Skip to content
This repository was archived by the owner on Aug 30, 2024. It is now read-only.

Commit 18ae0da

Browse files
committed
Add golintci and fix errors
1 parent 924ebad commit 18ae0da

File tree

7 files changed

+28
-12
lines changed

7 files changed

+28
-12
lines changed

.golangci.yml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# See https://golangci-lint.run/usage/configuration/
2+
linters-settings:
3+
goconst:
4+
min-len: 4
5+
min-occurrences: 3
6+
gocognit:
7+
min-complexity: 46
8+
nestif:
9+
min-complexity: 10
10+
govet:
11+
settings:
12+
printf:
13+
funcs: # Run `go tool vet help printf` to see available settings for `printf` analyzer.
14+
- (cdr.dev/coder-cli/internal/clog).Tipf
15+
- (cdr.dev/coder-cli/internal/clog).Hintf
16+
- (cdr.dev/coder-cli/internal/clog).LogDebugf
17+
- (cdr.dev/coder-cli/internal/clog).Causef

ci/image/Dockerfile

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ ENV CI=true
55

66
RUN go get golang.org/x/tools/cmd/goimports
77
RUN go get golang.org/x/lint/golint
8-
RUN go get github.com/mattn/goveralls
8+
RUN go get github.com/mattn/goveralls
9+
RUN go get github.com/golangci/golangci-lint/cmd/golangci-lint@v1.27.0

ci/steps/lint.sh

+6
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,11 @@ set -euo pipefail
44

55
echo "Linting..."
66

7+
cd "$(dirname "$0")"
8+
cd ../../
9+
710
go vet ./...
811
golint -set_exit_status ./...
12+
13+
echo "--- golangci-lint"
14+
golangci-lint run -c .golangci.yml

internal/cmd/ceapi.go

-9
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,3 @@ func findEnv(ctx context.Context, client *coder.Client, envName, userEmail strin
8181
clog.Tip("run \"coder envs ls\" to view your environments"),
8282
)
8383
}
84-
85-
type notFoundButDidFind struct {
86-
needle string
87-
haystack []string
88-
}
89-
90-
func (n notFoundButDidFind) Error() string {
91-
return fmt.Sprintf("\"%s\" not found in %q: %v", n.needle, n.haystack, coder.ErrNotFound)
92-
}

internal/cmd/login.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func makeLoginCmd() *cobra.Command {
4040
// Don't return errors as it would print the usage.
4141

4242
if err := login(cmd, u, config.URL, config.Session); err != nil {
43-
return xerrors.Errorf("Login error", err)
43+
return xerrors.Errorf("login error: %w", err)
4444
}
4545
return nil
4646
},

internal/cmd/rebuild.go

-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ coder envs rebuild backend-env --force`,
7575
func trailBuildLogs(ctx context.Context, client *coder.Client, envID string) error {
7676
const check = "✅"
7777
const failure = "❌"
78-
const loading = "⌛"
7978

8079
newSpinner := func() *spinner.Spinner { return spinner.New(spinner.CharSets[11], 100*time.Millisecond) }
8180

internal/cmd/resourcemanager.go

+2
Original file line numberDiff line numberDiff line change
@@ -318,13 +318,15 @@ func (a resources) String() string {
318318
// )
319319
}
320320

321+
//nolint:unused
321322
func (a resources) cpuUtilPercentage() string {
322323
if a.cpuAllocation == 0 {
323324
return "N/A"
324325
}
325326
return fmt.Sprintf("%.1f%%", a.cpuUtilization/a.cpuAllocation*100)
326327
}
327328

329+
//nolint:unused
328330
func (a resources) memUtilPercentage() string {
329331
if a.memAllocation == 0 {
330332
return "N/A"

0 commit comments

Comments
 (0)