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

Rule 8.3: Remove false positives for declarations that don't share a link target #695

Merged
merged 2 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,19 @@ where
not isExcluded(decl2, Declarations4Package::declarationsOfAnObjectSameNameAndTypeQuery()) and
not decl1 = decl2 and
not decl1.getVariable().getDeclaringType().isAnonymous() and
// Declarations are for the same qualified name
// Note: decl1.getVariable() = decl2.getVariable() does not work for common cases where an aliased
// type is used.
decl1.getVariable().getQualifiedName() = decl2.getVariable().getQualifiedName() and
// As we use qualified name, require that they share a common link target to ensure they are
// for the same object
(
decl1.getVariable().(GlobalVariable).getALinkTarget() =
decl2.getVariable().(GlobalVariable).getALinkTarget()
or
decl1.getVariable().(Field).getDeclaringType().(Class).getALinkTarget() =
decl2.getVariable().(Field).getDeclaringType().(Class).getALinkTarget()
) and
not typesCompatible(decl1.getType(), decl2.getType())
select decl1,
"The object $@ of type " + decl1.getType().toString() +
Expand Down
2 changes: 2 additions & 0 deletions change_notes/2024-09-17-rule-8-3-linker-aware.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- `RULE-8-3` - `DeclarationsOfAnObjectSameNameAndType.ql`
- Remove false positives where two conflicting declarations are never linked together.
Loading