Skip to content

Commit 14b3a37

Browse files
author
sutong.527608
committed
Fix linter errors in handleOrganizeImportsCommand
- Replace fmt.Errorf with errors.New for non-formatted error (perfsprint) - Fix variable shadowing by reusing err instead of declaring new one (customlint)
1 parent 04d537f commit 14b3a37

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

internal/lsp/server.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -861,15 +861,16 @@ func (s *Server) handleExecuteCommand(ctx context.Context, params *lsproto.Execu
861861

862862
func (s *Server) handleOrganizeImportsCommand(ctx context.Context, params *lsproto.ExecuteCommandParams) (lsproto.ExecuteCommandResponse, error) {
863863
if params.Arguments == nil || len(*params.Arguments) == 0 {
864-
return lsproto.LSPAnyOrNull{}, fmt.Errorf("organizeImports command requires a document URI argument")
864+
return lsproto.LSPAnyOrNull{}, errors.New("organizeImports command requires a document URI argument")
865865
}
866866

867867
var documentURI lsproto.DocumentUri
868868
argBytes, err := json.Marshal((*params.Arguments)[0])
869869
if err != nil {
870870
return lsproto.LSPAnyOrNull{}, fmt.Errorf("failed to marshal argument: %w", err)
871871
}
872-
if err := json.Unmarshal(argBytes, &documentURI); err != nil {
872+
err = json.Unmarshal(argBytes, &documentURI)
873+
if err != nil {
873874
return lsproto.LSPAnyOrNull{}, fmt.Errorf("invalid document URI: %w", err)
874875
}
875876

0 commit comments

Comments
 (0)