Skip to content

Commit

Permalink
feat: Adding strict lint (#3348)
Browse files Browse the repository at this point in the history
* feat: Adding strict lint

* fix: Bumping up to a medium instance
  • Loading branch information
yhakbar authored Aug 22, 2024
1 parent e56946c commit 98fcd4f
Show file tree
Hide file tree
Showing 4 changed files with 133 additions and 1 deletion.
21 changes: 21 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,19 @@ jobs:
- store_test_results:
path: logs

strict_lint:
resource_class: medium
<<: *defaults
steps:
- checkout
# The `run-strict-lint` target requires the `master` ref for comparison.
- run: git fetch
- run:
name: Run strict lint
command: |
make install-lint
make run-strict-lint
# Run TFLint tests separately as tflint during execution change working directory.
integration_test_tflint:
resource_class: large
Expand Down Expand Up @@ -567,6 +580,14 @@ workflows:
- AWS__PHXDEVOPS__circle-ci-test
- GCP__automated-tests
- GITHUB__PAT__gruntwork-ci
- strict_lint:
filters:
tags:
only: /^v.*/
context:
- AWS__PHXDEVOPS__circle-ci-test
- GCP__automated-tests
- GITHUB__PAT__gruntwork-ci
- integration_test_tofu_engine:
filters:
tags:
Expand Down
3 changes: 3 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ linters:
- performance
- unused
- test
# NOTE: These two are only in the strict lint right now
# - style
# - complexity

issues:
exclude-dirs:
Expand Down
105 changes: 105 additions & 0 deletions .strict.golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
run:
timeout: 2m
issues-exit-code: 1
tests: true
go: "1.22"
output:
formats:
- format: colored-line-number
print-issued-lines: true
print-linter-name: true

linters-settings:
staticcheck:
checks:
- all
- '-SA9005'
errcheck:
check-type-assertions: false
check-blank: false
exclude-functions:
- (*os.File).Close
errorlint:
errorf: true
asserts: true
comparison: true
gofmt:
simplify: true
dupl:
threshold: 120
goconst:
min-len: 3
min-occurrences: 5
revive:
min-confidence: 0.8
unused:
check-exported: false
unparam:
check-exported: false
nakedret:
max-func-lines: 20
gocritic:
disabled-checks:
- regexpMust
- rangeValCopy
- appendAssign
- hugeParam
enabled-tags:
- performance
disabled-tags:
- experimental

linters:
enable:
- dupl
- errcheck
- goconst
- gocritic
- goimports
- mnd
- gosimple
- govet
- ineffassign
- staticcheck
- misspell
- unconvert
- unused
- unparam
enable-all: false
disable:
- depguard
- gosec
- gocyclo
- exhaustruct
fast: false
mnd:
ignored-functions: strconv.Format*,os.*,strconv.Parse*,strings.SplitN,bytes.SplitN
presets:
- bugs
- performance
- unused
- test
# These two are only in the strict lint right now
- style
- complexity

issues:
exclude-dirs:
- docs
- _ci
- .github
- .circleci
exclude-rules:
- path: _test\.go
linters:
- dupl
- gocyclo
- lll
- errcheck
- wsl
- mnd
- unparam

exclude-use-default: false
max-issues-per-linter: 0
max-same-issues: 0
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,13 @@ install-lint:
run-lint:
golangci-lint run -v --timeout=5m ./...

run-strict-lint:
golangci-lint run -v --timeout=5m -c .strict.golangci.yml --new-from-rev origin/master ./...

install-mockery:
go install github.com/vektra/mockery/[email protected]

generate-mocks:
go generate ./...

.PHONY: help fmtcheck fmt install-fmt-hook clean install-lint run-lint
.PHONY: help fmtcheck fmt install-fmt-hook clean install-lint run-lint run-strict-lint

0 comments on commit 98fcd4f

Please sign in to comment.