You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Category: Naming Title: Local constant names must begin with upper case letter Description: A violation of this rule occurs when a const variable declared within a method has a name that starts with a lower-case letter. For consistency with other const usages throughout the application, these variables should have a name that starts with an upper-case letter. Rationale: In #1310, a new rule was added which enforces a local non-const variable naming convention which is identical to the naming convention used by private non-const fields. This rule proposes a matching rule for local const variables to use the same naming convention as private const fields.
I don't like the idea to enforce local consts to be started with an upper-case letter. I never named local consts like this in my code. If an identifier starts with an upper-case letter then it always has an external scope (class field, method, etc.) and the upper-case-started local consts would not be consistent with this.
I would rather treat them like immutable variables and prefer to enforce them to be started with a lower-case letter instead (maybe it make sense to check them within the newly proposed rule #1310 and not to create a separate rule).
@test20150828 Rule #1310 requires that local variables use the same naming convention as private fields. Like the original rule for private fields (SA1306), this rule does not evaluate variables marked const. This proposal is a consistent pairing with that rule - it applies the same naming convention for local const variables as is current applied for private const fields. Requiring that local const variables start with a lower case variable would introduce an inconsistency in our rules which I would like to avoid.
sharwell
changed the title
SA1300 should check the names of local constants
New rule proposal: LocalConstNamesMustBeginWithUpperCaseLetter
Aug 28, 2015
Category: Naming
Title: Local constant names must begin with upper case letter
Description: A violation of this rule occurs when a
const
variable declared within a method has a name that starts with a lower-case letter. For consistency with otherconst
usages throughout the application, these variables should have a name that starts with an upper-case letter.Rationale: In #1310, a new rule was added which enforces a local non-
const
variable naming convention which is identical to the naming convention used by private non-const
fields. This rule proposes a matching rule for localconst
variables to use the same naming convention as privateconst
fields.Example:
The text was updated successfully, but these errors were encountered: