Details

    • Type: Code Smell Detection
    • Status: Active
    • Resolution: Unresolved
    • Labels:
    • Message:
      Use decimal rather than octal values.
    • Default Severity:
      Blocker
    • Impact:
      High
    • Likelihood:
      High
    • Legacy Key:
      OctalConstantAndSequence, OctalNumber
    • Targeted languages:
      PHP, Python
    • Covered Languages:
      C, C++, Flex, Go, Java, JavaScript, Objective-C, Ruby
    • Irrelevant for Languages:
      ABAP, C#, Cobol, HTML, Kotlin, PL/I, PL/SQL, RPG, Swift, T-SQL, TypeScript, VB.Net, VB6, XML
    • Remediation Function:
      Constant/Issue
    • Constant Cost:
      5min
    • Analysis Level:
      Syntactic Analysis
    • Analysis Scope:
      Main Sources, Test Sources
    • Common Rule:
      Yes
    • CERT:
      DCL18-C., DCL50-J.
    • ESLint:
      no-octal
    • PC-Lint:
      9001
    • PMD:
      AvoidUsingOctalValues

      Description

      Integer literals starting with a zero are octal rather than decimal values. While using octal values is fully supported, most developers do not have experience with them. They may not recognize octal values as such, mistaking them instead for decimal values.

      Noncompliant Code Example

      int myNumber = 010;   // Noncompliant. myNumber will hold 8, not 10 - was this really expected?
      

      Compliant Solution

      int myNumber = 8;
      

      See

        Attachments

          Issue Links

          1.
          JavaScript RSPEC-3197 Language-Specification Active Unassigned
          2.
          Flex RSPEC-3198 Language-Specification Active Unassigned
          3.
          C-Family RSPEC-4383 Language-Specification Active Unassigned
          4.
          Go RSPEC-4580 Language-Specification Active Unassigned
          5.
          Ruby RSPEC-4777 Language-Specification Active Unassigned

            Activity

              People

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

                Dates

                • Created:
                  Updated: