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

"public static" fields should be constant

    Details

    • Type: Code Smell Detection
    • Status: Active
    • Resolution: Unresolved
    • Labels:
    • Message:
      Make this "public static XXX" field [final|const]
    • Default Severity:
      Minor
    • Impact:
      Low
    • Likelihood:
      Low
    • Default Quality Profiles:
      Sonar way
    • Targeted languages:
      C#, C++
    • Covered Languages:
      Flex, Java
    • Remediation Function:
      Constant/Issue
    • Constant Cost:
      20min
    • Analysis Scope:
      Main Sources
    • CERT:
      OBJ10-J.
    • CWE:
      CWE-500
    • FindBugs:
      MS_SHOULD_BE_REFACTORED_TO_BE_FINAL,MS_SHOULD_BE_FINAL,MS_CANNOT_BE_FINAL

      Description

      There is no good reason to declare a field "public" and "static" without also declaring it "const". Most of the time this is a kludge to share a state among several objects. But with this approach, any object can do whatever it wants with the shared state, such as setting it to null.

      See

        Attachments

          Issue Links

          1.
          Java RSPEC-2378 Language-Specification Active Unassigned
          2.
          Flex RSPEC-5992 Language-Specification Active Unassigned

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                freddy.mallet Freddy Mallet (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated: