diff options
| author | Elena Vilchik | 2019-12-27 15:34:39 +0100 |
|---|---|---|
| committer | GitHub | 2019-12-27 15:34:39 +0100 |
| commit | 2bbe2243f0a393dd3c9884dca5560f583a843f88 (patch) | |
| tree | d32c3c13efa2d4fc2540ff33a16982a020156fc2 /sonar-css-plugin/src/main/java/org | |
| parent | 0c7fadc03cca985bfc5fbae3a29f29cc71866bac (diff) | |
| download | sonar-css-2bbe2243f0a393dd3c9884dca5560f583a843f88.tar.bz2 | |
Analyze CSS in Vue Single File Components (#232)
Diffstat (limited to 'sonar-css-plugin/src/main/java/org')
| -rw-r--r-- | sonar-css-plugin/src/main/java/org/sonar/css/plugin/CssRuleSensor.java | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/sonar-css-plugin/src/main/java/org/sonar/css/plugin/CssRuleSensor.java b/sonar-css-plugin/src/main/java/org/sonar/css/plugin/CssRuleSensor.java index db961df..326c94f 100644 --- a/sonar-css-plugin/src/main/java/org/sonar/css/plugin/CssRuleSensor.java +++ b/sonar-css-plugin/src/main/java/org/sonar/css/plugin/CssRuleSensor.java @@ -88,7 +88,7 @@ public class CssRuleSensor implements Sensor { List<InputFile> inputFiles = getInputFiles(context); if (inputFiles.isEmpty()) { - LOG.info("No CSS, PHP or HTML files are found in the project. CSS analysis is skipped."); + LOG.info("No CSS, PHP, HTML or VueJS files are found in the project. CSS analysis is skipped."); return; } @@ -142,8 +142,8 @@ public class CssRuleSensor implements Sensor { LOG.info(e.toString()); } catch (Exception e) { - // we can end up here in the following cases: file analysis request sending, or response parsing, server is not answering - // or some unpredicted state + // we can end up here in the following cases: fail to send file analysis request, fail to parse the response, server is not answering + // or some other unpredicted state String msg = "Failure during CSS analysis, " + cssAnalyzerBridgeServer.getCommandInfo(); logErrorOrWarn(context, msg, e); throwFailFast(context, e); @@ -245,10 +245,18 @@ public class CssRuleSensor implements Sensor { private static List<InputFile> getInputFiles(SensorContext context) { FileSystem fileSystem = context.fileSystem(); + FilePredicate mainFilePredicate = fileSystem.predicates().and( fileSystem.predicates().hasType(InputFile.Type.MAIN), fileSystem.predicates().hasLanguages(CssLanguage.KEY, "php", "web")); - return StreamSupport.stream(fileSystem.inputFiles(mainFilePredicate).spliterator(), false) + + FilePredicate vueFilePredicate = fileSystem.predicates().and( + fileSystem.predicates().hasType(InputFile.Type.MAIN), + fileSystem.predicates().hasExtension("vue"), + // by default 'vue' extension is defined for JS language, but 'vue' files can contain TS code and thus language can be changed + fileSystem.predicates().hasLanguages("js", "ts")); + + return StreamSupport.stream(fileSystem.inputFiles(fileSystem.predicates().or(mainFilePredicate, vueFilePredicate)).spliterator(), false) .collect(Collectors.toList()); } |
