Skip to content

Commit fcf92f8

Browse files
committed
S2769 Remove false positive
1 parent 26ae859 commit fcf92f8

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

javascript-checks/src/main/java/org/sonar/javascript/checks/SelectionTestedWithoutLengthCheck.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ public class SelectionTestedWithoutLengthCheck extends BaseTreeVisitor {
4141
@Override
4242
public void visitIfStatement(IfStatementTree tree) {
4343
ExpressionTree condition = tree.condition();
44-
if (condition.types().contains(PrimitiveType.JQUERY_SELECTOR_OBJECT)) {
44+
boolean canBeOnlyJQuerySelector = condition.types().contains(PrimitiveType.JQUERY_SELECTOR_OBJECT) && condition.types().size() == 1;
45+
if (canBeOnlyJQuerySelector) {
4546
getContext().addIssue(this, condition, "Use the \"length\" property to see whether this selection contains elements.");
4647
}
4748
super.visitIfStatement(tree);

0 commit comments

Comments
 (0)