Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IsDefined array member function gives invalid advice #2

Open
jmohler1970 opened this issue Oct 16, 2018 · 3 comments
Open

IsDefined array member function gives invalid advice #2

jmohler1970 opened this issue Oct 16, 2018 · 3 comments

Comments

@jmohler1970
Copy link

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
Copy link
Collaborator

bdw429s commented Oct 16, 2018

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
Copy link
Author

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
Copy link
Contributor

xdecock commented Apr 25, 2024

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants