CFLint
CFLint copied to clipboard
Check file and method lengths
So a lot of the time, when I am looking for code smells it usually is when you have have a 2000 line file with 1000 lines in a single method.
A couple of length checkers would be good:
FILE_TOO_BIG METHOD_TOO_BIG
Would like to see if I can implement these (the context variable looks like is the one that I want) but is there a way to configure this? So by default it's 2000 lines ?
I guess this goes along for many other rules?
I think FunctionLengthChecker does something similar. You will see the default configuration in the cflint.definition.json.
This sounds like the rules EXCESSIVE_COMPONENT_LENGTH and EXCESSIVE_FUNCTION_LENGTH. You can configure ComponentLengthChecker.length
and FunctionLengthChecker.length
in your .cflintrc
in parameters
.
See Configuring a parameter for an example of how to do this. As @ryaneberly mentioned, you can check cflint.definition.json
but they're a bit more readable in the RULES.md.
Not all CFML files are components. Does EXCESSIVE_COMPONENT_LENGTH check .cfm files (just checked: no).
For better or for worse, there will be a lot of CFML code out there in .cfm files(*), and there are length thresholds that could/should be applied there too.
(*) I'm working on a CFWHeels app, and for some reason best known to someone other than me, their approach to building classes is to have an mostly empty .cfc file which then includes a bunch of .cfm files which have the actual methods in it. This is - obviously - an antipattern, but there we go: it's a fairly significant CFML project that uses a lot of .cfm files...