CFLint icon indicating copy to clipboard operation
CFLint copied to clipboard

False positives: parse error and missing semicolon

Open sbleon opened this issue 5 years ago • 2 comments

This code works fine in Lucee, but the linter can't parse it.

foo.cfc:

component {
  public struct function foo () localmode='modern' {
    if (['ach', 'wire'].find(form.payment_method)) {
      param name="form.confirmation_number" type="string";
    }
  }
}

Output:

Issue
Severity:ERROR
Message code:PARSE_ERROR
	File:/Users/leon/code/csubs/internal/objects/modules/foo.cfc
	Column:-44
	Line:5
		Message:Unable to parse
		Variable:'null' in function: 
		Expression:null
Issue
Severity:ERROR
Message code:MISSING_SEMI
	File:/Users/leon/code/csubs/internal/objects/modules/foo.cfc
	Column:22
	Line:5
		Message:End of statement(;) expected after ]
		Variable:']' in function: 
		Expression:null

Severity:ERROR
Message code:MISSING_SEMI
	File:/Users/leon/code/csubs/internal/objects/modules/foo.cfc
	Column:49
	Line:3
		Message:End of statement(;) expected after '
		Variable:''' in function: 
		Expression:null

Severity:ERROR
Message code:MISSING_SEMI
	File:/Users/leon/code/csubs/internal/objects/modules/foo.cfc
	Column:-18
	Line:5
		Message:End of statement(;) expected after 
		Variable:'null' in function: 
		Expression:null


Total files:1
Total lines:11

Issue counts:2
PARSE_ERROR:1
MISSING_SEMI:3

Total issues:4
Total errors:4

Version: 75bc070eabbf6d82f45593b89b4813f54b03ea04 (1.5)

sbleon avatar Feb 11 '20 17:02 sbleon

It seems that the parser is failing when it encounters a function being called on an array literal.

KamasamaK avatar Mar 07 '20 03:03 KamasamaK

Yep, another example that triggers the MISSING_SEMI rule as a false positive.

return apiCall(
	  httpMethod  = 'POST'
	, path        = '/' & variables.domain & '/batchcode/'
	, queryParams = queryParams
	, payload     = serializeJSON( [].append( payload ) )
);

CreativeNotice avatar Dec 31 '20 07:12 CreativeNotice