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

Comments should not be located at the end of lines of code

    Details

    • Type: Code Smell Detection
    • Status: Active
    • Resolution: Unresolved
    • Labels:
    • Message:
      Move this trailing comment on the previous empty line.
    • List of parameters:
      Hide

      Key: legalTrailingCommentPattern
      description: Pattern for text of trailing comments that are allowed. By default, comments containing only one word.
      Default Value: ^\s*[^\s]+$
      Default Value PHP: ^(//|#)\s*[^\s]+$
      Default Value Swift: ^//\s*[^\s]+$
      Default Value VB6: ^'\s*[^\s]+$

      Show
      Key: legalTrailingCommentPattern description: Pattern for text of trailing comments that are allowed. By default, comments containing only one word. Default Value: ^\s* [^\s] +$ Default Value PHP: ^(//|#)\s* [^\s] +$ Default Value Swift: ^//\s* [^\s] +$ Default Value VB6: ^'\s* [^\s] +$
    • Default Severity:
      Minor
    • Impact:
      Low
    • Likelihood:
      Low
    • Legacy Key:
      trailing-comment, TrailingCommentCheck, TrailingComment
    • Targeted languages:
      C#, Flex
    • Covered Languages:
      C, C++, Java, JavaScript, Objective-C, PHP, PL/SQL, Python, Swift, VB.Net, VB6
    • Remediation Function:
      Constant/Issue
    • Constant Cost:
      1min
    • Analysis Scope:
      Main Sources, Test Sources
    • Checkstyle:
      TrailingComment
    • ESLint:
      no-inline-comment

      Description

      This rule verifies that single-line comments are not located at the ends of lines of code. The main idea behind this rule is that in order to be really readable, trailing comments would have to be properly written and formatted (correct alignment, no interference with the visual structure of the code, not too long to be visible) but most often, automatic code formatters would not handle this correctly: the code would end up less readable. Comments are far better placed on the previous empty line of code, where they will always be visible and properly formatted.

        Attachments

          Issue Links

          1.
          VB.NET RSPEC-2300 Language-Specification Active Unassigned
          2.
          Swift RSPEC-2507 Language-Specification Active Unassigned
          3.
          C-Family RSPEC-2896 Language-Specification Active Unassigned
          4.
          Java RSPEC-3150 Language-Specification Active Unassigned
          5.
          JavaScript RSPEC-3151 Language-Specification Active Unassigned
          6.
          PHP RSPEC-3152 Language-Specification Active Unassigned
          7.
          PL/SQL RSPEC-3153 Language-Specification Active Unassigned
          8.
          VB6 RSPEC-3154 Language-Specification Active Unassigned
          9.
          Python RSPEC-4008 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: