From 8772a07e5a27f5858ed438d32f717c36d2307e3f Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Thu, 23 Feb 2012 10:33:38 +0100 Subject: [PATCH] Improve description of the Checkstyle rule "Trailing Comment" --- .../org/sonar/plugins/checkstyle/rules.xml | 13 +++--- ...ecks.indentation.TrailingCommentCheck.html | 42 ++++++++++++++++++- 2 files changed, 48 insertions(+), 7 deletions(-) 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 37c17e03d5f..35c03296e42 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 @@ -1427,13 +1427,14 @@ MINOR - - - - + + format + r + ^[\\s\\}\\);]*$ - - + + legalComment + r diff --git a/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/checkstyle/com.puppycrawl.tools.checkstyle.checks.indentation.TrailingCommentCheck.html b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/checkstyle/com.puppycrawl.tools.checkstyle.checks.indentation.TrailingCommentCheck.html index 0296f30b6ad..1a58f64f62d 100644 --- a/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/checkstyle/com.puppycrawl.tools.checkstyle.checks.indentation.TrailingCommentCheck.html +++ b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/checkstyle/com.puppycrawl.tools.checkstyle.checks.indentation.TrailingCommentCheck.html @@ -1 +1,41 @@ -The check to ensure that requires that comments be the only thing on a line. \ No newline at end of file +

+ 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: +

+ +

+ 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 -- 2.39.5