You've already forked nginx_exporter
mirror of
https://github.com/nginxinc/nginx-prometheus-exporter.git
synced 2025-08-09 16:02:43 +03:00
cherry-pick: golangci-lint version and action update (#1046)
* Update golangci/golangci-lint-action action to v7 | datasource | package | from | to | | ----------- | ----------------------------- | ------ | ------ | | github-tags | golangci/golangci-lint-action | v6.5.2 | v7.0.0 | Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * Update dependency golangci/golangci-lint to v2 | datasource | package | from | to | | ----------- | ---------------------- | ------- | ------ | | github-tags | golangci/golangci-lint | v1.64.8 | v2.1.5 | Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * golangci-lint migrate result * Fix linting error - remove embedded field * Update the make target for lint --------- Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
This commit is contained in:
4
.github/workflows/lint.yml
vendored
4
.github/workflows/lint.yml
vendored
@@ -30,9 +30,9 @@ jobs:
|
|||||||
go-version-file: go.mod
|
go-version-file: go.mod
|
||||||
|
|
||||||
- name: Lint Go
|
- name: Lint Go
|
||||||
uses: golangci/golangci-lint-action@55c2c1448f86e01eaae002a5a3a9624417608d84 # v6.5.2
|
uses: golangci/golangci-lint-action@1481404843c368bc19ca9406f87d6e0fc97bdcfd # v7.0.0
|
||||||
with:
|
with:
|
||||||
version: v1.64.8 # renovate: datasource=github-tags depName=golangci/golangci-lint
|
version: v2.1.5 # renovate: datasource=github-tags depName=golangci/golangci-lint
|
||||||
|
|
||||||
actionlint:
|
actionlint:
|
||||||
name: Actionlint
|
name: Actionlint
|
||||||
|
119
.golangci.yml
119
.golangci.yml
@@ -1,47 +1,6 @@
|
|||||||
linters-settings:
|
version: "2"
|
||||||
misspell:
|
|
||||||
locale: US
|
|
||||||
revive:
|
|
||||||
ignore-generated-header: true
|
|
||||||
rules:
|
|
||||||
- name: blank-imports
|
|
||||||
- name: constant-logical-expr
|
|
||||||
- name: context-as-argument
|
|
||||||
- name: context-keys-type
|
|
||||||
- name: defer
|
|
||||||
- name: dot-imports
|
|
||||||
- name: duplicated-imports
|
|
||||||
- name: empty-block
|
|
||||||
- name: error-naming
|
|
||||||
- name: error-return
|
|
||||||
- name: error-strings
|
|
||||||
- name: errorf
|
|
||||||
- name: exported
|
|
||||||
- name: import-shadowing
|
|
||||||
- name: increment-decrement
|
|
||||||
- name: indent-error-flow
|
|
||||||
- name: package-comments
|
|
||||||
- name: range
|
|
||||||
- name: range-val-address
|
|
||||||
- name: range-val-in-closure
|
|
||||||
- name: receiver-naming
|
|
||||||
- name: redefines-builtin-id
|
|
||||||
- name: string-of-int
|
|
||||||
- name: superfluous-else
|
|
||||||
- name: time-naming
|
|
||||||
- name: unchecked-type-assertion
|
|
||||||
- name: unexported-return
|
|
||||||
- name: unnecessary-stmt
|
|
||||||
- name: unreachable-code
|
|
||||||
- name: unused-parameter
|
|
||||||
- name: var-declaration
|
|
||||||
- name: var-naming
|
|
||||||
govet:
|
|
||||||
enable-all: true
|
|
||||||
sloglint:
|
|
||||||
static-msg: true
|
|
||||||
key-naming-case: snake
|
|
||||||
linters:
|
linters:
|
||||||
|
default: none
|
||||||
enable:
|
enable:
|
||||||
- asasalint
|
- asasalint
|
||||||
- asciicheck
|
- asciicheck
|
||||||
@@ -61,11 +20,7 @@ linters:
|
|||||||
- gochecksumtype
|
- gochecksumtype
|
||||||
- gocritic
|
- gocritic
|
||||||
- godot
|
- godot
|
||||||
- gofmt
|
|
||||||
- gofumpt
|
|
||||||
- goimports
|
|
||||||
- gosec
|
- gosec
|
||||||
- gosimple
|
|
||||||
- gosmopolitan
|
- gosmopolitan
|
||||||
- govet
|
- govet
|
||||||
- ineffassign
|
- ineffassign
|
||||||
@@ -88,12 +43,9 @@ linters:
|
|||||||
- revive
|
- revive
|
||||||
- sloglint
|
- sloglint
|
||||||
- staticcheck
|
- staticcheck
|
||||||
- stylecheck
|
|
||||||
- tagalign
|
- tagalign
|
||||||
- tenv
|
|
||||||
- thelper
|
- thelper
|
||||||
- tparallel
|
- tparallel
|
||||||
- typecheck
|
|
||||||
- unconvert
|
- unconvert
|
||||||
- unparam
|
- unparam
|
||||||
- unused
|
- unused
|
||||||
@@ -101,9 +53,70 @@ linters:
|
|||||||
- wastedassign
|
- wastedassign
|
||||||
- whitespace
|
- whitespace
|
||||||
- wrapcheck
|
- wrapcheck
|
||||||
disable-all: true
|
settings:
|
||||||
|
govet:
|
||||||
|
enable-all: true
|
||||||
|
misspell:
|
||||||
|
locale: US
|
||||||
|
revive:
|
||||||
|
rules:
|
||||||
|
- name: blank-imports
|
||||||
|
- name: constant-logical-expr
|
||||||
|
- name: context-as-argument
|
||||||
|
- name: context-keys-type
|
||||||
|
- name: defer
|
||||||
|
- name: dot-imports
|
||||||
|
- name: duplicated-imports
|
||||||
|
- name: empty-block
|
||||||
|
- name: error-naming
|
||||||
|
- name: error-return
|
||||||
|
- name: error-strings
|
||||||
|
- name: errorf
|
||||||
|
- name: exported
|
||||||
|
- name: import-shadowing
|
||||||
|
- name: increment-decrement
|
||||||
|
- name: indent-error-flow
|
||||||
|
- name: package-comments
|
||||||
|
- name: range
|
||||||
|
- name: range-val-address
|
||||||
|
- name: range-val-in-closure
|
||||||
|
- name: receiver-naming
|
||||||
|
- name: redefines-builtin-id
|
||||||
|
- name: string-of-int
|
||||||
|
- name: superfluous-else
|
||||||
|
- name: time-naming
|
||||||
|
- name: unchecked-type-assertion
|
||||||
|
- name: unexported-return
|
||||||
|
- name: unnecessary-stmt
|
||||||
|
- name: unreachable-code
|
||||||
|
- name: unused-parameter
|
||||||
|
- name: var-declaration
|
||||||
|
- name: var-naming
|
||||||
|
sloglint:
|
||||||
|
static-msg: true
|
||||||
|
key-naming-case: snake
|
||||||
|
exclusions:
|
||||||
|
generated: lax
|
||||||
|
presets:
|
||||||
|
- comments
|
||||||
|
- common-false-positives
|
||||||
|
- legacy
|
||||||
|
- std-error-handling
|
||||||
|
paths:
|
||||||
|
- third_party$
|
||||||
|
- builtin$
|
||||||
|
- examples$
|
||||||
issues:
|
issues:
|
||||||
max-issues-per-linter: 0
|
max-issues-per-linter: 0
|
||||||
max-same-issues: 0
|
max-same-issues: 0
|
||||||
run:
|
formatters:
|
||||||
timeout: 5m
|
enable:
|
||||||
|
- gofmt
|
||||||
|
- gofumpt
|
||||||
|
- goimports
|
||||||
|
exclusions:
|
||||||
|
generated: lax
|
||||||
|
paths:
|
||||||
|
- third_party$
|
||||||
|
- builtin$
|
||||||
|
- examples$
|
||||||
|
@@ -26,7 +26,7 @@ repos:
|
|||||||
- id: fix-byte-order-marker
|
- id: fix-byte-order-marker
|
||||||
|
|
||||||
- repo: https://github.com/golangci/golangci-lint
|
- repo: https://github.com/golangci/golangci-lint
|
||||||
rev: v1.64.8
|
rev: v2.1.5
|
||||||
hooks:
|
hooks:
|
||||||
- id: golangci-lint-full
|
- id: golangci-lint-full
|
||||||
|
|
||||||
|
4
Makefile
4
Makefile
@@ -2,7 +2,7 @@ VERSION = 1.4.0
|
|||||||
TAG = $(VERSION)
|
TAG = $(VERSION)
|
||||||
PREFIX = nginx/nginx-prometheus-exporter
|
PREFIX = nginx/nginx-prometheus-exporter
|
||||||
# renovate: datasource=github-tags depName=golangci/golangci-lint
|
# renovate: datasource=github-tags depName=golangci/golangci-lint
|
||||||
GOLANGCI_LINT_VERSION = v1.64.8
|
GOLANGCI_LINT_VERSION = v2.1.5
|
||||||
|
|
||||||
.DEFAULT_GOAL:=nginx-prometheus-exporter
|
.DEFAULT_GOAL:=nginx-prometheus-exporter
|
||||||
|
|
||||||
@@ -21,7 +21,7 @@ build-goreleaser: ## Build all binaries using GoReleaser
|
|||||||
|
|
||||||
.PHONY: lint
|
.PHONY: lint
|
||||||
lint: ## Run linter
|
lint: ## Run linter
|
||||||
go run github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION) run --fix
|
go run github.com/golangci/golangci-lint/v2/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION) run --fix
|
||||||
|
|
||||||
.PHONY: test
|
.PHONY: test
|
||||||
test: ## Run tests
|
test: ## Run tests
|
||||||
|
@@ -292,7 +292,7 @@ func cloneRequest(req *http.Request) *http.Request {
|
|||||||
// addMissingEnvironmentFlags sets Envar on any flag which has
|
// addMissingEnvironmentFlags sets Envar on any flag which has
|
||||||
// the "web." prefix which doesn't already have an Envar set.
|
// the "web." prefix which doesn't already have an Envar set.
|
||||||
func addMissingEnvironmentFlags(ka *kingpin.Application) {
|
func addMissingEnvironmentFlags(ka *kingpin.Application) {
|
||||||
for _, f := range ka.Model().FlagGroupModel.Flags {
|
for _, f := range ka.Model().Flags {
|
||||||
if strings.HasPrefix(f.Name, "web.") && f.Envar == "" {
|
if strings.HasPrefix(f.Name, "web.") && f.Envar == "" {
|
||||||
retrievedFlag := ka.GetFlag(f.Name)
|
retrievedFlag := ka.GetFlag(f.Name)
|
||||||
if retrievedFlag != nil {
|
if retrievedFlag != nil {
|
||||||
|
@@ -130,7 +130,7 @@ func TestAddMissingEnvironmentFlags(t *testing.T) {
|
|||||||
// instead of checking the envar of each matching flag name
|
// instead of checking the envar of each matching flag name
|
||||||
for k, v := range expectedMatches {
|
for k, v := range expectedMatches {
|
||||||
matched := false
|
matched := false
|
||||||
for _, f := range kingpin.CommandLine.Model().FlagGroupModel.Flags {
|
for _, f := range kingpin.CommandLine.Model().Flags {
|
||||||
if f.Name == k && f.Envar == v {
|
if f.Name == k && f.Envar == v {
|
||||||
matched = true
|
matched = true
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user