CFLint icon indicating copy to clipboard operation
CFLint copied to clipboard

Better Lucee support for CFLint

Open TheRealAgentK opened this issue 7 years ago • 7 comments

Collection ticket for discussion around Lucee and CFLint

TheRealAgentK avatar Aug 09 '17 20:08 TheRealAgentK

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

  • ===/!==: Checks value and type
  • CT: Alias for CONTAINS
  • NCT: Alias for DOES NOT CONTAIN

KamasamaK avatar Aug 09 '17 20:08 KamasamaK

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:

  • var item = FileExists(thing) ? "Yep" : "Nope";
  • var item = rockstar?:"Elvis";

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

cybersonic avatar May 03 '18 15:05 cybersonic

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.

KamasamaK avatar May 03 '18 16:05 KamasamaK

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.

cybersonic avatar May 03 '18 17:05 cybersonic

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

michaelborn avatar Jun 21 '19 04:06 michaelborn

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!

AFO-0 avatar Sep 07 '21 15:09 AFO-0

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)

zspitzer avatar Oct 13 '21 15:10 zspitzer