File tree Expand file tree Collapse file tree 1 file changed +7
-9
lines changed
internal/rules/no_unnecessary_type_assertion Expand file tree Collapse file tree 1 file changed +7
-9
lines changed Original file line number Diff line number Diff line change @@ -219,20 +219,18 @@ var NoUnnecessaryTypeAssertionRule = rule.Rule{
219219 msg := buildUnnecessaryAssertionMessage ()
220220
221221 if node .Kind == ast .KindAsExpression {
222- s := scanner .GetScannerForSourceFile (ctx .SourceFile , expression .End ())
223- asKeywordRange := s .TokenRange ()
224-
225222 ctx .ReportNodeWithFixes (node , msg , func () []rule.RuleFix {
223+ s := scanner .GetScannerForSourceFile (ctx .SourceFile , expression .End ())
224+ asKeywordRange := s .TokenRange ()
226225 return []rule.RuleFix {rule .RuleFixRemoveRange (asKeywordRange ), rule .RuleFixRemove (ctx .SourceFile , typeNode )}
227226 })
228227 } else {
229- s := scanner .GetScannerForSourceFile (ctx .SourceFile , node .Pos ())
230- openingAngleBracket := s .TokenRange ()
231- s .ResetPos (typeNode .End ())
232- s .Scan ()
233- closingAngleBracket := s .TokenRange ()
234-
235228 ctx .ReportNodeWithFixes (node , msg , func () []rule.RuleFix {
229+ s := scanner .GetScannerForSourceFile (ctx .SourceFile , node .Pos ())
230+ openingAngleBracket := s .TokenRange ()
231+ s .ResetPos (typeNode .End ())
232+ s .Scan ()
233+ closingAngleBracket := s .TokenRange ()
236234 return []rule.RuleFix {rule .RuleFixRemoveRange (openingAngleBracket .WithEnd (closingAngleBracket .End ()))}
237235 })
238236 }
You can’t perform that action at this time.
0 commit comments