commandbox-modules / commandbox-codechecker

A CLI wrapper for the Codechecker project
4 stars 6 forks source link

IsDefined array member function gives invalid advice #2

Open jmohler1970 opened 6 years ago

jmohler1970 commented 6 years ago

This is the message shown

 Don't use IsDefined | Performance | Severity: 3
  Prefer StructKeyExists() over IsDefined()
  Users//jamesmohler/Sites/ColdFusion/FormUtils.../formutils.cfc:115

I am using the array member function isDefined() The advice to use a structKeyExists() seems to be invalid.

bdw429s commented 6 years ago

Hi @jmohler1970 here's the regex used to define that rule:

https://github.com/coldbox-modules/codechecker-core/blob/master/rules/core.performance.rules.json#L31

I'm thinking just modifying that to NOT match when there's a leading period should clear up the false positive. Would you like to try sending a pull to the core repo that defines those default rules?

We have quite a few rules that were created several years ago so I'm sure there are a number of ones that we can tweak and update.

jmohler1970 commented 6 years ago

I not good with regular expressions, but I know the scenarios to be looked into

<space>isDefined(( bad (isDefined( bad arrayIsDefined( good .isDefined( good, member function of above

xdecock commented 7 months ago

(?<!array|\.)isdefined\( i think might do the trick

https://regex101.com/r/0AcEON/1