@Test public void should_run_custom_rule() throws Exception { inputFile("file.js"); ActiveRules activeRules = (new ActiveRulesBuilder()) .addRule(new NewActiveRule.Builder().setRuleKey(RuleKey.of("customKey", "key")).build()) .build(); checkFactory = new CheckFactory(activeRules); createSensorWithCustomRules().execute(context); Collection<Issue> issues = context.allIssues(); assertThat(issues).hasSize(1); Map<Integer, Issue> issueByLine = issues.stream().collect(Collectors.toMap(issue -> issue.primaryLocation().textRange().start().line(), i -> i)); assertThat(issueByLine.keySet()).containsExactlyInAnyOrder(1); Issue issue = issueByLine.get(1); assertThat(issue.gap()).isEqualTo(42); assertThat(issue.primaryLocation().message()).isEqualTo("Message of custom rule"); assertThat(issue.primaryLocation().textRange()).isEqualTo(new DefaultTextRange(new DefaultTextPointer(1, 0), new DefaultTextPointer(1, 7))); }
public void execute(SensorContext context) { checkDeprecatedEslintProperty(context); List<TreeVisitor> treeVisitors = new ArrayList<>(); treeVisitors.add(new SeChecksDispatcher(checks.seChecks())); treeVisitors.addAll(checks.visitorChecks()); Iterable<InputFile> inputFiles = getInputFiles(context); Collection<String> files = StreamSupport.stream(inputFiles.spliterator(), false) .map(InputFile::toString) .collect(Collectors.toList()); ProgressReport progressReport = new ProgressReport("Report about progress of Javascript analyzer", TimeUnit.SECONDS.toMillis(10)); progressReport.start(files); analyseFiles(context, treeVisitors, inputFiles, progressReport); }
JavaScriptSensor { public void execute(SensorContext context) { checkDeprecatedEslintProperty(context); List<TreeVisitor> treeVisitors = new ArrayList<>(); treeVisitors.add(new SeChecksDispatcher(checks.seChecks())); treeVisitors.addAll(checks.visitorChecks()); Iterable<InputFile> inputFiles = getInputFiles(context); Collection<String> files = StreamSupport.stream(inputFiles.spliterator(), false) .map(InputFile::toString) .collect(Collectors.toList()); ProgressReport progressReport = new ProgressReport("Report about progress of Javascript analyzer", TimeUnit.SECONDS.toMillis(10)); progressReport.start(files); analyseFiles(context, treeVisitors, inputFiles, progressReport); } }
JavaScriptSensor { public void execute(SensorContext context) { checkDeprecatedEslintProperty(context); List<TreeVisitor> treeVisitors = new ArrayList<>(); treeVisitors.add(new SeChecksDispatcher(checks.seChecks())); treeVisitors.addAll(checks.visitorChecks()); Iterable<InputFile> inputFiles = getInputFiles(context); Collection<String> files = StreamSupport.stream(inputFiles.spliterator(), false) .map(InputFile::toString) .collect(Collectors.toList()); ProgressReport progressReport = new ProgressReport("Report about progress of Javascript analyzer", TimeUnit.SECONDS.toMillis(10)); progressReport.start(files); analyseFiles(context, treeVisitors, inputFiles, progressReport); } JavaScriptSensor(AbstractChecks checks); }
JavaScriptSensor { public void execute(SensorContext context) { checkDeprecatedEslintProperty(context); List<TreeVisitor> treeVisitors = new ArrayList<>(); treeVisitors.add(new SeChecksDispatcher(checks.seChecks())); treeVisitors.addAll(checks.visitorChecks()); Iterable<InputFile> inputFiles = getInputFiles(context); Collection<String> files = StreamSupport.stream(inputFiles.spliterator(), false) .map(InputFile::toString) .collect(Collectors.toList()); ProgressReport progressReport = new ProgressReport("Report about progress of Javascript analyzer", TimeUnit.SECONDS.toMillis(10)); progressReport.start(files); analyseFiles(context, treeVisitors, inputFiles, progressReport); } JavaScriptSensor(AbstractChecks checks); void execute(SensorContext context); }
JavaScriptSensor { public void execute(SensorContext context) { checkDeprecatedEslintProperty(context); List<TreeVisitor> treeVisitors = new ArrayList<>(); treeVisitors.add(new SeChecksDispatcher(checks.seChecks())); treeVisitors.addAll(checks.visitorChecks()); Iterable<InputFile> inputFiles = getInputFiles(context); Collection<String> files = StreamSupport.stream(inputFiles.spliterator(), false) .map(InputFile::toString) .collect(Collectors.toList()); ProgressReport progressReport = new ProgressReport("Report about progress of Javascript analyzer", TimeUnit.SECONDS.toMillis(10)); progressReport.start(files); analyseFiles(context, treeVisitors, inputFiles, progressReport); } JavaScriptSensor(AbstractChecks checks); void execute(SensorContext context);  }