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

Literal suffixes should be upper case

    Details

    • Message:
      Upper case this literal suffix.
    • Default Severity:
      Minor
    • Impact:
      Low
    • Likelihood:
      Low
    • Default Quality Profiles:
      Sonar way
    • Legacy Key:
      LiteralSuffix
    • Covered Languages:
      C#, C, C++, Java, Objective-C
    • Irrelevant for Languages:
      ABAP, Cobol, Flex, Go, HTML, JavaScript, PHP, PL/I, PL/SQL, Python, RPG, Swift, T-SQL, TypeScript, VB.Net, VB6, XML
    • Remediation Function:
      Constant/Issue
    • Constant Cost:
      2min
    • Analysis Level:
      Syntactic Analysis
    • Analysis Scope:
      Main Sources, Test Sources
    • Common Rule:
      Yes
    • CERT:
      DCL16-C., DCL50-J.
    • Checkstyle:
      UpperEll
    • PC-Lint:
      620, 1620, 9057, 9106
    • ReSharper:
      LongLiteralEndingLowerL

      Description

      Using upper case literal suffixes removes the potential ambiguity between "1" (digit 1) and "l" (letter el) for declaring literals.

      Noncompliant Code Example

      const int        a = 0u;      // Noncompliant
      const int        b = 0l;      // Noncompliant
      const int        c = 0Ul;     // Noncompliant
      const int        d = 0x12bu;  // Noncompliant
      const float      m = 1.2f;    // Noncompliant
      const float      n = 1.2l;    // Noncompliant
      

      Compliant Solution

      const int        a = 0U;
      const int        b = 0L;
      const int        c = 0UL;
      const int        d = 0x12bU;
      const float      m = 1.2F;
      const float      n = 1.2L;
      

      See

        Attachments

          Issue Links

          1.
          C-Family: Literal suffixes shall be upper case RSPEC-3232 Language-Specification Active Unassigned
          2.
          Java RSPEC-3339 Language-Specification Active Unassigned
          3.
          C# RSPEC-3347 Language-Specification Active Unassigned

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                Anonymous
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated: