-
Notifications
You must be signed in to change notification settings - Fork 781
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(ci): add golangci-lint (#1774)
* chore(ci): add golangci-lint * add depguard Co-authored-by: Ronald <[email protected]> * remove exclude rules Co-authored-by: Ronald <[email protected]> * add gomodguard + depguard settings Co-authored-by: Ronald <[email protected]> * Align setup-go GHA version Co-authored-by: Ronald <[email protected]> * fix depguard v2 config --------- Co-authored-by: Ronald <[email protected]>
- Loading branch information
1 parent
2d446f0
commit a0c9082
Showing
2 changed files
with
114 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
name: lint | ||
|
||
on: | ||
pull_request: | ||
|
||
jobs: | ||
run-linters: | ||
name: Run linters | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0 | ||
with: | ||
go-version-file: 'go.mod' | ||
|
||
- name: Run linters | ||
uses: golangci/golangci-lint-action@639cd343e1d3b897ff35927a75193d57cfcba299 # v3.6.0 | ||
with: | ||
version: latest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
# Copyright (c) HashiCorp, Inc. | ||
# SPDX-License-Identifier: MPL-2.0 | ||
|
||
linters: | ||
disable-all: true | ||
enable: | ||
- gofmt | ||
- govet | ||
- unconvert | ||
- staticcheck | ||
- ineffassign | ||
- unparam | ||
- forbidigo | ||
- gomodguard | ||
- gosimple | ||
- depguard | ||
|
||
issues: | ||
# Disable the default exclude list so that all excludes are explicitly | ||
# defined in this file. | ||
exclude-use-default: false | ||
|
||
|
||
linters-settings: | ||
govet: | ||
check-shadowing: true | ||
enable-all: true | ||
disable: | ||
- fieldalignment | ||
- nilness | ||
- shadow | ||
- unusedwrite | ||
forbidigo: | ||
# Forbid the following identifiers (list of regexp). | ||
forbid: | ||
- '\bioutil\b(# Use io and os packages instead of ioutil)?' | ||
- '\brequire\.New\b(# Use package-level functions with explicit TestingT)?' | ||
- '\bassert\.New\b(# Use package-level functions with explicit TestingT)?' | ||
# Exclude godoc examples from forbidigo checks. | ||
# Default: true | ||
exclude_godoc_examples: false | ||
gofmt: | ||
simplify: true | ||
gomodguard: | ||
blocked: | ||
# List of blocked modules. | ||
modules: | ||
# Blocked module. | ||
- github.com/hashicorp/go-msgpack: | ||
recommendations: | ||
- github.com/hashicorp/consul-net-rpc/go-msgpack | ||
- github.com/golang/protobuf: | ||
recommendations: | ||
- google.golang.org/protobuf | ||
depguard: | ||
rules: | ||
main: | ||
# List of file globs that will match this list of settings to compare against. | ||
# Default: $all | ||
files: | ||
- $all | ||
# List of allowed packages. | ||
allow: | ||
- $gostd | ||
- github.com/BurntSushi/toml | ||
- github.com/Masterminds/sprig/v3 | ||
- github.com/davecgh/go-spew/spew | ||
- github.com/hashicorp/consul-template | ||
- github.com/hashicorp/consul/api | ||
- github.com/hashicorp/consul/sdk/testutil | ||
- github.com/hashicorp/go-gatedio | ||
- github.com/hashicorp/go-hclog | ||
- github.com/hashicorp/go-multierror | ||
- github.com/hashicorp/go-rootcerts | ||
- github.com/hashicorp/go-sockaddr/template | ||
- github.com/hashicorp/go-syslog | ||
- github.com/hashicorp/hcl | ||
- github.com/hashicorp/logutils | ||
- github.com/hashicorp/nomad/api | ||
- github.com/hashicorp/vault/api | ||
- github.com/imdario/mergo | ||
- github.com/mitchellh/go-homedir | ||
- github.com/mitchellh/hashstructure | ||
- github.com/mitchellh/mapstructure | ||
- github.com/pkg/errors | ||
- github.com/stretchr/testify/assert | ||
- github.com/stretchr/testify/require | ||
|
||
run: | ||
timeout: 10m | ||
concurrency: 4 | ||
skip-dirs-use-default: false |