diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index 6034bcbf..433f71b8 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -1,3 +1,5 @@ +--- +# This action is synced from https://github.com/prometheus/prometheus name: golangci-lint on: push: @@ -18,13 +20,13 @@ jobs: - name: Checkout repository uses: actions/checkout@v3 - name: install Go - uses: actions/setup-go@v2 + uses: actions/setup-go@v3 with: - go-version: 1.18.x + go-version: 1.20.x - name: Install snmp_exporter/generator dependencies run: sudo apt-get update && sudo apt-get -y install libsnmp-dev if: github.repository == 'prometheus/snmp_exporter' - name: Lint - uses: golangci/golangci-lint-action@v3.2.0 + uses: golangci/golangci-lint-action@v3.4.0 with: - version: v1.45.2 + version: v1.53.3 diff --git a/.golangci.yml b/.golangci.yml index fa108af5..8ae9b68e 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -26,3 +26,9 @@ linters-settings: - (net/http.ResponseWriter).Write # Never check for logger errors. - (github.com/go-kit/log.Logger).Log + revive: + rules: + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unused-parameter + - name: unused-parameter + severity: warning + disabled: true diff --git a/.yamllint b/.yamllint index 19552574..955a5a62 100644 --- a/.yamllint +++ b/.yamllint @@ -20,5 +20,4 @@ rules: config/testdata/section_key_dup.bad.yml line-length: disable truthy: - ignore: | - .github/workflows/*.yml + check-keys: false diff --git a/collector/collector_test.go b/collector/collector_test.go index 51382bd8..a1a009d8 100644 --- a/collector/collector_test.go +++ b/collector/collector_test.go @@ -531,9 +531,8 @@ func TestPduToSample(t *testing.T) { if c.shouldErr { errHappened = true continue - } else { - t.Fatalf("Error writing metric: %v", err) } + t.Fatalf("Error writing metric: %v", err) } got := strings.ReplaceAll(m.Desc().String()+" "+metric.String(), " ", " ") if _, ok := expected[got]; !ok { diff --git a/config/config.go b/config/config.go index e7004d88..0c15c41a 100644 --- a/config/config.go +++ b/config/config.go @@ -94,10 +94,7 @@ type Module struct { func (c *Module) UnmarshalYAML(unmarshal func(interface{}) error) error { *c = DefaultModule type plain Module - if err := unmarshal((*plain)(c)); err != nil { - return err - } - return nil + return unmarshal((*plain)(c)) } // ConfigureSNMP sets the various version and auth settings. @@ -286,10 +283,7 @@ type RegexpExtract struct { func (c *RegexpExtract) UnmarshalYAML(unmarshal func(interface{}) error) error { *c = DefaultRegexpExtract type plain RegexpExtract - if err := unmarshal((*plain)(c)); err != nil { - return err - } - return nil + return unmarshal((*plain)(c)) } // Regexp encapsulates a regexp.Regexp and makes it YAML marshalable.