CFLint icon indicating copy to clipboard operation
CFLint copied to clipboard

Annotation-based configuration

Open chandler3224 opened this issue 3 years ago • 6 comments

The option to use comments to ignore lines/specific rules doesn't seem to be working when running from the command line. I'm running against the following code:

<cfcomponent displayname="test" output="false" hint="test">

	<cffunction name="init" access="public" output="false" returntype="test">
        <cfscript>
		var testa = ''; //cflint ignore:line
		return this;
	</cfscript>
    </cffunction>
    
</cfcomponent>

testa is never ignored. I have tried multiple variations.

Environment

Version: 1.5.0 (also tested 1.4.1) Windows 10

java -version
java version "1.8.0_291"
Java(TM) SE Runtime Environment (build 1.8.0_291-b10)
Java HotSpot(TM) 64-Bit Server VM (build 25.291-b10, mixed mode)

chandler3224 avatar Jun 10 '21 10:06 chandler3224

Since you are within a tag context, try the tag-style comment <!--- --->

begin-again avatar Jun 10 '21 11:06 begin-again

Ah yes, wasn't the best example. However I used this and still the same

<cfcomponent displayname="test" output="false" hint="test">

    <cffunction name="init" access="public" output="false" returntype="test">
        <cfset var testA = '' /> <!--- @CFLintIgnore line --->
        <cfreturn />
    </cffunction>
    
</cfcomponent>

Used combinations of @CFLintIgnore and just cflint. Thanks for the quick reply though.

chandler3224 avatar Jun 10 '21 12:06 chandler3224

I write mostly in CFScript and have found that the annotations do not work at all and the rules themselves have a lot of false positives.

/*
    @CFLintIgnore MISSING_SEMI,AVOID_USING_CREATEOBJECT,UNUSED_LOCAL_VARIABLE
*/

begin-again avatar Jun 10 '21 12:06 begin-again

Yeah, it seems the same with me. The tag comment only works for the whole file as long as it's before a component/function, doesn't support individual lines.

The cfscript comments support seems like it supports some annotations and not others. For example with this mixed snippet:

Works

<cfcomponent displayname="test" output="false" hint="test">
	<cffunction name="init" access="public" output="false" returntype="test">
        <cfscript>
            testB = ''; // cflint ignore:line
        </cfscript>
        <cfreturn />
    </cffunction>
</cfcomponent>

Doesn't work

<cfcomponent displayname="test" output="false" hint="test">
	<cffunction name="init" access="public" output="false" returntype="test">
        <cfscript>
            var testB = ''; // cflint ignore:line
        </cfscript>
        <cfreturn />
    </cffunction>
</cfcomponent>

Note the addition of the var. Strange one.

chandler3224 avatar Jun 10 '21 12:06 chandler3224

I can confirm that (tag-based) annotations have to be the first thing to put in a file, before <cfcomponent ...>, for them to work on the whole file.

nukleos avatar Jul 14 '21 07:07 nukleos

Ok, I'm not crazy, I can't get the annotations to work for me, I tried all the variations... doesn't seem to work. I'm in all script, in queryExecute, I tried almost every syntax, and nothing. I'm running with the commandbox cflint command.

gpickin avatar Sep 28 '21 19:09 gpickin