@Test public void should_exclude_vendor_dir() { MapSettings settings = new MapSettings(); settings.setProperty(PhpPlugin.PHP_EXCLUSIONS_KEY, PhpPlugin.PHP_EXCLUSIONS_DEFAULT_VALUE); PhpExclusionsFileFilter filter = new PhpExclusionsFileFilter(settings.asConfig()); assertThat(filter.accept(inputFile("some_app.php"))).isTrue(); assertThat(filter.accept(inputFile("vendor/some_lib.php"))).isFalse(); assertThat(filter.accept(inputFile("vendor/my_lib_folder/my_lib.php"))).isFalse(); assertThat(filter.accept(inputFile("sub_module/vendor/submodule_lib.php"))).isFalse(); }
@Override public boolean accept(InputFile inputFile) { if (!Php.KEY.equals(inputFile.language())) { return true; } String relativePath = inputFile.uri().toString(); if (WildcardPattern.match(WildcardPattern.create(excludedPatterns), relativePath)) { LOG.debug("File [" + inputFile.uri() + "] is excluded by '" + PhpPlugin.PHP_EXCLUSIONS_KEY + "' property and will not be analyzed"); return false; } if (new AverageLineLengthCalculator(inputFile).getAverageLineLength() > DEFAULT_AVERAGE_LINE_LENGTH_THRESHOLD) { LOG.debug("File [" + inputFile.uri() + "] is excluded because it is considered generated (average line length is too big)."); return false; } return true; }
PhpExclusionsFileFilter implements InputFileFilter { @Override public boolean accept(InputFile inputFile) { if (!Php.KEY.equals(inputFile.language())) { return true; } String relativePath = inputFile.uri().toString(); if (WildcardPattern.match(WildcardPattern.create(excludedPatterns), relativePath)) { LOG.debug("File [" + inputFile.uri() + "] is excluded by '" + PhpPlugin.PHP_EXCLUSIONS_KEY + "' property and will not be analyzed"); return false; } if (new AverageLineLengthCalculator(inputFile).getAverageLineLength() > DEFAULT_AVERAGE_LINE_LENGTH_THRESHOLD) { LOG.debug("File [" + inputFile.uri() + "] is excluded because it is considered generated (average line length is too big)."); return false; } return true; } }
PhpExclusionsFileFilter implements InputFileFilter { @Override public boolean accept(InputFile inputFile) { if (!Php.KEY.equals(inputFile.language())) { return true; } String relativePath = inputFile.uri().toString(); if (WildcardPattern.match(WildcardPattern.create(excludedPatterns), relativePath)) { LOG.debug("File [" + inputFile.uri() + "] is excluded by '" + PhpPlugin.PHP_EXCLUSIONS_KEY + "' property and will not be analyzed"); return false; } if (new AverageLineLengthCalculator(inputFile).getAverageLineLength() > DEFAULT_AVERAGE_LINE_LENGTH_THRESHOLD) { LOG.debug("File [" + inputFile.uri() + "] is excluded because it is considered generated (average line length is too big)."); return false; } return true; } PhpExclusionsFileFilter(Configuration configuration); }
PhpExclusionsFileFilter implements InputFileFilter { @Override public boolean accept(InputFile inputFile) { if (!Php.KEY.equals(inputFile.language())) { return true; } String relativePath = inputFile.uri().toString(); if (WildcardPattern.match(WildcardPattern.create(excludedPatterns), relativePath)) { LOG.debug("File [" + inputFile.uri() + "] is excluded by '" + PhpPlugin.PHP_EXCLUSIONS_KEY + "' property and will not be analyzed"); return false; } if (new AverageLineLengthCalculator(inputFile).getAverageLineLength() > DEFAULT_AVERAGE_LINE_LENGTH_THRESHOLD) { LOG.debug("File [" + inputFile.uri() + "] is excluded because it is considered generated (average line length is too big)."); return false; } return true; } PhpExclusionsFileFilter(Configuration configuration); @Override boolean accept(InputFile inputFile); }
PhpExclusionsFileFilter implements InputFileFilter { @Override public boolean accept(InputFile inputFile) { if (!Php.KEY.equals(inputFile.language())) { return true; } String relativePath = inputFile.uri().toString(); if (WildcardPattern.match(WildcardPattern.create(excludedPatterns), relativePath)) { LOG.debug("File [" + inputFile.uri() + "] is excluded by '" + PhpPlugin.PHP_EXCLUSIONS_KEY + "' property and will not be analyzed"); return false; } if (new AverageLineLengthCalculator(inputFile).getAverageLineLength() > DEFAULT_AVERAGE_LINE_LENGTH_THRESHOLD) { LOG.debug("File [" + inputFile.uri() + "] is excluded because it is considered generated (average line length is too big)."); return false; } return true; } PhpExclusionsFileFilter(Configuration configuration); @Override boolean accept(InputFile inputFile);  }