Skip to content

Commit 67988e6

Browse files
committed
Exclude types annotated with attributes in UnusedType
1 parent 53f7d67 commit 67988e6

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
## [1.14.1] - 2025-03-05
1111

12+
### Changed
13+
14+
- Exclude types annotated with attributes in `UnusedType`.
15+
1216
### Fixed
1317

1418
- File pointer errors around `>=` and `<=` tokens.

delphi-checks/src/main/java/au/com/integradev/delphi/checks/UnusedTypeCheck.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ private boolean isViolation(TypeDeclarationNode node) {
6969
return false;
7070
}
7171

72+
if (node.getAttributeList() != null) {
73+
return false;
74+
}
75+
7276
return node.getTypeNameNode().getUsages().stream()
7377
.allMatch(occurrence -> isWithinType(occurrence, type));
7478
}

delphi-checks/src/test/java/au/com/integradev/delphi/checks/UnusedTypeCheckTest.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,4 +199,17 @@ void testUnusedImplementationTypeWithExcludeApiShouldAddIssue() {
199199
.appendImpl("end;"))
200200
.verifyIssues();
201201
}
202+
203+
@Test
204+
void testUnusedTypeWithAttributeShouldNotAddIssue() {
205+
CheckVerifier.newVerifier()
206+
.withCheck(new UnusedTypeCheck())
207+
.onFile(
208+
new DelphiTestUnitBuilder()
209+
.appendDecl("type")
210+
.appendDecl(" [Bar]")
211+
.appendDecl(" TFoo = class")
212+
.appendDecl(" end;"))
213+
.verifyNoIssues();
214+
}
202215
}

0 commit comments

Comments
 (0)