cflint / CFLint

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

Better Lucee support for CFLint #414

Open TheRealAgentK opened 7 years ago

TheRealAgentK commented 7 years ago

Collection ticket for discussion around Lucee and CFLint

KamasamaK commented 7 years ago

I have not used Lucee extensively, so if anyone can comment on syntax differences that would need to be taken into consideration that would be great as parse errors would be the biggest issue. Currently, I know that Lucee makes semicolons optional (#104) [EDIT: This is now supported in ACF 2018] and allows for trailing commas (#263 and #365). There is also the proposal for an HTML island, but as far as I am aware nothing has come of it. [EDIT: It's been deployed] Lucee supports the ACF syntax as well in most cases for compatibility, but it also has its own syntax variations in some cases.

Anonymous functions/Lambda syntax (Arrow functions)

cfparser/cfparser#123

ACF does not support the arrow function syntax at this time, but it is marked as "To Fix". [EDIT: Support added in CF2018U5 via CF-4198396].

ACF

g = function(x,y) {
    return x*y;
}

Lucee-only

g = (x,y) => x*y

Lucee-exclusive operators

cfparser/cfparser#128

cybersonic commented 6 years ago

I am also testing but a big one (that I think more developers would use) would be

<cfscript>
dump(SERVER);
</cfscript>

There is also the ternary and elvis operators:

More info here: http://docs.lucee.org/guides/developing-with-lucee-server/operators.html

KamasamaK commented 6 years ago

The ternary and elvis operators are not exclusive to Lucee, so they should be supported regardless.

The dump function is a good example because there is a rule to avoid writeDump (in production code), but does not account for dump which is a Lucee-exclusive alias.

cybersonic commented 6 years ago

Apologies, haven't used latest versions of ACF in anger for a while so not sure they are in.

There are rules I want to add too, but will get to that once #317 gets done so I can get contributing.

michaelborn commented 5 years ago

Yeah, what would it take to add arrow function support? Currently CFLint throws a NullPointerException when it encounters them.

(I can open this as a new issue if you'd like - I just thought I'd put it here since you mentioned it above.)

https://bitbucket.org/michaelborn_me/cfevents/addon/pipelines/home#!/results/4

AFO-0 commented 3 years ago

Hi!
It's seems the arrow function is not supported yet :cry:. info

And, here is another syntax from Lucee that is no well handled.
This is the oredered struct definition using array brackets: info

var z = [
  a = 1,
  b = 2
];

That is equivalent to this ugly piece of code:

var z = new struct( 'ordered' );
z.a = 1;
z.b = 2;

Thanks!

zspitzer commented 2 years ago

it seems tag islands cause a NPE

Caused by: java.lang.NullPointerException at cfml.parsing.cfscript.walker.CFScriptStatementVisitor.visitForStatement(CFScriptStatementVisitor.java:340) at cfml.parsing.cfscript.walker.CFScriptStatementVisitor.visitForStatement(CFScriptStatementVisitor.java:102) at cfml.CFSCRIPTParser$ForStatementContext.accept(CFSCRIPTParser.java:2955) at org.antlr.v4.runtime.tree.AbstractParseTreeVisitor.visitChildren(AbstractParseTreeVisitor.java:46)