diff options
| author | Amaury Levé | 2018-06-25 11:58:32 +0200 | 
|---|---|---|
| committer | Amaury Levé | 2018-06-25 15:05:03 +0200 | 
| commit | b45e6c9923f9ab8a27a81430dfea81d5302922d3 (patch) | |
| tree | 1d4bfa1a244876d746913da800a5c50a691bbb6d /sonar-css-plugin/src | |
| parent | 0105e87be8d99a8e9c99faa0a278fc3a2d676a20 (diff) | |
| download | sonar-css-b45e6c9923f9ab8a27a81430dfea81d5302922d3.tar.bz2 | |
Rule S4658: Empty blocks should be removed
Diffstat (limited to 'sonar-css-plugin/src')
5 files changed, 61 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 9545b1f..689d361 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 @@ -29,6 +29,7 @@ import javax.annotation.Nullable;  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.BlockNoEmpty;  import org.sonar.css.plugin.rules.ColorNoInvalidHex;  import org.sonar.css.plugin.rules.CommentNoEmpty;  import org.sonar.css.plugin.rules.CssRule; @@ -60,6 +61,7 @@ public class CssRules {    public static List<Class> getRuleClasses() {      return Collections.unmodifiableList(Arrays.asList( +      BlockNoEmpty.class,        ColorNoInvalidHex.class,        CommentNoEmpty.class,        DeclarationBlockNoDuplicateProperties.class, diff --git a/sonar-css-plugin/src/main/java/org/sonar/css/plugin/rules/BlockNoEmpty.java b/sonar-css-plugin/src/main/java/org/sonar/css/plugin/rules/BlockNoEmpty.java new file mode 100644 index 0000000..c27ed0e --- /dev/null +++ b/sonar-css-plugin/src/main/java/org/sonar/css/plugin/rules/BlockNoEmpty.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 = "S4658") +public class BlockNoEmpty implements CssRule { + +  @Override +  public String stylelintKey() { +    return "block-no-empty"; +  } +} diff --git a/sonar-css-plugin/src/main/resources/org/sonar/l10n/css/rules/css/S4658.html b/sonar-css-plugin/src/main/resources/org/sonar/l10n/css/rules/css/S4658.html new file mode 100644 index 0000000..44648db --- /dev/null +++ b/sonar-css-plugin/src/main/resources/org/sonar/l10n/css/rules/css/S4658.html @@ -0,0 +1,11 @@ +<p>Leftover empty blocks are usually introduced by mistake. They are useless and prevent readability of the code. They should be removed or completed +with real code.</p> +<h2>Noncompliant Code Example</h2> +<pre> +a { } +</pre> +<h2>Compliant Solution</h2> +<pre> +a { color: pink; } +</pre> + diff --git a/sonar-css-plugin/src/main/resources/org/sonar/l10n/css/rules/css/S4658.json b/sonar-css-plugin/src/main/resources/org/sonar/l10n/css/rules/css/S4658.json new file mode 100644 index 0000000..5ba10d9 --- /dev/null +++ b/sonar-css-plugin/src/main/resources/org/sonar/l10n/css/rules/css/S4658.json @@ -0,0 +1,16 @@ +{ +  "title": "Empty blocks should be removed", +  "type": "CODE_SMELL", +  "status": "ready", +  "remediation": { +    "func": "Constant\/Issue", +    "constantCost": "1min" +  }, +  "tags": [ +     +  ], +  "defaultSeverity": "Major", +  "ruleSpecification": "RSPEC-4658", +  "sqKey": "S4658", +  "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 0a7d005..d7ae454 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 @@ -10,6 +10,7 @@      "S4653",      "S4655",      "S4656", +    "S4658",      "S4663",      "S4667"    ] | 
