All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.sonar.l10n.csharp.rules.csharpsquid.ParameterAssignedTo.html Maven / Gradle / Ivy

There is a newer version: 4.0
Show newest version

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