diff options
| author | Amaury Levé | 2018-06-25 11:35:15 +0200 |
|---|---|---|
| committer | Elena Vilchik | 2018-06-25 11:57:13 +0200 |
| commit | 99ba1731fae85f49ae6bd9462a7d52070f104b52 (patch) | |
| tree | f3aceb434dba098a5b43d7512f9274e2043f21e6 /sonar-css-plugin/src | |
| parent | 15137476e5c5a2a4a39016928750cc0bd9af5f57 (diff) | |
| download | sonar-css-99ba1731fae85f49ae6bd9462a7d52070f104b52.tar.bz2 | |
Rule S4648: Duplicated font names should be removed
Diffstat (limited to 'sonar-css-plugin/src')
5 files changed, 66 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 4456b50..255f58f 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 @@ -33,6 +33,7 @@ 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.DeclarationBlockNoDuplicateProperties; +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; @@ -61,6 +62,7 @@ public class CssRules { ColorNoInvalidHex.class, CommentNoEmpty.class, DeclarationBlockNoDuplicateProperties.class, + FontFamilyNoDuplicateNames.class, FontFamilyNoMissingGenericFamilyKeyword.class, KeyframeDeclarationNoImportant.class, NoDuplicateAtImportRules.class, diff --git a/sonar-css-plugin/src/main/java/org/sonar/css/plugin/rules/FontFamilyNoDuplicateNames.java b/sonar-css-plugin/src/main/java/org/sonar/css/plugin/rules/FontFamilyNoDuplicateNames.java new file mode 100644 index 0000000..b1258e2 --- /dev/null +++ b/sonar-css-plugin/src/main/java/org/sonar/css/plugin/rules/FontFamilyNoDuplicateNames.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 = "S4648") +public class FontFamilyNoDuplicateNames implements CssRule { + + @Override + public String stylelintKey() { + return "font-family-no-duplicate-names"; + } +} diff --git a/sonar-css-plugin/src/main/resources/org/sonar/l10n/css/rules/css/S4648.html b/sonar-css-plugin/src/main/resources/org/sonar/l10n/css/rules/css/S4648.html new file mode 100644 index 0000000..02b3570 --- /dev/null +++ b/sonar-css-plugin/src/main/resources/org/sonar/l10n/css/rules/css/S4648.html @@ -0,0 +1,16 @@ +<p>Having duplicated font names doesn't help to read the font declaration and may be an indicator the author of the line was not sure how to configure +it. This rule raises an issue when <code>font</code> or <code>font-family</code> properties contain a duplicated font name. This rule ignores +<code>$sass</code>, <code>@less</code>, and <code>var(--custom-property)</code> variable syntaxes.</p> +<h2>Noncompliant Code Example</h2> +<pre> +a { + font-family: 'Georgia', Georgia, serif; +} +</pre> +<h2>Compliant Solution</h2> +<pre> +a { + font-family: Georgia, serif; +} +</pre> + diff --git a/sonar-css-plugin/src/main/resources/org/sonar/l10n/css/rules/css/S4648.json b/sonar-css-plugin/src/main/resources/org/sonar/l10n/css/rules/css/S4648.json new file mode 100644 index 0000000..487ab8a --- /dev/null +++ b/sonar-css-plugin/src/main/resources/org/sonar/l10n/css/rules/css/S4648.json @@ -0,0 +1,16 @@ +{ + "title": "Duplicated font names should be removed", + "type": "CODE_SMELL", + "status": "ready", + "remediation": { + "func": "Constant\/Issue", + "constantCost": "1min" + }, + "tags": [ + + ], + "defaultSeverity": "Major", + "ruleSpecification": "RSPEC-4648", + "sqKey": "S4648", + "scope": "All" +} 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 5fb55c0..64ab8d6 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 @@ -3,6 +3,7 @@ "ruleKeys": [ "S1128", "S4647", + "S4648", "S4649", "S4652", "S4653", |
