Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
ryaneberly committed Jul 22, 2017
1 parent 925acb4 commit 28730bd
Showing 1 changed file with 35 additions and 1 deletion.
36 changes: 35 additions & 1 deletion src/main/java/com/cflint/CFLint.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Map.Entry;
Expand Down Expand Up @@ -170,9 +171,42 @@ public void scan(final String folderName) {
if (showProgress) {
ScanningProgressMonitorLookAhead.createInstance(this, folderName, progressUsesThread).startPreScan();
}
scan(new File(folderName));
final File starterFile = new File(folderName);
setupConfigAncestry(starterFile.getParentFile());
scan(starterFile);
fireClose();
}

private void setupConfigAncestry(File folder){
Stack<CFLintConfig> configFiles = new Stack<CFLintConfig>();
fileLoop:
while(folder != null && folder.exists()){
for (final File file : folder.listFiles()) {
if (file.getName().toLowerCase().startsWith(".cflintrc")) {
if (verbose) {
System.out.println("read config " + file);
}
System.out.println(
"DEPRECATED: The use of \"inheritPlugins\" has been marked as deprecated in CFLint 1.2.x and support for it will be fully removed in CFLint 1.3.0. Please remove the setting from your configuration file(s). Run CFLint in verbose mode for config file location details.");
try {
CFLintConfig newConfig = file.getName().toLowerCase().endsWith(".xml")
? ConfigUtils.unmarshal(new FileInputStream(file), CFLintConfig.class)
: ConfigUtils.unmarshalJson(new FileInputStream(file), CFLintConfig.class);
configFiles.push(newConfig);
if (!newConfig.isInheritParent()) {
break fileLoop;
}
} catch (Exception e) {
System.err.println("Could not read config file " + file);
}
}
}
folder = folder.getParentFile();
}
for(CFLintConfig newConfig: configFiles){
configuration = new CFLintChainedConfig(newConfig,configuration);
}
}

public void scan(final File folderOrFile) {
if (getBugs().getFileFilter() != null && !getBugs().getFileFilter().includeFile(folderOrFile)) {
Expand Down

0 comments on commit 28730bd

Please sign in to comment.