diff options
| author | Amaury Levé | 2018-06-25 14:31:23 +0200 |
|---|---|---|
| committer | Elena Vilchik | 2018-06-26 11:49:59 +0200 |
| commit | ad92bb6746b5b29ce41f91f7aa6dc2bb8195fa07 (patch) | |
| tree | 7f40cf87f1a58430f8f22e90d3d85ffb1463cbdb /sonar-css-plugin/src | |
| parent | e78f845d7f25952cd5703296455e4e4825d9ec8e (diff) | |
| download | sonar-css-ad92bb6746b5b29ce41f91f7aa6dc2bb8195fa07.tar.bz2 | |
Rule S4666: Selectors should not be duplicated
Diffstat (limited to 'sonar-css-plugin/src')
5 files changed, 64 insertions, 0 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 479adb5..3951f64 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 @@ -39,6 +39,7 @@ import org.sonar.css.plugin.rules.FontFamilyNoDuplicateNames; import org.sonar.css.plugin.rules.FontFamilyNoMissingGenericFamilyKeyword; import org.sonar.css.plugin.rules.KeyframeDeclarationNoImportant; import org.sonar.css.plugin.rules.NoDuplicateAtImportRules; +import org.sonar.css.plugin.rules.NoDuplicateSelectors; import org.sonar.css.plugin.rules.NoEmptySource; import org.sonar.css.plugin.rules.NoExtraSemicolons; import org.sonar.css.plugin.rules.PropertyNoUnknown; @@ -72,6 +73,7 @@ public class CssRules { FontFamilyNoMissingGenericFamilyKeyword.class, KeyframeDeclarationNoImportant.class, NoDuplicateAtImportRules.class, + NoDuplicateSelectors.class, NoEmptySource.class, NoExtraSemicolons.class, PropertyNoUnknown.class, diff --git a/sonar-css-plugin/src/main/java/org/sonar/css/plugin/rules/NoDuplicateSelectors.java b/sonar-css-plugin/src/main/java/org/sonar/css/plugin/rules/NoDuplicateSelectors.java new file mode 100644 index 0000000..9c1d2df --- /dev/null +++ b/sonar-css-plugin/src/main/java/org/sonar/css/plugin/rules/NoDuplicateSelectors.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 = "S4666") +public class NoDuplicateSelectors implements CssRule { + + @Override + public String stylelintKey() { + return "no-duplicate-selectors"; + } +} diff --git a/sonar-css-plugin/src/main/resources/org/sonar/l10n/css/rules/css/S4666.html b/sonar-css-plugin/src/main/resources/org/sonar/l10n/css/rules/css/S4666.html new file mode 100644 index 0000000..9521f64 --- /dev/null +++ b/sonar-css-plugin/src/main/resources/org/sonar/l10n/css/rules/css/S4666.html @@ -0,0 +1,14 @@ +<p>When a selector appears more than once in a statement, this is not a bug but probably a mistake that reduces the readability of the source code. +Therefore, selectors should not be duplicated.</p> +<h2>Noncompliant Code Example</h2> +<pre> +.foo, +.bar, +.foo {} +</pre> +<h2>Compliant Solution</h2> +<pre> +.bar, +.foo {} +</pre> + diff --git a/sonar-css-plugin/src/main/resources/org/sonar/l10n/css/rules/css/S4666.json b/sonar-css-plugin/src/main/resources/org/sonar/l10n/css/rules/css/S4666.json new file mode 100644 index 0000000..f8be3d1 --- /dev/null +++ b/sonar-css-plugin/src/main/resources/org/sonar/l10n/css/rules/css/S4666.json @@ -0,0 +1,16 @@ +{ + "title": "Selectors should not be duplicated", + "type": "CODE_SMELL", + "status": "ready", + "remediation": { + "func": "Constant\/Issue", + "constantCost": "1min" + }, + "tags": [ + + ], + "defaultSeverity": "Minor", + "ruleSpecification": "RSPEC-4666", + "sqKey": "S4666", + "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 aa28914..079c18c 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 @@ -14,6 +14,7 @@ "S4657", "S4658", "S4663", + "S4666", "S4667" ] }
|
