aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-css-plugin/src
diff options
context:
space:
mode:
authorAmaury Levé2018-06-21 15:53:16 +0200
committerElena Vilchik2018-06-21 15:53:16 +0200
commit7a2daa058f3da99a224a2c874e554f88d2ad8104 (patch)
tree3744b3a0d73ec6716320fc068d85a70633c5082f /sonar-css-plugin/src
parent9bcc46b342cfb888f16c180cb0b3103335def5f1 (diff)
downloadsonar-css-7a2daa058f3da99a224a2c874e554f88d2ad8104.tar.bz2
Rule S4663: Comments should not be empty (#51)
Diffstat (limited to 'sonar-css-plugin/src')
-rw-r--r--sonar-css-plugin/src/main/java/org/sonar/css/plugin/CssRules.java4
-rw-r--r--sonar-css-plugin/src/main/java/org/sonar/css/plugin/rules/CommentNoEmpty.java31
-rw-r--r--sonar-css-plugin/src/main/resources/org/sonar/l10n/css/rules/css/S4663.html10
-rw-r--r--sonar-css-plugin/src/main/resources/org/sonar/l10n/css/rules/css/S4663.json16
-rw-r--r--sonar-css-plugin/src/main/resources/org/sonar/l10n/css/rules/css/Sonar_way_profile.json3
5 files changed, 62 insertions, 2 deletions
diff --git a/sonar-css-plugin/src/main/java/org/sonar/css/plugin/CssRules.java b/sonar-css-plugin/src/main/java/org/sonar/css/plugin/CssRules.java
index 1dac08c..5a4be0c 100644
--- a/sonar-css-plugin/src/main/java/org/sonar/css/plugin/CssRules.java
+++ b/sonar-css-plugin/src/main/java/org/sonar/css/plugin/CssRules.java
@@ -23,6 +23,7 @@ import org.sonar.api.batch.rule.CheckFactory;
import org.sonar.api.batch.rule.Checks;
import org.sonar.api.rule.RuleKey;
import org.sonar.css.plugin.rules.ColorNoInvalidHex;
+import org.sonar.css.plugin.rules.CommentNoEmpty;
import org.sonar.css.plugin.rules.CssRule;
import org.sonar.css.plugin.rules.UnitNoUnknown;
@@ -52,7 +53,8 @@ public class CssRules {
public static List<Class> getRuleClasses() {
return Collections.unmodifiableList(Arrays.asList(
ColorNoInvalidHex.class,
- UnitNoUnknown.class
+ UnitNoUnknown.class,
+ CommentNoEmpty.class
));
}
diff --git a/sonar-css-plugin/src/main/java/org/sonar/css/plugin/rules/CommentNoEmpty.java b/sonar-css-plugin/src/main/java/org/sonar/css/plugin/rules/CommentNoEmpty.java
new file mode 100644
index 0000000..547b5db
--- /dev/null
+++ b/sonar-css-plugin/src/main/java/org/sonar/css/plugin/rules/CommentNoEmpty.java
@@ -0,0 +1,31 @@
+/*
+ * SonarCSS
+ * Copyright (C) 2018-2018 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.css.plugin.rules;
+
+import org.sonar.check.Rule;
+
+@Rule(key = "S4663")
+public class CommentNoEmpty implements CssRule {
+
+ @Override
+ public String stylelintKey() {
+ return "comment-no-empty";
+ }
+}
diff --git a/sonar-css-plugin/src/main/resources/org/sonar/l10n/css/rules/css/S4663.html b/sonar-css-plugin/src/main/resources/org/sonar/l10n/css/rules/css/S4663.html
new file mode 100644
index 0000000..2b11dea
--- /dev/null
+++ b/sonar-css-plugin/src/main/resources/org/sonar/l10n/css/rules/css/S4663.html
@@ -0,0 +1,10 @@
+<p>An empty comment is likely to be a mistake and doesn't help to improve the readability of the code. For these reasons, it should be removed.</p>
+<h2>Noncompliant Code Example</h2>
+<pre>
+/* */
+
+/*
+
+ */
+</pre>
+
diff --git a/sonar-css-plugin/src/main/resources/org/sonar/l10n/css/rules/css/S4663.json b/sonar-css-plugin/src/main/resources/org/sonar/l10n/css/rules/css/S4663.json
new file mode 100644
index 0000000..70b312a
--- /dev/null
+++ b/sonar-css-plugin/src/main/resources/org/sonar/l10n/css/rules/css/S4663.json
@@ -0,0 +1,16 @@
+{
+ "title": "Comments should not be empty",
+ "type": "CODE_SMELL",
+ "status": "ready",
+ "remediation": {
+ "func": "Constant\/Issue",
+ "constantCost": "1min"
+ },
+ "tags": [
+
+ ],
+ "defaultSeverity": "Minor",
+ "ruleSpecification": "RSPEC-4663",
+ "sqKey": "S4663",
+ "scope": "Main"
+}
diff --git a/sonar-css-plugin/src/main/resources/org/sonar/l10n/css/rules/css/Sonar_way_profile.json b/sonar-css-plugin/src/main/resources/org/sonar/l10n/css/rules/css/Sonar_way_profile.json
index a0e81bb..f7ce787 100644
--- a/sonar-css-plugin/src/main/resources/org/sonar/l10n/css/rules/css/Sonar_way_profile.json
+++ b/sonar-css-plugin/src/main/resources/org/sonar/l10n/css/rules/css/Sonar_way_profile.json
@@ -2,6 +2,7 @@
"name": "Sonar way",
"ruleKeys": [
"S4647",
- "S4653"
+ "S4653",
+ "S4663"
]
}