diff options
Diffstat (limited to 'sonar-css-plugin/src')
5 files changed, 72 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 91f1898..4456b50 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.FontFamilyNoMissingGenericFamilyKeyword; import org.sonar.css.plugin.rules.KeyframeDeclarationNoImportant; import org.sonar.css.plugin.rules.NoDuplicateAtImportRules; import org.sonar.css.plugin.rules.NoEmptySource; @@ -60,6 +61,7 @@ public class CssRules { ColorNoInvalidHex.class, CommentNoEmpty.class, DeclarationBlockNoDuplicateProperties.class, + FontFamilyNoMissingGenericFamilyKeyword.class, KeyframeDeclarationNoImportant.class, NoDuplicateAtImportRules.class, NoEmptySource.class, diff --git a/sonar-css-plugin/src/main/java/org/sonar/css/plugin/rules/FontFamilyNoMissingGenericFamilyKeyword.java b/sonar-css-plugin/src/main/java/org/sonar/css/plugin/rules/FontFamilyNoMissingGenericFamilyKeyword.java new file mode 100644 index 0000000..9cdc1b5 --- /dev/null +++ b/sonar-css-plugin/src/main/java/org/sonar/css/plugin/rules/FontFamilyNoMissingGenericFamilyKeyword.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 = "S4649") +public class FontFamilyNoMissingGenericFamilyKeyword implements CssRule { + + @Override + public String stylelintKey() { + return "font-family-no-missing-generic-family-keyword"; + } +} diff --git a/sonar-css-plugin/src/main/resources/org/sonar/l10n/css/rules/css/S4649.html b/sonar-css-plugin/src/main/resources/org/sonar/l10n/css/rules/css/S4649.html new file mode 100644 index 0000000..0816eb7 --- /dev/null +++ b/sonar-css-plugin/src/main/resources/org/sonar/l10n/css/rules/css/S4649.html @@ -0,0 +1,22 @@ +<p>If none of the font names defined in a <code>font</code> or <code>font-family</code> declaration are available on the browser of the user, the +browser will display the text using its default font. It's recommended to always define a generic font family for each declaration of +<code>font</code> or <code>font-family</code> to get a less degraded situation than relying on the default browser font. All browsers should implement +a list of generic font matching these families: <code>Serif</code>, <code>Sans-serif</code>, <code>cursive</code>, <code>fantasy</code>, +<code>Monospace</code>.</p> +<h2>Noncompliant Code Example</h2> +<pre> +a { + font-family: Helvetica, Arial, Verdana, Tahoma; +} +</pre> +<h2>Compliant Solution</h2> +<pre> +a { + font-family: Helvetica, Arial, Verdana, Tahoma, sans-serif; +} +</pre> +<h2>See</h2> +<ul> + <li> https://www.w3.org/TR/CSS2/fonts.html#generic-font-families </li> +</ul> + diff --git a/sonar-css-plugin/src/main/resources/org/sonar/l10n/css/rules/css/S4649.json b/sonar-css-plugin/src/main/resources/org/sonar/l10n/css/rules/css/S4649.json new file mode 100644 index 0000000..eb427fa --- /dev/null +++ b/sonar-css-plugin/src/main/resources/org/sonar/l10n/css/rules/css/S4649.json @@ -0,0 +1,16 @@ +{ + "title": "Font declarations should contain at least one generic font family", + "type": "BUG", + "status": "ready", + "remediation": { + "func": "Constant\/Issue", + "constantCost": "1min" + }, + "tags": [ + + ], + "defaultSeverity": "Major", + "ruleSpecification": "RSPEC-4649", + "sqKey": "S4649", + "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 4455af6..5fb55c0 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", + "S4649", "S4652", "S4653", "S4655", |
