Skip to content

Commit 34cc758

Browse files
zthcristianoc
authored andcommitted
do not mark redundant optional argument warnings as unecessary/unused code
1 parent b8c2955 commit 34cc758

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

client/src/commands/dead_code_analysis.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,15 +132,21 @@ let dceTextToDiagnostics = (
132132
}
133133

134134
let issueLocationRange = new Range(startPos, endPos);
135+
let diagnosticText = text.trim();
135136

136137
let diagnostic = new Diagnostic(
137138
issueLocationRange,
138-
text.trim(),
139+
diagnosticText,
139140
DiagnosticSeverity.Warning
140141
);
141142

142-
// This will render the part of the code as unused
143-
diagnostic.tags = [DiagnosticTag.Unnecessary];
143+
// Everything reanalyze reports is about dead code, except for redundant
144+
// optional arguments. This will ensure that everything but reduntant
145+
// optional arguments is highlighted as unecessary/unused code in the
146+
// editor.
147+
if (!diagnosticText.toLowerCase().startsWith("optional argument")) {
148+
diagnostic.tags = [DiagnosticTag.Unnecessary];
149+
}
144150

145151
if (diagnosticsMap.has(processedFileInfo.filePath)) {
146152
diagnosticsMap.get(processedFileInfo.filePath).push(diagnostic);

0 commit comments

Comments
 (0)