Skip to content

Commit 21272f5

Browse files
author
Valentin REJAUNIER
committed
fix: add linter annotation
1 parent cb34479 commit 21272f5

File tree

3 files changed

+44
-46
lines changed

3 files changed

+44
-46
lines changed

pkg/log/main_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package log
1+
package log //nolint:revive
22

33
import (
44
"testing"

pkg/version/update_check.go

Lines changed: 42 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package version
1+
package version //nolint:revive
22

33
import (
44
"context"
@@ -15,62 +15,60 @@ import (
1515
const updateCheckTimeout = 1000 * time.Millisecond
1616

1717
type githubRelease struct {
18-
TagName string `json:"tag_name"`
18+
TagName string `json:"tag_name"`
1919
}
2020

2121
func normalizeVersion(v string) string {
22-
v = strings.TrimSpace(v)
23-
v = strings.TrimPrefix(v, "v")
24-
return v
22+
v = strings.TrimSpace(v)
23+
v = strings.TrimPrefix(v, "v")
24+
return v
2525
}
2626

2727
func getLatestReleaseTag(ctx context.Context) (string, error) {
28-
client := env.GetHTTPClient()
29-
req, err := http.NewRequestWithContext(ctx, http.MethodGet, "https://api.github.com/repos/Escape-Technologies/cli/releases/latest", nil)
30-
if err != nil {
31-
return "", fmt.Errorf("create request: %w", err)
32-
}
28+
client := env.GetHTTPClient()
29+
req, err := http.NewRequestWithContext(ctx, http.MethodGet, "https://api.github.com/repos/Escape-Technologies/cli/releases/latest", nil)
30+
if err != nil {
31+
return "", fmt.Errorf("create request: %w", err)
32+
}
3333

34-
resp, err := client.Do(req)
35-
if err != nil {
36-
return "", fmt.Errorf("perform request: %w", err)
37-
}
38-
defer func() { _ = resp.Body.Close() }()
39-
if resp.StatusCode != http.StatusOK {
40-
return "", fmt.Errorf("unexpected status: %s", resp.Status)
41-
}
42-
var release githubRelease
43-
if err := json.NewDecoder(resp.Body).Decode(&release); err != nil {
44-
return "", fmt.Errorf("decode response: %w", err)
45-
}
46-
return strings.TrimSpace(release.TagName), nil
34+
resp, err := client.Do(req)
35+
if err != nil {
36+
return "", fmt.Errorf("perform request: %w", err)
37+
}
38+
defer func() { _ = resp.Body.Close() }()
39+
if resp.StatusCode != http.StatusOK {
40+
return "", fmt.Errorf("unexpected status: %s", resp.Status)
41+
}
42+
var release githubRelease
43+
if err := json.NewDecoder(resp.Body).Decode(&release); err != nil {
44+
return "", fmt.Errorf("decode response: %w", err)
45+
}
46+
return strings.TrimSpace(release.TagName), nil
4747
}
4848

4949
// WarnIfNotLatestVersion checks the latest GitHub release and prints if the current version is not the latest.
5050
func WarnIfNotLatestVersion(parentCtx context.Context) {
51-
v := GetVersion()
52-
if strings.TrimSpace(v.Version) == "" || v.Version == "local" {
53-
return
54-
}
51+
v := GetVersion()
52+
if strings.TrimSpace(v.Version) == "" || v.Version == "local" {
53+
return
54+
}
5555

56-
ctx, cancel := context.WithTimeout(parentCtx, updateCheckTimeout)
57-
defer cancel()
56+
ctx, cancel := context.WithTimeout(parentCtx, updateCheckTimeout)
57+
defer cancel()
5858

59-
latest, err := getLatestReleaseTag(ctx)
60-
if err != nil || latest == "" {
61-
return
62-
}
59+
latest, err := getLatestReleaseTag(ctx)
60+
if err != nil || latest == "" {
61+
return
62+
}
6363

64-
current := normalizeVersion(v.Version)
65-
latestNorm := normalizeVersion(latest)
66-
if current == latestNorm {
67-
return
68-
}
64+
current := normalizeVersion(v.Version)
65+
latestNorm := normalizeVersion(latest)
66+
if current == latestNorm {
67+
return
68+
}
6969

70-
yellow := "\x1b[33m"
71-
reset := "\x1b[0m"
72-
msg := fmt.Sprintf("A new version of escape-cli is available: %s (you have %s). Update: https://docs.escape.tech/documentation/tooling/cli/?h=cli", latest, v.Version)
73-
fmt.Fprintf(os.Stderr, "%s%s%s\n", yellow, msg, reset)
70+
yellow := "\x1b[33m"
71+
reset := "\x1b[0m"
72+
msg := fmt.Sprintf("A new version of escape-cli is available: %s (you have %s). Update: https://docs.escape.tech/documentation/tooling/cli/?h=cli", latest, v.Version)
73+
fmt.Fprintf(os.Stderr, "%s%s%s\n", yellow, msg, reset)
7474
}
75-
76-

pkg/version/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Package version contains the version information for the CLI
2-
package version
2+
package version //nolint:revive
33

44
import "fmt"
55

0 commit comments

Comments
 (0)