@Test public void test_issues() { activeRules = (new ActiveRulesBuilder()) .create(RuleKey.of(CheckList.REPOSITORY_KEY, "PathMaskerading")) .activate() .build(); InputFile inputFile = inputFile("file1.yaml"); sensor().execute(context); String key = "moduleKey:file1.yaml"; assertThat(context.measure(key, CoreMetrics.NCLOC).value()).isEqualTo(29); assertThat(context.measure(key, OpenApiMetrics.PATHS_COUNT).value()).isEqualTo(2); assertThat(context.measure(key, OpenApiMetrics.OPERATIONS_COUNT).value()).isEqualTo(2); assertThat(context.measure(key, OpenApiMetrics.SCHEMAS_COUNT).value()).isEqualTo(2); assertThat(context.measure(key, CoreMetrics.COMPLEXITY).value()).isEqualTo(8); assertThat(context.measure(key, CoreMetrics.COMMENT_LINES).value()).isEqualTo(1); assertThat(context.allIssues()).hasSize(1); Issue issue = Iterables.get(context.allIssues(), 0); IssueLocation issueLocation = issue.primaryLocation(); assertThat(issueLocation.inputComponent()).isEqualTo(inputFile); if (issue.ruleKey().rule().equals("PathMaskerading")) { assertThat(issueLocation.message()).isEqualTo(PathMaskeradingCheck.MASK_MESSAGE); assertThat(issueLocation.textRange()).isEqualTo(inputFile.newRange(6, 2, 6, 15)); assertThat(issue.flows()).hasSize(1); assertThat(issue.gap()).isNull(); } assertThat(context.allAnalysisErrors()).isEmpty(); }
@Override public void execute(SensorContext context) { FilePredicates p = context.fileSystem().predicates(); OpenApiProperties openApiProperties = new OpenApiProperties(); scanFiles(context, p, openApiProperties.getV2FilesPattern(context), true); scanFiles(context, p, openApiProperties.getV3FilesPattern(context), false); }
OpenApiScannerSensor implements Sensor { @Override public void execute(SensorContext context) { FilePredicates p = context.fileSystem().predicates(); OpenApiProperties openApiProperties = new OpenApiProperties(); scanFiles(context, p, openApiProperties.getV2FilesPattern(context), true); scanFiles(context, p, openApiProperties.getV3FilesPattern(context), false); } }
OpenApiScannerSensor implements Sensor { @Override public void execute(SensorContext context) { FilePredicates p = context.fileSystem().predicates(); OpenApiProperties openApiProperties = new OpenApiProperties(); scanFiles(context, p, openApiProperties.getV2FilesPattern(context), true); scanFiles(context, p, openApiProperties.getV3FilesPattern(context), false); } OpenApiScannerSensor(CheckFactory checkFactory, FileLinesContextFactory fileLinesContextFactory, NoSonarFilter noSonarFilter);  OpenApiScannerSensor(CheckFactory checkFactory, FileLinesContextFactory fileLinesContextFactory, NoSonarFilter noSonarFilter, @Nullable OpenApiCustomRuleRepository[] customRuleRepositories); }
OpenApiScannerSensor implements Sensor { @Override public void execute(SensorContext context) { FilePredicates p = context.fileSystem().predicates(); OpenApiProperties openApiProperties = new OpenApiProperties(); scanFiles(context, p, openApiProperties.getV2FilesPattern(context), true); scanFiles(context, p, openApiProperties.getV3FilesPattern(context), false); } OpenApiScannerSensor(CheckFactory checkFactory, FileLinesContextFactory fileLinesContextFactory, NoSonarFilter noSonarFilter);  OpenApiScannerSensor(CheckFactory checkFactory, FileLinesContextFactory fileLinesContextFactory, NoSonarFilter noSonarFilter, @Nullable OpenApiCustomRuleRepository[] customRuleRepositories); @Override void describe(SensorDescriptor descriptor); @Override void execute(SensorContext context); void scanFiles(SensorContext context, FilePredicates p, String[] pathPatterns, boolean isV2); }
OpenApiScannerSensor implements Sensor { @Override public void execute(SensorContext context) { FilePredicates p = context.fileSystem().predicates(); OpenApiProperties openApiProperties = new OpenApiProperties(); scanFiles(context, p, openApiProperties.getV2FilesPattern(context), true); scanFiles(context, p, openApiProperties.getV3FilesPattern(context), false); } OpenApiScannerSensor(CheckFactory checkFactory, FileLinesContextFactory fileLinesContextFactory, NoSonarFilter noSonarFilter);  OpenApiScannerSensor(CheckFactory checkFactory, FileLinesContextFactory fileLinesContextFactory, NoSonarFilter noSonarFilter, @Nullable OpenApiCustomRuleRepository[] customRuleRepositories); @Override void describe(SensorDescriptor descriptor); @Override void execute(SensorContext context); void scanFiles(SensorContext context, FilePredicates p, String[] pathPatterns, boolean isV2);  }