Uploaded image for project: 'Rules Repository'
  1. Rules Repository
  2. RSPEC-4174

Local constants should follow naming conventions for constants

    XMLWordPrintable

    Details

    • Type: Code Smell Detection
    • Status: Active
    • Resolution: Unresolved
    • Labels:
    • Message:
      Rename this local constant "XXXX" to match the regular expression: ${format}
    • List of parameters:
      Hide

      Key: format
      Description: Regular expression used to check the constant names against.
      Default Value: ^[A-Z][A-Z0-9]*(_[A-Z0-9]+)$

      Show
      Key: format Description: Regular expression used to check the constant names against. Default Value: ^ [A-Z] [A-Z0-9] *(_ [A-Z0-9] +)$
    • Default Severity:
      Minor
    • Impact:
      Low
    • Likelihood:
      Low
    • Covered Languages:
      Java
    • Remediation Function:
      Constant/Issue
    • Constant Cost:
      5min
    • Analysis Scope:
      Main Sources, Test Sources

      Description

      Shared coding conventions allow teams to collaborate efficiently. This rule checks that all local, final, initialized, primitive variables, have names that match a provided regular expression.

      Noncompliant Code Example

      With the default regular expression ^[A-Z][A-Z0-9](_[A-Z0-9]+)$:

      public void doSomething() { 
        final int local = 42;    
        ...             
      }
      

      Compliant Solution

      public void doSomething() { 
        final int LOCAL = 42;  
        ...               
      }
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              michael.gumowski Michael Gumowski
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated: