Skip to content

AA1301VariablesShouldBeAssignedOnceOnly

David Arno edited this page Oct 3, 2016 · 2 revisions

Warning: this wiki page is auto-generated by the Arnolyzer solution-build process. Do not directly edit this page, as your changes will be lost on the next commit. To edit this page, please refer to Contributing to this project.

These wiki pages reflect the state of the project in development, per the last commit. For details of the latest release of the Arnolyzer Analysers, please see the Arnolyzer website.


AA1301 - Variables Should Be Assigned Once Only

Report code: AA1301-VariablesShouldBeAssignedOnceOnly

Summary

Status Implemented
Description Variables should be treated as immutable and should not be overwritten
Category Immutability Analyzers
Enabled by default: Yes
Severity: Error

Cause

How to fix violations

There currently aren't any implemented code-fixes for this rule.

How to suppress violations

This rule can be suppressed using the following attributes:

[MutableVariable]
A method annotated with MutableVariable attribute is allowed to have variables that change value (ie canbe reassigned. The variables affected must be named in the MutableVariable attribute attribute, eg

[MutableVariable attribute("var1")]
public void F()
{
    var var1 = 1;
var1 = 2;
}

Multiple variables can be supplied to the attribute, eg [MutableVariable attribute("var1", "var2")]