Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP Rewrite selection code #870

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -164,14 +164,14 @@ private Default() {
"**/LICENSE_HEADER",

// binary files - images
"**/*.jpg",
"**/*.png",
"**/*.bmp",
"**/*.cr2",
"**/*.gif",
"**/*.ico",
"**/*.bmp",
"**/*.jpg",
"**/*.png",
"**/*.tiff",
"**/*.tif",
"**/*.cr2",
"**/*.xcf",

// binary files - programs
Expand All @@ -197,18 +197,17 @@ private Default() {
"**/*.pub",

// binary files - archives
"**/*.7z",
"**/*.ear",
"**/*.gz",
"**/*.jar",
"**/*.war",
"**/*.zip",
"**/*.rar",
"**/*.tar",
"**/*.tar.gz",
"**/*.tar.bz2",
"**/*.tar.bz3",
"**/*.tar.xz",
"**/*.gz",
"**/*.7z",
"**/*.war",
"**/*.zip",

// ServiceLoader files
"**/META-INF/services/**",
Expand All @@ -217,11 +216,11 @@ private Default() {
"**/*.md",

// Office documents
"**/*.xls",
"**/*.doc",
"**/*.odt",
"**/*.ods",
"**/*.pdf",
"**/*.xls",

// Travis
"**/.travis.yml",
Expand Down Expand Up @@ -250,16 +249,19 @@ private Default() {
"**/maven-wrapper.properties",
"**/MavenWrapperDownloader.java",

// Profiler
"**/.profiler/**"

// flash
"**/*.swf",

// json files
"**/*.json",

// fonts
"**/*.svg",
"**/*.eot",
"**/*.otf",
"**/*.svg",
"**/*.ttf",
"**/*.woff",
"**/*.woff2",
Expand All @@ -268,10 +270,10 @@ private Default() {
"**/*.log",

// office documents
"**/*.xlsx",
"**/*.docx",
"**/*.ppt",
"**/*.pptx",
"**/*.xlsx",

// String Template
"**/*.st",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,19 +100,25 @@ public ScanAction visitFile(final String name, final File file) {
}
}

private String[] findFolderExcludes() { // less we keep, less overhead we get so we only use user excludes there
final List<String> excludes = new ArrayList<>(excluded.length / 2 /*estimate*/);
for (final String exclude : (userExcluded != null ? userExcluded : excluded)) {
private String[] findFolderExcludes() {
/* Estimate size of folder exclusions at half of the exclusion list. */
final List<String> excludes = new ArrayList<>(excluded.length / 2);
// Search all exclusions which includes user exclusions
for (final String exclude : excluded) {
if (isFolderExclusion(exclude)) {
excludes.add(exclude);
// Replace file separator here
excludes.add(exclude.replace("/", File.separator));
}
}
Collections.reverse(excludes); // assume user ones are more important than the set of defaults we appended

// assume user ones are more important than the set of defaults we appended
Collections.reverse(excludes);
return excludes.toArray(new String[0]);
}

private boolean isFolderExclusion(final String exclude) {
return exclude.endsWith(File.separator + "**");
// Exclude is hard-coded values
return exclude.endsWith("/**");
}

private static String[] buildExclusions(boolean useDefaultExcludes, String[] excludes, String[] overrides) {
Expand Down
Loading