org.sonar.plugins.csharp.S927.html Maven / Gradle / Ivy
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