From fb06e0a88b47fe8505b87dbbf88aad47e9b300e2 Mon Sep 17 00:00:00 2001 From: Amaury Levé Date: Thu, 21 Jun 2018 17:11:48 +0200 Subject: Rule S4652: Strings should not contain new lines (#57) --- .../org/sonar/l10n/css/rules/css/S4652.html | 26 ++++++++++++++++++++++ .../org/sonar/l10n/css/rules/css/S4652.json | 16 +++++++++++++ .../l10n/css/rules/css/Sonar_way_profile.json | 3 ++- 3 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 sonar-css-plugin/src/main/resources/org/sonar/l10n/css/rules/css/S4652.html create mode 100644 sonar-css-plugin/src/main/resources/org/sonar/l10n/css/rules/css/S4652.json (limited to 'sonar-css-plugin/src/main/resources') diff --git a/sonar-css-plugin/src/main/resources/org/sonar/l10n/css/rules/css/S4652.html b/sonar-css-plugin/src/main/resources/org/sonar/l10n/css/rules/css/S4652.html new file mode 100644 index 0000000..ae6f801 --- /dev/null +++ b/sonar-css-plugin/src/main/resources/org/sonar/l10n/css/rules/css/S4652.html @@ -0,0 +1,26 @@ +

According to the W3C specifications:

+
+

A string cannot directly contain a newline. To include a newline in a string, use an escape representing the line feed character in ISO-10646 + (U+000A), such as "\A" or "\00000a".

+

[...]

+

It is possible to break strings over several lines, for aesthetic or other reasons, but in such a case the newline itself has to be escaped with + a backslash (\).

+
+

Noncompliant Code Example

+
+a {
+  content: "first
+    second";
+}
+
+

Compliant Solution

+
+a {
+  content: "first\Asecond";
+}
+
+

See

+ + diff --git a/sonar-css-plugin/src/main/resources/org/sonar/l10n/css/rules/css/S4652.json b/sonar-css-plugin/src/main/resources/org/sonar/l10n/css/rules/css/S4652.json new file mode 100644 index 0000000..06dcd4d --- /dev/null +++ b/sonar-css-plugin/src/main/resources/org/sonar/l10n/css/rules/css/S4652.json @@ -0,0 +1,16 @@ +{ + "title": "Strings should not contain new lines", + "type": "CODE_SMELL", + "status": "ready", + "remediation": { + "func": "Constant\/Issue", + "constantCost": "1min" + }, + "tags": [ + + ], + "defaultSeverity": "Major", + "ruleSpecification": "RSPEC-4652", + "sqKey": "S4652", + "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 f7ce787..68da351 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 @@ -2,7 +2,8 @@ "name": "Sonar way", "ruleKeys": [ "S4647", + "S4652", "S4653", "S4663" ] -} +} -- cgit v1.2.3