Skip to content

Commit 1839bd3

Browse files
committed
comment, and handle another case
1 parent 28f6031 commit 1839bd3

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

client/src/commands/code_analysis.ts

+17-4
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,22 @@ export type DiagnosticsResultFormat = Array<{
3434
};
3535
}>;
3636

37+
enum ClassifiedMessage {
38+
Removable,
39+
Default,
40+
}
41+
42+
let classifyMessage = (msg: string) => {
43+
if (
44+
msg.endsWith(" is never used") ||
45+
msg.endsWith(" has no side effects and can be removed")
46+
) {
47+
return ClassifiedMessage.Removable;
48+
}
49+
50+
return ClassifiedMessage.Default;
51+
};
52+
3753
let resultsToDiagnostics = (
3854
results: DiagnosticsResultFormat,
3955
diagnosticsResultCodeActions: DiagnosticsResultCodeActionsMap
@@ -120,10 +136,7 @@ let resultsToDiagnostics = (
120136

121137
// This heuristic below helps only target dead code that can be removed
122138
// safely by just removing its text.
123-
if (
124-
item.message.endsWith(" is never used") ||
125-
item.message.endsWith(" has no side effects and can be removed")
126-
) {
139+
if (classifyMessage(item.message) === ClassifiedMessage.Removable) {
127140
{
128141
let codeAction = new CodeAction("Remove unused");
129142
codeAction.kind = CodeActionKind.RefactorRewrite;

client/src/extension.ts

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import {
1919
LanguageClientOptions,
2020
ServerOptions,
2121
State,
22-
Executable,
2322
TransportKind,
2423
} from "vscode-languageclient/node";
2524

0 commit comments

Comments
 (0)