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

[GCI11] Disallow multiple access of same DOM element - False positives #59

Open
MP-Aubay opened this issue Jan 16, 2025 · 0 comments
Open
Labels
💉 bug: unconfirmed Potential bugs that need replicating to verify.

Comments

@MP-Aubay
Copy link

MP-Aubay commented Jan 16, 2025

Current Behavior

When using a loop and a variable in method (like getElementsByName), the issue is triggered, even if the "name" is unique.

And the issue is called "'undefined' selector is already used. Assign the result in a variable.".

Expected Behavior

The issue should not be triggered.

Steps to Reproduce

The source code that trigger the issue (rewrite to remove proprietary code) :

var row = 3;
var indice = 1;
while(indice <= row){	
	var test = document.getElementsByName("test" + indice)[0].value;
        indice++;
}

I don't know if the loop is important, but I have the same problem with the for loop.

Failure Logs

creedengo-javascript Version

1.4.0

SonarQube Version

9.9.3

Additional Information

Not using the last version of the plugin but did not see any update in the rule file since.

Issue with Javascript, did not check Typescript.

@MP-Aubay MP-Aubay added the 💉 bug: unconfirmed Potential bugs that need replicating to verify. label Jan 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💉 bug: unconfirmed Potential bugs that need replicating to verify.
Projects
None yet
Development

No branches or pull requests

1 participant