Example of Using a CommandBox Task Runner to Run CFLint

I have been looking into CFLint as a tool to help improve the quality of our teams CFML. Also, to aid in code reviews.

I created this gist that is a CommandBox Task Runner that takes a glob pattern and runs CFLint on any files that match.

box task run taskFile=cflint pattern=**.cfc

By default, it will display the results in the console.

Console Output

It can also generate an HTML report based on Bootstrap. See example below.

box task run taskFile=cflint pattern=**.cfc --html

HTML Report

You could also use it as part of an automatic build process. This will code will cause CommandBox to return an exit code of 1 if an error exists and thus cause build tools such as Jenkins to fail.

if ( reportData.errorExists ) {
	/* Flush any output to the console */
	print.line().toConsole();
	error("Please fix errors found by CFLint!");
}

CFLint can already output results to html and the console out of the box. The main reason I wrote this is that I wanted to only run CFLint on files that changed in an SVN development branch. Here is a version that uses SVN to get files for linting. It could be adapted for GIT as well which I may attempt at some point.