aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-css-plugin/src/main/resources/org
diff options
context:
space:
mode:
authorAmaury Levé2018-06-26 15:24:29 +0200
committerElena Vilchik2018-06-26 17:12:59 +0200
commit510ac865875fcd1ed4475a50f74fd3ed5f0de3d5 (patch)
treee5211369488c3107bb706064b8faa046650f10bc /sonar-css-plugin/src/main/resources/org
parent5aaa1f182736f84f1613aa60f3f7da37103167c2 (diff)
downloadsonar-css-510ac865875fcd1ed4475a50f74fd3ed5f0de3d5.tar.bz2
Rule S4664: Selectors of lower specificity should come before overriding selectors of higher specificity
Diffstat (limited to 'sonar-css-plugin/src/main/resources/org')
-rw-r--r--sonar-css-plugin/src/main/resources/org/sonar/l10n/css/rules/css/S4664.html28
-rw-r--r--sonar-css-plugin/src/main/resources/org/sonar/l10n/css/rules/css/S4664.json16
-rw-r--r--sonar-css-plugin/src/main/resources/org/sonar/l10n/css/rules/css/Sonar_way_profile.json1
3 files changed, 45 insertions, 0 deletions
diff --git a/sonar-css-plugin/src/main/resources/org/sonar/l10n/css/rules/css/S4664.html b/sonar-css-plugin/src/main/resources/org/sonar/l10n/css/rules/css/S4664.html
new file mode 100644
index 0000000..6f501e2
--- /dev/null
+++ b/sonar-css-plugin/src/main/resources/org/sonar/l10n/css/rules/css/S4664.html
@@ -0,0 +1,28 @@
+<p>Order of instructions in CSS is important: instructions that occur last in the file take the priority. When a selector with high specificity (eg
+<code>#container a top: 10px; </code>) comes before the selector it overrides (eg: <code>a top: 0; </code>), the priority is given to the high
+specificity definition which violates the principle of the last instruction takes the priority. </p>
+<p>CSS are most legible when overriding selectors always come after the selectors they override. That way both mechanisms, source order and
+specificity, work together nicely.</p>
+<h2>Noncompliant Code Example</h2>
+<pre>
+b a {}
+a {}
+
+
+@media print {
+ #c a {}
+ a {}
+}
+</pre>
+<h2>Compliant Solution</h2>
+<pre>
+a {}
+b a {}
+
+
+@media print {
+ a {}
+ #c a {}
+}
+</pre>
+
diff --git a/sonar-css-plugin/src/main/resources/org/sonar/l10n/css/rules/css/S4664.json b/sonar-css-plugin/src/main/resources/org/sonar/l10n/css/rules/css/S4664.json
new file mode 100644
index 0000000..ebcea71
--- /dev/null
+++ b/sonar-css-plugin/src/main/resources/org/sonar/l10n/css/rules/css/S4664.json
@@ -0,0 +1,16 @@
+{
+ "title": "Selectors of lower specificity should come before overriding selectors of higher specificity",
+ "type": "BUG",
+ "status": "ready",
+ "remediation": {
+ "func": "Constant\/Issue",
+ "constantCost": "5min"
+ },
+ "tags": [
+
+ ],
+ "defaultSeverity": "Critical",
+ "ruleSpecification": "RSPEC-4664",
+ "sqKey": "S4664",
+ "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 adbe829..ce1c647 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
@@ -20,6 +20,7 @@
"S4661",
"S4662",
"S4663",
+ "S4664",
"S4666",
"S4667",
"S4668",