use of com.cflint.api.CFLintAPI in project CFLint by cflint.
the class TestCFBugs_ArgsUse method setUp.
@Before
public void setUp() throws Exception {
final ConfigBuilder configBuilder = new ConfigBuilder().include("ARG_VAR_CONFLICT", "ARG_VAR_MIXED");
cfBugs = new CFLintAPI(configBuilder.build());
}
use of com.cflint.api.CFLintAPI in project CFLint by cflint.
the class TestCFBugs_ComponentHint method setUp.
@Before
public void setUp() throws Exception {
final ConfigBuilder configBuilder = new ConfigBuilder().include("COMPONENT_HINT_MISSING");
cfBugs = new CFLintAPI(configBuilder.build());
}
use of com.cflint.api.CFLintAPI in project CFLint by cflint.
the class TestCFBugs_ComponentName method setUp.
@Before
public void setUp() throws Exception {
final ConfigBuilder configBuilder = new ConfigBuilder().include("USE_DISPLAY_NAME");
cfBugs = new CFLintAPI(configBuilder.build());
}
use of com.cflint.api.CFLintAPI in project CFLint by cflint.
the class TestCFBugs_FunctionHint method setUp.
@Before
public void setUp() throws Exception {
final ConfigBuilder configBuilder = new ConfigBuilder().include("FUNCTION_HINT_MISSING");
cfBugs = new CFLintAPI(configBuilder.build());
}
use of com.cflint.api.CFLintAPI in project CFLint by cflint.
the class CFLintCLI method execute.
private void execute(final CFLintConfiguration cfLintConfig) throws IOException, TransformerException, MarshallerException, JAXBException, CFLintScanException, CFLintConfigurationException {
final CFLintAPI api = new CFLintAPI(cfLintConfig);
api.setVerbose(verbose);
api.setLogError(logerror);
api.setQuiet(quiet);
api.setStrictInclude(strictInclude);
if (extensions != null && extensions.trim().length() > 0) {
try {
api.setExtensions(Arrays.asList(extensions.trim().split(",")));
} catch (final Exception e) {
System.err.println("Unable to use extensions (" + extensions + ") using default instead. " + e.getMessage());
}
}
api.setFilterFile(filterFile);
CFLintResult lintResult = null;
if (stdIn) {
final StringWriter source = new StringWriter();
IOUtils.copy(new InputStreamReader(System.in), source);
lintResult = api.scan(source.toString(), stdInFile);
} else {
lintResult = api.scan(folder);
}
if (xmlOutput) {
try (final Writer xmlwriter = stdOut ? new OutputStreamWriter(System.out) : createXMLWriter(xmlOutFile, StandardCharsets.UTF_8)) {
if (FINDBUGS.equalsIgnoreCase(xmlstyle)) {
if (verbose) {
display("Writing XML (style: findbugs)" + (stdOut ? "." : " to " + xmlOutFile));
}
lintResult.writeFindBugsXml(xmlwriter);
} else {
if (verbose) {
display("Writing XML" + (stdOut ? "." : " to " + xmlOutFile));
}
lintResult.writeXml(xmlwriter);
}
}
}
if (textOutput) {
try (final Writer textwriter = stdOut || textOutFile == null ? new OutputStreamWriter(System.out) : new FileWriter(textOutFile)) {
if (textOutFile != null && verbose) {
display("Writing text" + (stdOut ? "." : " to " + textOutFile));
}
lintResult.writeText(textwriter);
}
}
if (htmlOutput) {
try (final Writer htmlwriter = stdOut ? new OutputStreamWriter(System.out) : new FileWriter(htmlOutFile)) {
if (verbose) {
display("Writing HTML (style: " + htmlStyle + ")" + (stdOut ? "." : " to " + htmlOutFile));
}
lintResult.writeHTML(htmlStyle, htmlwriter);
}
}
if (jsonOutput) {
try (final Writer jsonwriter = stdOut ? new OutputStreamWriter(System.out) : new FileWriter(jsonOutFile)) {
if (verbose) {
display("Writing JSON" + (stdOut ? "." : " to " + jsonOutFile));
}
lintResult.writeJSON(jsonwriter);
}
}
if (verbose) {
display("Total files scanned: " + lintResult.getStats().getFileCount());
display("Total LOC scanned: " + lintResult.getStats().getTotalLines());
}
}
Aggregations