Skip to content

Commit 0db3210

Browse files
committed
Fix lint errors: unchecked returns, redundant selectors, type inference
1 parent 479c22c commit 0db3210

File tree

9 files changed

+39
-39
lines changed

9 files changed

+39
-39
lines changed

internal/client/file.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,12 @@ func (s *fileService) Info(ctx context.Context, uuid string, includeAppData bool
7575

7676
func mapFileInfo(info file.Info) *service.File {
7777
f := &service.File{
78-
UUID: info.BasicFileInfo.ID,
79-
Size: int64(info.BasicFileInfo.Size),
80-
Filename: info.BasicFileInfo.OriginalFileName,
81-
MimeType: info.BasicFileInfo.MimeType,
82-
IsImage: info.BasicFileInfo.IsImage,
83-
IsReady: info.BasicFileInfo.IsReady,
78+
UUID: info.ID,
79+
Size: int64(info.Size),
80+
Filename: info.OriginalFileName,
81+
MimeType: info.MimeType,
82+
IsImage: info.IsImage,
83+
IsReady: info.IsReady,
8484
IsStored: info.StoredAt != nil,
8585
URL: info.URL,
8686
Metadata: info.Metadata,
@@ -114,12 +114,12 @@ func mapFileInfo(info file.Info) *service.File {
114114

115115
func mapUploadFileInfo(info upload.FileInfo) *service.File {
116116
return &service.File{
117-
UUID: info.BasicFileInfo.ID,
118-
Size: int64(info.BasicFileInfo.Size),
119-
Filename: info.BasicFileInfo.OriginalFileName,
120-
MimeType: info.BasicFileInfo.MimeType,
121-
IsImage: info.BasicFileInfo.IsImage,
122-
IsReady: info.BasicFileInfo.IsReady,
117+
UUID: info.ID,
118+
Size: int64(info.Size),
119+
Filename: info.OriginalFileName,
120+
MimeType: info.MimeType,
121+
IsImage: info.IsImage,
122+
IsReady: info.IsReady,
123123
IsStored: info.IsStored,
124124
}
125125
}

internal/client/file_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ func TestNewFileService(t *testing.T) {
1616
if err != nil {
1717
t.Fatalf("NewFileService failed: %v", err)
1818
}
19-
var _ service.FileService = svc
19+
var _ service.FileService = svc //nolint:gosimple
2020
}
2121

2222
func TestNewFileService_WithCDNBase(t *testing.T) {
2323
svc, err := NewFileService("test-pub-key", "test-secret-key", "https://custom.example.com", nil, nil)
2424
if err != nil {
2525
t.Fatalf("NewFileService with CDN base failed: %v", err)
2626
}
27-
var _ service.FileService = svc
27+
var _ service.FileService = svc //nolint:gosimple
2828
}
2929

3030
func TestSetCDNURL_RewritesOriginalFileURL(t *testing.T) {
@@ -106,7 +106,7 @@ func TestMapFileInfo_Complete(t *testing.T) {
106106
}`
107107
w.Header().Set("Content-Type", "application/json")
108108
w.WriteHeader(200)
109-
w.Write([]byte(resp))
109+
_, _ = w.Write([]byte(resp))
110110
}))
111111
defer server.Close()
112112

internal/cmd/addon.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ JSON fields (after completion): status, result.`,
147147
"status": "would execute",
148148
})
149149
}
150-
fmt.Fprintf(cmd.OutOrStdout(), "Would execute %s on %s\n", addonName, fileUUID)
150+
_, _ = fmt.Fprintf(cmd.OutOrStdout(), "Would execute %s on %s\n", addonName, fileUUID)
151151
return nil
152152
}
153153

@@ -160,7 +160,7 @@ JSON fields (after completion): status, result.`,
160160
if opts.JSON {
161161
return formatter.Format(cmd.OutOrStdout(), result)
162162
}
163-
fmt.Fprintf(cmd.OutOrStdout(), "Request ID: %s\n", result.RequestID)
163+
_, _ = fmt.Fprintf(cmd.OutOrStdout(), "Request ID: %s\n", result.RequestID)
164164
return nil
165165
}
166166

@@ -173,9 +173,9 @@ JSON fields (after completion): status, result.`,
173173
return formatter.Format(cmd.OutOrStdout(), status)
174174
}
175175

176-
fmt.Fprintf(cmd.OutOrStdout(), "Status: %s\n", status.Status)
176+
_, _ = fmt.Fprintf(cmd.OutOrStdout(), "Status: %s\n", status.Status)
177177
if len(status.Result) > 0 {
178-
fmt.Fprintf(cmd.OutOrStdout(), "Result: %s\n", string(status.Result))
178+
_, _ = fmt.Fprintf(cmd.OutOrStdout(), "Result: %s\n", string(status.Result))
179179
}
180180
return nil
181181
},
@@ -235,9 +235,9 @@ JSON fields: status, result (when done).`,
235235
return formatter.Format(cmd.OutOrStdout(), status)
236236
}
237237

238-
fmt.Fprintf(cmd.OutOrStdout(), "Status: %s\n", status.Status)
238+
_, _ = fmt.Fprintf(cmd.OutOrStdout(), "Status: %s\n", status.Status)
239239
if len(status.Result) > 0 {
240-
fmt.Fprintf(cmd.OutOrStdout(), "Result: %s\n", string(status.Result))
240+
_, _ = fmt.Fprintf(cmd.OutOrStdout(), "Result: %s\n", string(status.Result))
241241
}
242242
return nil
243243
},

internal/cmd/file_upload.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,13 +190,13 @@ is_ready, datetime_uploaded, original_file_url, metadata.`,
190190
Metadata: meta,
191191
MultipartThreshold: threshold,
192192
})
193-
f.Close()
193+
_ = f.Close()
194194
if err != nil {
195195
return fmt.Errorf("uploading %q: %w", entry.path, err)
196196
}
197197

198198
if showProgress {
199-
fmt.Fprintln(cmd.ErrOrStderr())
199+
_, _ = fmt.Fprintln(cmd.ErrOrStderr())
200200
}
201201

202202
results = append(results, result)
@@ -280,7 +280,7 @@ func detectContentType(path string) (string, error) {
280280
if err != nil {
281281
return "", err
282282
}
283-
defer f.Close()
283+
defer func() { _ = f.Close() }()
284284

285285
buf := make([]byte, 512)
286286
n, err := f.Read(buf)

internal/cmd/metadata.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ is specified. Returns "No metadata found" when the file has no metadata.`,
7373
}
7474

7575
if len(meta) == 0 {
76-
fmt.Fprintln(cmd.OutOrStdout(), "No metadata found")
76+
_, _ = fmt.Fprintln(cmd.OutOrStdout(), "No metadata found")
7777
return nil
7878
}
7979

@@ -133,7 +133,7 @@ fields when --json all is specified. Returns an error if the key does not exist.
133133
})
134134
}
135135

136-
fmt.Fprintln(cmd.OutOrStdout(), value)
136+
_, _ = fmt.Fprintln(cmd.OutOrStdout(), value)
137137
return nil
138138
},
139139
}

internal/cmd/schema.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ No authentication required.`,
8787
enc := json.NewEncoder(cmd.OutOrStdout())
8888
enc.SetEscapeHTML(false)
8989
enc.SetIndent("", " ")
90-
enc.Encode(schema)
90+
_ = enc.Encode(schema)
9191
},
9292
}
9393
}

internal/cmd/url_api.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ For the full machine-readable reference with all parameters and values:
4444
https://ucarecdn.com/{uuid}/-/autorotate/yes/-/resize/1200x/-/quality/smart/-/format/auto/`,
4545
Args: cobra.NoArgs,
4646
Run: func(cmd *cobra.Command, args []string) {
47-
cmd.Help()
47+
_ = cmd.Help()
4848
},
4949
}
5050
}

internal/cmd/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Use --json all for machine-readable output.`,
2626

2727
if opts.JSON || opts.JQ != "" {
2828
formatter := output.New(opts)
29-
formatter.Format(cmd.OutOrStdout(), map[string]string{
29+
_ = formatter.Format(cmd.OutOrStdout(), map[string]string{
3030
"version": version,
3131
"commit": commit,
3232
"date": date,

internal/config/config.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -130,16 +130,16 @@ func (l *Loader) Init() error {
130130

131131
// Bind env vars
132132
l.v.SetEnvPrefix("")
133-
l.v.BindEnv("public_key", "UPLOADCARE_PUBLIC_KEY")
134-
l.v.BindEnv("secret_key", "UPLOADCARE_SECRET_KEY")
135-
l.v.BindEnv("project_api_token", "UPLOADCARE_PROJECT_API_TOKEN")
136-
l.v.BindEnv("project", "UPLOADCARE_PROJECT")
137-
l.v.BindEnv("verbose", "UPLOADCARE_VERBOSE")
138-
139-
l.v.BindEnv("rest_api_base", "UPLOADCARE_REST_API_BASE")
140-
l.v.BindEnv("upload_api_base", "UPLOADCARE_UPLOAD_API_BASE")
141-
l.v.BindEnv("cdn_base", "UPLOADCARE_CDN_BASE")
142-
l.v.BindEnv("project_api_base", "UPLOADCARE_PROJECT_API_BASE")
133+
_ = l.v.BindEnv("public_key", "UPLOADCARE_PUBLIC_KEY")
134+
_ = l.v.BindEnv("secret_key", "UPLOADCARE_SECRET_KEY")
135+
_ = l.v.BindEnv("project_api_token", "UPLOADCARE_PROJECT_API_TOKEN")
136+
_ = l.v.BindEnv("project", "UPLOADCARE_PROJECT")
137+
_ = l.v.BindEnv("verbose", "UPLOADCARE_VERBOSE")
138+
139+
_ = l.v.BindEnv("rest_api_base", "UPLOADCARE_REST_API_BASE")
140+
_ = l.v.BindEnv("upload_api_base", "UPLOADCARE_UPLOAD_API_BASE")
141+
_ = l.v.BindEnv("cdn_base", "UPLOADCARE_CDN_BASE")
142+
_ = l.v.BindEnv("project_api_base", "UPLOADCARE_PROJECT_API_BASE")
143143

144144
// Defaults
145145
l.v.SetDefault("rest_api_base", DefaultRESTAPIBase)

0 commit comments

Comments
 (0)