
org.sonar.l10n.csharp.rules.csharpsquid.ParameterAssignedTo.html Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sonar-csharp-plugin Show documentation
Show all versions of sonar-csharp-plugin Show documentation
Enable analysis and reporting on C# projects.
Parameters variables that are not marked as out
or ref
should not be assigned to from within a method.
Those modifications will not impact the caller of the method, which can be confusing.
Instead, it is better to assign the parameter to a temporary variable.
The following code snippet:
void foo(int a)
{
a = 42; // Non-Compliant
}
should be refactored into:
void foo(int a)
{
int tmp = a;
tmp = 42; // Compliant
}
or:
void foo(out int a) // 'ref' is also allowed
{
a = 42; // Compliant
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy