diff options
| author | Elena Vilchik | 2019-06-14 10:01:23 +0200 |
|---|---|---|
| committer | Tibor Blenessy | 2019-06-14 10:01:23 +0200 |
| commit | eb017c3b5e0b4652210fb7bcd0a68fe0c36b29cf (patch) | |
| tree | 48fc01eeddd1ac38351e57d3ea7d7a4dcd2d1ef1 /its/plugin | |
| parent | 479b21eb67bd2f5f7170cb4e14b19561ed59ddcf (diff) | |
| download | sonar-css-eb017c3b5e0b4652210fb7bcd0a68fe0c36b29cf.tar.bz2 | |
Analyse CSS inside other language files (html, vue) (#183)
Diffstat (limited to 'its/plugin')
6 files changed, 50 insertions, 3 deletions
diff --git a/its/plugin/projects/issues-project/src/file5-1.html b/its/plugin/projects/issues-project/src/file5-1.html new file mode 100644 index 0000000..908013f --- /dev/null +++ b/its/plugin/projects/issues-project/src/file5-1.html @@ -0,0 +1,14 @@ +<!DOCTYPE html> +<!-- this file is not analyzed as HTML suffixes are changed to "htm" --> +<html> +<head> + <title>Page Title</title> + <style> +b a { + color: pink;; /* S1116 | no-extra-semicolons */ +} + </style> +</head> +<body> +</body> +</html> diff --git a/its/plugin/projects/issues-project/src/file5.htm b/its/plugin/projects/issues-project/src/file5.htm new file mode 100644 index 0000000..8cb86d7 --- /dev/null +++ b/its/plugin/projects/issues-project/src/file5.htm @@ -0,0 +1,13 @@ +<!DOCTYPE html> +<html> +<head> + <title>Page Title</title> + <style> +b a { + color: pink;; /* S1116 | no-extra-semicolons */ +} + </style> +</head> +<body> +</body> +</html> diff --git a/its/plugin/projects/issues-project/src/file6.vue b/its/plugin/projects/issues-project/src/file6.vue new file mode 100644 index 0000000..ba35736 --- /dev/null +++ b/its/plugin/projects/issues-project/src/file6.vue @@ -0,0 +1,12 @@ +<!-- my-component.vue --> +<template> + <div>hello</div> +</template> +<script> +let x = 42; // to verify highlighting by SonarJS +</script> +<style> +b a { + color: pink;; /* S1116 | no-extra-semicolons */ +} +</style> diff --git a/its/plugin/src/test/java/org/sonar/css/its/IssuesTest.java b/its/plugin/src/test/java/org/sonar/css/its/IssuesTest.java index ce57e15..c65df09 100644 --- a/its/plugin/src/test/java/org/sonar/css/its/IssuesTest.java +++ b/its/plugin/src/test/java/org/sonar/css/its/IssuesTest.java @@ -20,6 +20,7 @@ package org.sonar.css.its; import com.sonar.orchestrator.Orchestrator; +import com.sonar.orchestrator.build.SonarScanner; import com.sonar.orchestrator.locator.FileLocation; import java.io.File; import java.util.Collections; @@ -50,7 +51,9 @@ public class IssuesTest { orchestrator.getServer().provisionProject(PROJECT_KEY, PROJECT_KEY); orchestrator.getServer().associateProjectToQualityProfile(PROJECT_KEY, "css", "rules"); - orchestrator.executeBuild(Tests.createScanner(PROJECT_KEY)); + SonarScanner scanner = Tests.createScanner(PROJECT_KEY); + scanner.setProperty("sonar.html.file.suffixes", ".htm"); + orchestrator.executeBuild(scanner); } @Test @@ -61,6 +64,7 @@ public class IssuesTest { assertThat(issuesList).extracting("rule").hasSize( CssRules.getRuleClasses().size() * 3 /* issues are raised against .css, .less and .scss */ + + 2 /* for html and vue files */ + 1 /* issue S4654 is raised for comment */ + 1 /* issue S4662 is raised for cssModules.css */ + 6 /* S5362 raises at the same place as S4650 */ diff --git a/its/plugin/src/test/java/org/sonar/css/its/MetricsTest.java b/its/plugin/src/test/java/org/sonar/css/its/MetricsTest.java index 275da9d..af4a153 100644 --- a/its/plugin/src/test/java/org/sonar/css/its/MetricsTest.java +++ b/its/plugin/src/test/java/org/sonar/css/its/MetricsTest.java @@ -42,8 +42,8 @@ public class MetricsTest { @Test public void test() { - assertThat(getProjectMeasureAsDouble("lines", PROJECT_KEY)).isEqualTo(32); - assertThat(getProjectMeasureAsDouble("ncloc", PROJECT_KEY)).isEqualTo(22); + assertThat(getProjectMeasureAsDouble("lines", PROJECT_KEY)).isEqualTo(43); + assertThat(getProjectMeasureAsDouble("ncloc", PROJECT_KEY)).isEqualTo(32); assertThat(getProjectMeasureAsDouble("comment_lines", PROJECT_KEY)).isEqualTo(4); assertThat(getMeasure("ncloc_data", PROJECT_KEY + ":src/file1.css").getValue()) diff --git a/its/plugin/src/test/java/org/sonar/css/its/Tests.java b/its/plugin/src/test/java/org/sonar/css/its/Tests.java index 5098022..e07dd76 100644 --- a/its/plugin/src/test/java/org/sonar/css/its/Tests.java +++ b/its/plugin/src/test/java/org/sonar/css/its/Tests.java @@ -23,6 +23,7 @@ import com.sonar.orchestrator.Orchestrator; import com.sonar.orchestrator.OrchestratorBuilder; import com.sonar.orchestrator.build.SonarScanner; import com.sonar.orchestrator.locator.FileLocation; +import com.sonar.orchestrator.locator.MavenLocation; import java.io.File; import java.util.Collections; import java.util.List; @@ -48,12 +49,15 @@ public class Tests { private static final FileLocation PLUGIN_LOCATION = FileLocation.byWildcardMavenFilename( new File("../../sonar-css-plugin/target"), "sonar-css-plugin-*.jar"); + @ClassRule public static final Orchestrator ORCHESTRATOR; static { OrchestratorBuilder orchestratorBuilder = Orchestrator.builderEnv() .addPlugin(PLUGIN_LOCATION) + .addPlugin(MavenLocation.of("org.sonarsource.html", "sonar-html-plugin", "DEV")) + .addPlugin(MavenLocation.of("org.sonarsource.javascript", "sonar-javascript-plugin", "DEV")) .setSonarVersion(System.getProperty("sonar.runtimeVersion", "LATEST_RELEASE")); ORCHESTRATOR = orchestratorBuilder.build(); } |
