Skip to content

Commit

Permalink
Merge pull request #695 from github/lcartey/rule-8-3-linker-aware
Browse files Browse the repository at this point in the history
Rule 8.3: Remove false positives for declarations that don't share a link target
  • Loading branch information
lcartey authored Sep 19, 2024
2 parents 2db3484 + 0705aa6 commit 397d9df
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
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.

0 comments on commit 397d9df

Please sign in to comment.