diff options
| author | Elena Vilchik | 2019-06-13 18:09:27 +0200 |
|---|---|---|
| committer | Tibor Blenessy | 2019-06-13 18:09:27 +0200 |
| commit | 479b21eb67bd2f5f7170cb4e14b19561ed59ddcf (patch) | |
| tree | 1e5d4c8de4d87d6add3f324f51bd21e153aeaa1e /sonar-css-plugin/src/main/resources | |
| parent | 6581b69a11c27d11ba5e1f4c37546485dc12b1d4 (diff) | |
| download | sonar-css-479b21eb67bd2f5f7170cb4e14b19561ed59ddcf.tar.bz2 | |
Add rule S5362: Expressions within "calc" should be valid (#180)
Removes S4650 from the default profile, because of overlap.
Diffstat (limited to 'sonar-css-plugin/src/main/resources')
3 files changed, 42 insertions, 2 deletions
diff --git a/sonar-css-plugin/src/main/resources/org/sonar/l10n/css/rules/css/S5362.html b/sonar-css-plugin/src/main/resources/org/sonar/l10n/css/rules/css/S5362.html new file mode 100644 index 0000000..66fa5cd --- /dev/null +++ b/sonar-css-plugin/src/main/resources/org/sonar/l10n/css/rules/css/S5362.html @@ -0,0 +1,24 @@ +<p>To perform calculations when specifying a CSS property <code>calc()</code> function can be used. This function takes single expression as +parameter. When writing this expression some rules must be respected:</p> +<ul> + <li> no empty <code>calc()</code> </li> + <li> there should be an operator between the arguments, spacing should be respected </li> + <li> there should not be any division by zero </li> + <li> the resolved type should be valid for where the expression is placed </li> +</ul> +<p>Otherwise <code>calc()</code> function will be invalid and the entire rule using it will be ignored.</p> +<h2>Noncompliant Code Example</h2> +<pre> +.btn { + border: solid black 1px; + width: calc(100% 80px); /* Noncompliant */ +} +</pre> +<h2>Compliant Solution</h2> +<pre> +.btn { + border: solid black 1px; + width: calc(100% - 80px); +} +</pre> + diff --git a/sonar-css-plugin/src/main/resources/org/sonar/l10n/css/rules/css/S5362.json b/sonar-css-plugin/src/main/resources/org/sonar/l10n/css/rules/css/S5362.json new file mode 100644 index 0000000..bde6f63 --- /dev/null +++ b/sonar-css-plugin/src/main/resources/org/sonar/l10n/css/rules/css/S5362.json @@ -0,0 +1,16 @@ +{ + "title": "Expressions within \"calc\" should be valid", + "type": "BUG", + "status": "ready", + "remediation": { + "func": "Constant\/Issue", + "constantCost": "5min" + }, + "tags": [ + + ], + "defaultSeverity": "Critical", + "ruleSpecification": "RSPEC-5362", + "sqKey": "S5362", + "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 9b98de0..7834cba 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 @@ -6,7 +6,6 @@ "S4647", "S4648", "S4649", - "S4650", "S4651", "S4652", "S4653", @@ -23,6 +22,7 @@ "S4666", "S4667", "S4668", - "S4670" + "S4670", + "S5362" ] } |
