Uploaded image for project: 'SonarJava'
  1. SonarJava
  2. SONARJAVA-1117

FP in S109 (MagicNumber): Numbers used in constructor of enum constants should be ignored

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.4
    • Component/s: None
    • Labels:
      None

      Description

      The following code should not raise issue, as enum constants as numbers used in their constructors will define the enum constant itself!

      enum CDataType { 
      
           UINT8(1),  // should not raise issue!
           DOUBLE(8);  // should not raise issue!
      
          private int byteSize; 
      
          private CDataType(final int bSize){ 
             this.byteSize = bSize; 
          } 
      
      } 
      

        Attachments

          Activity

            People

            Assignee:
            samuel.mercier Samuel Mercier (Inactive)
            Reporter:
            michael.gumowski Michael Gumowski
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Due:
              Created:
              Updated:
              Resolved: