@Test public void should_exclude_using_custom_path_regex() throws Exception { MapSettings settings = new MapSettings(); settings.setProperty( JavaScriptPlugin.JS_EXCLUSIONS_KEY, EXCLUSIONS_DEFAULT_VALUE + "," + "**/libs/**"); JavaScriptExclusionsFileFilter filter = new JavaScriptExclusionsFileFilter(settings.asConfig()); assertThat(filter.accept(inputFile("some_app.js"))).isTrue(); assertThat(filter.accept(inputFile("node_modules/some_lib.js"))).isFalse(); assertThat(filter.accept(inputFile("libs/some_lib.js"))).isFalse(); }
@Override public boolean accept(InputFile inputFile) { boolean isJsTs = JavaScriptLanguage.KEY.equals(inputFile.language()) || TypeScriptLanguage.KEY.equals(inputFile.language()); if (isJsTs && SizeAssessor.hasExcessiveSize(inputFile, maxFileSizeKb * 1000)) { LOG.debug("File {} was excluded because of excessive size", inputFile); return false; } String relativePath = inputFile.uri().toString(); if (WildcardPattern.match(excludedPatterns, relativePath)) { LOG.debug("File {} was excluded by {} or {}", inputFile, JavaScriptPlugin.JS_EXCLUSIONS_KEY, JavaScriptPlugin.TS_EXCLUSIONS_KEY); return false; } boolean isMinified = new MinificationAssessor().isMinified(inputFile); if (isMinified) { LOG.debug("File [" + inputFile.uri() + "] looks like a minified file and will not be analyzed"); return false; } return true; }
JavaScriptExclusionsFileFilter implements InputFileFilter { @Override public boolean accept(InputFile inputFile) { boolean isJsTs = JavaScriptLanguage.KEY.equals(inputFile.language()) || TypeScriptLanguage.KEY.equals(inputFile.language()); if (isJsTs && SizeAssessor.hasExcessiveSize(inputFile, maxFileSizeKb * 1000)) { LOG.debug("File {} was excluded because of excessive size", inputFile); return false; } String relativePath = inputFile.uri().toString(); if (WildcardPattern.match(excludedPatterns, relativePath)) { LOG.debug("File {} was excluded by {} or {}", inputFile, JavaScriptPlugin.JS_EXCLUSIONS_KEY, JavaScriptPlugin.TS_EXCLUSIONS_KEY); return false; } boolean isMinified = new MinificationAssessor().isMinified(inputFile); if (isMinified) { LOG.debug("File [" + inputFile.uri() + "] looks like a minified file and will not be analyzed"); return false; } return true; } }
JavaScriptExclusionsFileFilter implements InputFileFilter { @Override public boolean accept(InputFile inputFile) { boolean isJsTs = JavaScriptLanguage.KEY.equals(inputFile.language()) || TypeScriptLanguage.KEY.equals(inputFile.language()); if (isJsTs && SizeAssessor.hasExcessiveSize(inputFile, maxFileSizeKb * 1000)) { LOG.debug("File {} was excluded because of excessive size", inputFile); return false; } String relativePath = inputFile.uri().toString(); if (WildcardPattern.match(excludedPatterns, relativePath)) { LOG.debug("File {} was excluded by {} or {}", inputFile, JavaScriptPlugin.JS_EXCLUSIONS_KEY, JavaScriptPlugin.TS_EXCLUSIONS_KEY); return false; } boolean isMinified = new MinificationAssessor().isMinified(inputFile); if (isMinified) { LOG.debug("File [" + inputFile.uri() + "] looks like a minified file and will not be analyzed"); return false; } return true; } JavaScriptExclusionsFileFilter(Configuration configuration); }
JavaScriptExclusionsFileFilter implements InputFileFilter { @Override public boolean accept(InputFile inputFile) { boolean isJsTs = JavaScriptLanguage.KEY.equals(inputFile.language()) || TypeScriptLanguage.KEY.equals(inputFile.language()); if (isJsTs && SizeAssessor.hasExcessiveSize(inputFile, maxFileSizeKb * 1000)) { LOG.debug("File {} was excluded because of excessive size", inputFile); return false; } String relativePath = inputFile.uri().toString(); if (WildcardPattern.match(excludedPatterns, relativePath)) { LOG.debug("File {} was excluded by {} or {}", inputFile, JavaScriptPlugin.JS_EXCLUSIONS_KEY, JavaScriptPlugin.TS_EXCLUSIONS_KEY); return false; } boolean isMinified = new MinificationAssessor().isMinified(inputFile); if (isMinified) { LOG.debug("File [" + inputFile.uri() + "] looks like a minified file and will not be analyzed"); return false; } return true; } JavaScriptExclusionsFileFilter(Configuration configuration); @Override boolean accept(InputFile inputFile); }
JavaScriptExclusionsFileFilter implements InputFileFilter { @Override public boolean accept(InputFile inputFile) { boolean isJsTs = JavaScriptLanguage.KEY.equals(inputFile.language()) || TypeScriptLanguage.KEY.equals(inputFile.language()); if (isJsTs && SizeAssessor.hasExcessiveSize(inputFile, maxFileSizeKb * 1000)) { LOG.debug("File {} was excluded because of excessive size", inputFile); return false; } String relativePath = inputFile.uri().toString(); if (WildcardPattern.match(excludedPatterns, relativePath)) { LOG.debug("File {} was excluded by {} or {}", inputFile, JavaScriptPlugin.JS_EXCLUSIONS_KEY, JavaScriptPlugin.TS_EXCLUSIONS_KEY); return false; } boolean isMinified = new MinificationAssessor().isMinified(inputFile); if (isMinified) { LOG.debug("File [" + inputFile.uri() + "] looks like a minified file and will not be analyzed"); return false; } return true; } JavaScriptExclusionsFileFilter(Configuration configuration); @Override boolean accept(InputFile inputFile);  }