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 #225

Merged
merged 5 commits 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 @@ -17,4 +17,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/action/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ func CreateFunctionList(input *CreateFunctionListInput) ([][]string, error) {
}

go func() {
//nolint:errcheck
eg.Wait()
close(functionCh)
}()
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, bool) {
Options: opts,
PageSize: CheckboxesPageSize,
}
//nolint:errcheck
survey.AskOne(prompt, &checkboxes, survey.WithKeepFilter(true))

if len(checkboxes) == 0 {
Expand Down
4 changes: 3 additions & 1 deletion internal/io/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ func outputAsCSV(header []string, data [][]string, csvOutputFilePath string) err
outputData = append(outputData, header)
outputData = append(outputData, data...)

w.WriteAll(outputData)
if err := w.WriteAll(outputData); err != nil {
return err
}

if err := w.Error(); err != nil {
return err
Expand Down
12 changes: 6 additions & 6 deletions pkg/client/lambda.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,13 @@ func (c *Lambda) compareActualVersion(first string, second string) (hasFinished
secondIntegers := second
secondDecimals := ""

if i := strings.Index(first, "."); i >= 0 {
firstIntegers = first[:i]
firstDecimals = first[i+1:]
if before, after, ok := strings.Cut(first, "."); ok {
firstIntegers = before
firstDecimals = after
}
if i := strings.Index(second, "."); i >= 0 {
secondIntegers = second[:i]
secondDecimals = second[i+1:]
if before, after, ok := strings.Cut(second, "."); ok {
secondIntegers = before
secondDecimals = after
}

if firstIntegers != secondIntegers {
Expand Down
1 change: 1 addition & 0 deletions pkg/client/lambda_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ func getNextMarkerForInitialize(
) (
out middleware.InitializeOutput, metadata middleware.Metadata, err error,
) {
//nolint:gocritic
switch v := in.Parameters.(type) {
case *lambda.ListFunctionsInput:
ctx = middleware.WithStackValue(ctx, markerKey{}, v.Marker)
Expand Down
Loading