From: Evgeny Mandrikov Date: Wed, 29 Aug 2012 10:19:07 +0000 (+0600) Subject: SONAR-3729 Fix key for Checkstyle rule TrailingComment X-Git-Tag: 3.3~333 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=7015d958aee6a342c2f9f7afec58b8211c925e21;p=sonarqube.git SONAR-3729 Fix key for Checkstyle rule TrailingComment --- diff --git a/plugins/sonar-checkstyle-plugin/src/main/resources/org/sonar/plugins/checkstyle/rules.xml b/plugins/sonar-checkstyle-plugin/src/main/resources/org/sonar/plugins/checkstyle/rules.xml index c281f27bdcd..6e9b9e608cb 100644 --- a/plugins/sonar-checkstyle-plugin/src/main/resources/org/sonar/plugins/checkstyle/rules.xml +++ b/plugins/sonar-checkstyle-plugin/src/main/resources/org/sonar/plugins/checkstyle/rules.xml @@ -1119,7 +1119,7 @@ - + MINOR diff --git a/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/checkstyle.properties b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/checkstyle.properties index 160fe92f4bc..96efaa871df 100644 --- a/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/checkstyle.properties +++ b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/checkstyle.properties @@ -109,9 +109,9 @@ rule.checkstyle.com.puppycrawl.tools.checkstyle.checks.header.HeaderCheck.param. rule.checkstyle.com.puppycrawl.tools.checkstyle.checks.coding.AvoidInlineConditionalsCheck.name=Avoid Inline Conditionals rule.checkstyle.com.puppycrawl.tools.checkstyle.checks.coding.NestedTryDepthCheck.name=Nested Try Depth rule.checkstyle.com.puppycrawl.tools.checkstyle.checks.coding.NestedTryDepthCheck.param.max=allowed nesting depth. Default is 1. -rule.checkstyle.com.puppycrawl.tools.checkstyle.checks.indentation.TrailingCommentCheck.name=Trailing Comment -rule.checkstyle.com.puppycrawl.tools.checkstyle.checks.indentation.TrailingCommentCheck.param.legalComment=pattern for text of trailing comment which is allowed. (this patter will not be applied to multiline comments and text of comment will be trimmed before matching) -rule.checkstyle.com.puppycrawl.tools.checkstyle.checks.indentation.TrailingCommentCheck.param.format=pattern for string allowed before comment. +rule.checkstyle.com.puppycrawl.tools.checkstyle.checks.TrailingCommentCheck.name=Trailing Comment +rule.checkstyle.com.puppycrawl.tools.checkstyle.checks.TrailingCommentCheck.param.legalComment=pattern for text of trailing comment which is allowed. (this patter will not be applied to multiline comments and text of comment will be trimmed before matching) +rule.checkstyle.com.puppycrawl.tools.checkstyle.checks.TrailingCommentCheck.param.format=pattern for string allowed before comment. rule.checkstyle.com.puppycrawl.tools.checkstyle.checks.naming.ParameterNameCheck.name=Parameter Name rule.checkstyle.com.puppycrawl.tools.checkstyle.checks.modifier.RedundantModifierCheck.name=Redundant Modifier rule.checkstyle.com.puppycrawl.tools.checkstyle.checks.modifier.RedundantModifierCheck.param.tokens=tokens to check diff --git a/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/checkstyle/rules/checkstyle/com.puppycrawl.tools.checkstyle.checks.TrailingCommentCheck.html b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/checkstyle/rules/checkstyle/com.puppycrawl.tools.checkstyle.checks.TrailingCommentCheck.html new file mode 100644 index 00000000000..1a58f64f62d --- /dev/null +++ b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/checkstyle/rules/checkstyle/com.puppycrawl.tools.checkstyle.checks.TrailingCommentCheck.html @@ -0,0 +1,41 @@ +

+ The check to ensure that requires that comments be the only thing on a line. For the case of // comments that means that the only thing that should precede it is whitespace. It + doesn't check comments if they do not end line, i.e. it accept the following: Thread.sleep( 10 <some comment here> ); Format property is intended to deal with the "} // + while" example. +

+

+ Rationale: Steve McConnel in "Code Complete" suggests that endline comments are a bad practice. An end line comment would be one that is on the same line as actual code. For + example: +

+
+  
+    a = b + c; // Some insightful comment
+    d = e / f; // Another comment for this line
+  
+
+ +

+ Quoting "Code Complete" for the justfication: +

+
    +
  • "The comments have to be aligned so that they do not interfere with the visual structure of the code. If you don't align them neatly, they'll make your listing look like it's + been through a washing machine." +
  • +
  • "Endline comments tend to be hard to format...It takes time to align them. Such time is not spent learning more about the code; it's dedicated solely to the tedious task of + pressing the spacebar or tab key." +
  • +
  • "Endline comments are also hard to maintain. If the code on any line containing an endline comment grows, it bumps the comment farther out, and all the other endline comments + will have to bumped out to match. Styles that are hard to maintain aren't maintained...." +
  • +
  • "Endline comments also tend to be cryptic. The right side of the line doesn't offer much room and the desire to keep the comment on one line means the comment must be short. + Work + then goes into making the line as short as possible instead of as clear as possible. The comment usually ends up as cryptic as possible...." +
  • +
  • "A systemic problem with endline comments is that it's hard to write a meaningful comment for one line of code. Most endline comments just repeat the line of code, which + hurts + more than it helps." +
  • +
+

+ His comments on being hard to maintain when the size of the line changes are even more important in the age of automated refactorings. +

\ No newline at end of file diff --git a/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/checkstyle/rules/checkstyle/com.puppycrawl.tools.checkstyle.checks.indentation.TrailingCommentCheck.html b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/checkstyle/rules/checkstyle/com.puppycrawl.tools.checkstyle.checks.indentation.TrailingCommentCheck.html deleted file mode 100644 index 1a58f64f62d..00000000000 --- a/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/checkstyle/rules/checkstyle/com.puppycrawl.tools.checkstyle.checks.indentation.TrailingCommentCheck.html +++ /dev/null @@ -1,41 +0,0 @@ -

- The check to ensure that requires that comments be the only thing on a line. For the case of // comments that means that the only thing that should precede it is whitespace. It - doesn't check comments if they do not end line, i.e. it accept the following: Thread.sleep( 10 <some comment here> ); Format property is intended to deal with the "} // - while" example. -

-

- Rationale: Steve McConnel in "Code Complete" suggests that endline comments are a bad practice. An end line comment would be one that is on the same line as actual code. For - example: -

-
-  
-    a = b + c; // Some insightful comment
-    d = e / f; // Another comment for this line
-  
-
- -

- Quoting "Code Complete" for the justfication: -

-
    -
  • "The comments have to be aligned so that they do not interfere with the visual structure of the code. If you don't align them neatly, they'll make your listing look like it's - been through a washing machine." -
  • -
  • "Endline comments tend to be hard to format...It takes time to align them. Such time is not spent learning more about the code; it's dedicated solely to the tedious task of - pressing the spacebar or tab key." -
  • -
  • "Endline comments are also hard to maintain. If the code on any line containing an endline comment grows, it bumps the comment farther out, and all the other endline comments - will have to bumped out to match. Styles that are hard to maintain aren't maintained...." -
  • -
  • "Endline comments also tend to be cryptic. The right side of the line doesn't offer much room and the desire to keep the comment on one line means the comment must be short. - Work - then goes into making the line as short as possible instead of as clear as possible. The comment usually ends up as cryptic as possible...." -
  • -
  • "A systemic problem with endline comments is that it's hard to write a meaningful comment for one line of code. Most endline comments just repeat the line of code, which - hurts - more than it helps." -
  • -
-

- His comments on being hard to maintain when the size of the line changes are even more important in the age of automated refactorings. -

\ No newline at end of file