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

org.sonar.plugins.csharp.S927.html Maven / Gradle / Ivy

There is a newer version: 10.2.0.105762
Show newest version

Why is this an issue?

Parameters are part of the method signature and its identity.

Implementing a method from an interface, a base class, or a partial method and changing one of its parameters' names will confuse and impact the method’s readability.

interface IBankAccount
{
  void AddMoney(int money);
}

class BankAccount : IBankAccount
{
  void AddMoney(int amount) // Noncompliant: parameter's name differs from base
  {
    // ...
  }
}

To avoid any ambiguity in the code, a parameter’s name should match the initial declaration, whether its initial declaration is from an interface, a base class, or a partial method.

interface IBankAccount
{
  void AddMoney(int money);
}

class BankAccount : IBankAccount
{
  void AddMoney(int money) // Compliant: parameter's name match base name
  {
    // ...
  }
}

Resources

Documentation





© 2015 - 2024 Weber Informatics LLC | Privacy Policy