russplaysguitar / navel

Working towards a linter for cfscript
MIT License
2 stars 0 forks source link

Decision operators #5

Open russplaysguitar opened 11 years ago

russplaysguitar commented 11 years ago

The use of "decision operators" should cause lint failures. Examples IS, IS NOT, EQ, NEQ, etc...

Boolean operations should be used instead.

russplaysguitar commented 11 years ago

== should be used instead of EQ != should be used instead of NEQ && should be used instead of AND || should be used instead of OR

CONTAINS and DOES NOT CONTAIN supposedly aren't valid in cfscript anyways (haven't tested that, though).

For string comparisons, compare() (or compareNoCase()) should be used instead of IS and IS NOT.

adamcameron commented 11 years ago

I see. Well it's up to you, but this would be one of the ones I don't agree with (not that you asked). I see this sort of thing as entirely personal preference, so not a good fit here.

Amusingly, this works in CFScript just fine, btw: result = a greater than or equal to b;

And, no, I would never do that. I personally prefer the C-style operators over the Perl-style ones, but I'd not enforce that on anyone else. YMMV obviously

russplaysguitar commented 11 years ago

yeah, that's the thing about linters: that they kinda force their code-style on everyone. that is why i wanted to get opinions before starting work on it.

i think all of the rules should be optional (but 'on' by default). maybe each rule could be set to one of: 'off', 'warn', or 'fail'.

i did see this one on a few cfml best practices guides, but maybe i should create a survey after we're done discussing and gathering potential rules?

adamcameron commented 11 years ago

Ah right, I see. Yeah, I think it's fine provided it can be switched off: or even not. Even then when I run JSLint I ignore half the stuff it says cos my opinion is "nah, that's a crap rule", and I imagine I'm not the only one ;-)

russplaysguitar commented 11 years ago

just to clarify: do you prefer those operators in cfscript as well as tags?

adamcameron commented 11 years ago

Yep. NB: PERL now has the == styles ones too, so when I said Perl-style before, I meant "EQ" etc: the alphabetical ones. So I prefer the same ones you were thinking of enforcing the use of (==, !=, &7, || etc), but I just wouldn't be enforcing it.

russplaysguitar commented 11 years ago

okay cool

atuttle commented 11 years ago

:+1: for the rule. also :+1: for having every rule be defaulted to "fail" but optionally set to warn/off.