Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: add linter #199

Merged
merged 1 commit into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,19 @@ jobs:
with:
name: code-coverage-report
path: cover.html

reviewdog:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: lint
uses: reviewdog/action-golangci-lint@v2
with:
go_version_file: go.mod
github_token: ${{ secrets.GITHUB_TOKEN }}
reporter: github-pr-review
level: error
filter_mode: nofilter
golangci_lint_flags: "--config=.golangci.yml"
fail_on_error: true
22 changes: 22 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
linters-settings:
govet:
enable:
- shadow

linters:
disable-all: true
enable:
- staticcheck
- gofmt
- govet
- gocritic
- unused
- errcheck
- gosimple
- typecheck
- misspell
- goimports
- gosec
- ineffassign
- unconvert
- unparam
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,8 @@
"shadow": true
}
},
"go.lintTool": "golangci-lint",
"go.lintFlags": [
"--fast"
],
}
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ test_view:
rm cover.out.tmp
go tool cover -func=cover.out
go tool cover -html=cover.out -o cover.html
lint:
golangci-lint run
lint_diff:
golangci-lint run $$(echo $(DIFF_FILE))
mockgen:
go generate ./...
shadow:
Expand Down
1 change: 1 addition & 0 deletions internal/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ func (a *App) getAction() func(c *cli.Context) error {
}

for _, bucket := range buckets {
//nolint:errcheck
a.BucketNames.Set(bucket)
}
}
Expand Down
1 change: 1 addition & 0 deletions internal/io/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ func GetCheckboxes(label string, opts []string) []string {
Options: opts,
PageSize: SelectionPageSize,
}
//nolint:errcheck
survey.AskOne(prompt, &res, survey.WithKeepFilter(true))

return res
Expand Down
1 change: 1 addition & 0 deletions pkg/client/retryer.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ func (r *Retryer) MaxAttempts() int {
func (r *Retryer) RetryDelay(int, error) (time.Duration, error) {
waitTime := 1
if r.delayTimeSec > 1 {
//nolint:gosec
waitTime += rand.IntN(r.delayTimeSec)
}
return time.Duration(waitTime) * time.Second, nil
Expand Down
2 changes: 2 additions & 0 deletions pkg/client/s3_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ func getTokenForListDirectoryBucketsInitialize(
) (
out middleware.InitializeOutput, metadata middleware.Metadata, err error,
) {
//nolint:gocritic
switch v := in.Parameters.(type) {
case *s3.ListDirectoryBucketsInput:
ctx = middleware.WithStackValue(ctx, tokenForListDirectoryBuckets{}, v.ContinuationToken)
Expand All @@ -35,6 +36,7 @@ func setTargetObjectsForDeleteObjectsInitialize(
) (
out middleware.InitializeOutput, metadata middleware.Metadata, err error,
) {
//nolint:gocritic
switch v := in.Parameters.(type) {
case *s3.DeleteObjectsInput:
ctx = middleware.WithStackValue(ctx, targetObjectsForDeleteObjects{}, v.Delete.Objects)
Expand Down
Loading