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

Type specifiers should be listed in a standard order

    Details

    • Type: Code Smell Detection
    • Status: Active
    • Resolution: Unresolved
    • Message:
      Reorder these specifiers to: "xxx yyy zzz..."
    • Default Severity:
      Minor
    • Impact:
      Low
    • Likelihood:
      Low
    • Covered Languages:
      C, C++, Objective-C
    • Remediation Function:
      Constant/Issue
    • Constant Cost:
      2min
    • CppCoreGuidelines:
      NL.26

      Description

      Shared coding conventions allow teams to collaborate efficiently. This rule checks that type specifiers always appear in the following order:

      1. typedef
      2. type name, spelling of built-in types with more than one type-specifier:
        1. signedness - signed or unsigned
        2. last single type-specifier or
          • short int
          • long int
          • long long int
          • long double

      Since the positioning of the const keyword is controversial, this rule does not check it.

      Noncompliant Code Example

      int typedef T;
      
      double long d;
      char unsigned ch;
      long signed int i;
      

      Compliant Solution

      typedef int T;
      
      long double d;
      unsigned char ch;
      signed long int i;
      

      See

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                ann.campbell.2 Ann Campbell
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated: