Search in sources :

Example 6 with CFLintConfiguration

use of com.cflint.config.CFLintConfiguration in project CFLint by cflint.

the class TestArrayNewChecker method setUp.

@Before
public void setUp() throws Exception {
    final CFLintConfiguration conf = CFLintConfig.createDefaultLimited("ArrayNewChecker");
    cfBugs = new CFLint(conf);
}
Also used : CFLintConfiguration(com.cflint.config.CFLintConfiguration) Before(org.junit.Before)

Example 7 with CFLintConfiguration

use of com.cflint.config.CFLintConfiguration in project CFLint by cflint.

the class CFLint method scan.

public void scan(final File folderOrFile) {
    if (getBugs().getFileFilter() != null && !getBugs().getFileFilter().includeFile(folderOrFile)) {
        return;
    }
    if (folderOrFile.isDirectory()) {
        final CFLintConfiguration saveConfig = configuration;
        try {
            for (final File file : folderOrFile.listFiles()) {
                if (file.getName().toLowerCase().startsWith(".cflintrc")) {
                    try {
                        System.out.println("read config " + file);
                        CFLintConfiguration newConfig = file.getName().toLowerCase().endsWith(".xml") ? ConfigUtils.unmarshal(new FileInputStream(file), CFLintConfig.class) : ConfigUtils.unmarshalJson(new FileInputStream(file), CFLintConfig.class);
                        configuration = new CFLintChainedConfig(newConfig, configuration);
                    } catch (Exception e) {
                        System.err.println("Could not read config file " + file);
                    }
                }
            }
            for (final File file : folderOrFile.listFiles()) {
                scan(file);
            }
        } finally {
            configuration = saveConfig;
        }
    } else if (!folderOrFile.isHidden() && FileUtil.checkExtension(folderOrFile, allowedExtensions)) {
        final String src = FileUtil.loadFile(folderOrFile);
        try {
            process(src, folderOrFile.getAbsolutePath());
        } catch (final Exception e) {
            printException(e);
            if (logError) {
                System.out.println("Logging Error: " + FILE_ERROR);
                fireCFLintException(e, FILE_ERROR, folderOrFile.getAbsolutePath(), null, null, null, null);
            }
        }
    }
}
Also used : CFLintConfiguration(com.cflint.config.CFLintConfiguration) CFLintConfig(com.cflint.config.CFLintConfig) File(java.io.File) FileInputStream(java.io.FileInputStream) RecognitionException(org.antlr.runtime.RecognitionException) ParseException(cfml.parsing.reporting.ParseException) IOException(java.io.IOException) CFLintChainedConfig(com.cflint.config.CFLintChainedConfig)

Aggregations

CFLintConfiguration (com.cflint.config.CFLintConfiguration)7 Before (org.junit.Before)4 File (java.io.File)3 CFLint (com.cflint.CFLint)2 CFLintConfig (com.cflint.config.CFLintConfig)2 FileInputStream (java.io.FileInputStream)2 IOException (java.io.IOException)2 ParseException (cfml.parsing.reporting.ParseException)1 HTMLOutput (com.cflint.HTMLOutput)1 JSONOutput (com.cflint.JSONOutput)1 TextOutput (com.cflint.TextOutput)1 XMLOutput (com.cflint.XMLOutput)1 CFLintChainedConfig (com.cflint.config.CFLintChainedConfig)1 PluginMessage (com.cflint.config.CFLintPluginInfo.PluginInfoRule.PluginMessage)1 CFLintExceptionListener (com.cflint.plugins.exceptions.CFLintExceptionListener)1 CFLintFilter (com.cflint.tools.CFLintFilter)1 DefaultCFlintResultMarshaller (com.cflint.xml.stax.DefaultCFlintResultMarshaller)1 FileWriter (java.io.FileWriter)1 OutputStreamWriter (java.io.OutputStreamWriter)1 StringWriter (java.io.StringWriter)1