cflint / CFLint

Static code analysis for CFML (a linter)
BSD 3-Clause "New" or "Revised" License
174 stars 84 forks source link

False error reporting for arrow functions #738

Open tcm151 opened 1 month ago

tcm151 commented 1 month ago

Arrow functions have been included in ACF since 2018, however CFLint false shows a missing semi colon error when they are used.

Example: shows error when using arrow function image doesn't show error when using the full chunky function syntax image

ghedwards commented 1 month ago

@tcm151 cfparser added some support for lambda functions a little while ago I wonder whats tripping it up here? https://github.com/cfparser/cfparser/commit/b6475f72dad69fd986e3a8c7320f031880be0be4 try using parens around your arguments ?

ghedwards commented 1 month ago

Also

temp = metadata.filter(m => m.DATA_TYPE != "P" && m.DATA_VALUE != "");

appears to work fine for me ? what version of cflint are you using ? try using this one and let me know if it fixes your issue

https://github.com/cfmleditor/CFLint/releases/tag/1.5.5-SNAPSHOT

tcm151 commented 1 month ago

Didn't know there was a snapshot, thanks for that! I've been using 1.5

ghedwards commented 1 month ago

@tcm151 no guarantees, just wanted to rule out an old version of the parser. The parser can get a bit crossed up with syntax depending on lots of other factors. Often as soon as you isolate the syntax it does fine, but embedded in a file with all kinds of other code can sometimes cause a problem. So if you're able to isolate it and reproduce the problem, that would help with some diagnosis ( but sometimes not an easy fix )

tcm151 commented 1 month ago

It's coming from a pretty small file, only 25-30 lines so I don't think there is too much affecting it that way. I'll give the snapshot a try and see if that resolves the issue

tcm151 commented 1 month ago

@ghedwards still no luck with the snapshot version, I've tried as many combinations of arrow functions syntax as I can think of

image image image image image

This is still the only one that works without an error image

tcm151 commented 1 month ago

I'm just going to exclude that rule for the meantime since it's not a major blocker for what I need it for