java: fix deadcode tests

GitOrigin-RevId: 8d170f38638a45e7a4304894e218ff0fbc02d8d9
This commit is contained in:
Bas Leijdekkers
2024-04-22 23:27:57 +00:00
committed by intellij-monorepo-bot
parent 3b492a9147
commit 4c7002e81c
8 changed files with 69 additions and 8 deletions
@@ -168,7 +168,7 @@ public class DeadHTMLComposer extends HTMLComposerImpl {
buf.append(AnalysisBundle.message("inspection.dead.code.problem.synopsis29.method", nRefs) );
}
}
} else if (refClass instanceof RefClassImpl && ((RefClassImpl)refClass).isSuspicious()) {
} else if (refClass instanceof RefClassImpl && ((RefClassImpl)refClass).isSuspicious() && !refClass.isUtilityClass()) {
if (method.isAbstract() && !refClass.isInterface()) {
buf.append(AnalysisBundle.message("inspection.dead.code.problem.synopsis14"));
} else {
@@ -1,10 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems>
<problem>
<file>Main.java</file>
<line>1</line>
<offset>13</offset>
<length>4</length>
<description>No class references has been found. Class static initializer is not reachable.</description>
</problem>
<problem>
<file>Main.java</file>
<line>6</line>
<description>Method is never used.</description>
</problem>
<problem>
<file>Test.java</file>
<line>1</line>
<offset>13</offset>
<length>4</length>
<description>Class has one instantiation, but it is not reachable from entry points.</description>
</problem>
<problem>
<file>Test.java</file>
<line>1</line>
@@ -15,10 +29,5 @@
<line>2</line>
<description>&lt;ul&gt;&lt;li&gt;Method owner class is never instantiated OR&lt;/li&gt;&lt;li&gt;An instantiation is not reachable from entry points.&lt;/li&gt;&lt;/ul&gt;</description>
</problem>
<problem>
<file>Test.java</file>
<line>1</line>
<description>Class has one instantiation but it is not reachable from entry points.</description>
</problem>
</problems>
@@ -1,11 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems>
<problem>
<file>Test.java</file>
<line>1</line>
<description>No class references has been found. Class static initializer is not reachable.</description>
</problem>
<problem>
<file>Test.java</file>
<line>1</line>
<description>No class references has been found. Class static initializer is not reachable.</description>
</problem>
<problem>
<file>Test.java</file>
<line>2</line>
<description>Method has one usage but it is not reachable from entry points.</description>
</problem>
<problem>
<file>Main.java</file>
<line>1</line>
<description>No class references has been found. Class static initializer is not reachable.</description>
</problem>
<problem>
<file>Main.java</file>
<line>6</line>
@@ -8,6 +8,6 @@
<problem>
<file>Example.java</file>
<line>3</line>
<description>No class references have been found. Class static initializer is not reachable.</description>
<description>No class references has been found. Class static initializer is not reachable.</description>
</problem>
</problems>
@@ -7,6 +7,13 @@
<description>Method has one usage but it is not reachable from entry points.</description>
</problem>
<problem>
<file>C.kt</file>
<line>1</line>
<entry_point TYPE="class" FQNAME="C" />
<description>No class references has been found. Class static initializer is not reachable.</description>
</problem>
<problem>
<file>C.kt</file>
<line>6</line>
@@ -22,6 +29,13 @@
<description>Method has usage(s) but they all belong to calls chain that has no members reachable from entry points.</description>
</problem>
<problem>
<file>A.java</file>
<line>1</line>
<entry_point TYPE="class" FQNAME="A" />
<description>No class references has been found. Class static initializer is not reachable.</description>
</problem>
<problem>
<file>A.java</file>
<line>2</line>
@@ -1,4 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems>
<problems>
<problem><!-- TODO false positive -->
<file>Test.kt</file>
<line>7</line>
<entry_point TYPE="class" FQNAME="Test.Companion" />
<description>No class references has been found. Class static initializer is not reachable.</description>
</problem>
</problems>
@@ -1,5 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems>
<problem><!-- TODO false positive -->
<file>A.kt</file>
<line>9</line>
<entry_point TYPE="class" FQNAME="YYY.Companion" />
<description>No class references has been found. Class static initializer is not reachable.</description>
</problem>
<problem>
<file>A.kt</file>
<line>11</line>
@@ -1,5 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems>
<problem><!--TODO false positive, or at least incorrect message because there are references -->
<file>Test.kt</file>
<line>1</line>
<entry_point TYPE="class" FQNAME="A" />
<description>No class references has been found. Class static initializer is not reachable.</description>
</problem>
<problem>
<file>Test.kt</file>
<line>2</line>