Browse Source

ci: update linter

Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
pull/4277/head
Mark Sagi-Kazar 7 months ago
parent
commit
26accba6b1
No known key found for this signature in database
GPG Key ID: 31AB0439F4C5C90E
  1. 3
      .editorconfig
  2. 124
      .golangci.yaml
  3. 97
      .golangci.yml
  4. 6
      Makefile
  5. 2
      connector/atlassiancrowd/atlassiancrowd_test.go
  6. 5
      flake.nix
  7. 2
      storage/ent/mysql.go
  8. 2
      storage/sql/config.go

3
.editorconfig

@ -19,3 +19,6 @@ indent_style = tab
[{config.yaml.dist,config.dev.yaml}]
indent_size = 2
[.golangci.yaml]
indent_size = 2

124
.golangci.yaml

@ -0,0 +1,124 @@
version: "2"
run:
timeout: 5m
linters:
disable:
- staticcheck
- errcheck
enable:
- depguard
- dogsled
- exhaustive
- gochecknoinits
# - gocritic
- goprintffuncname
- govet
- ineffassign
- misspell
- nakedret
- nolintlint
- prealloc
# - revive
# - sqlclosecheck
# - staticcheck
- unconvert
- unused
- whitespace
# Disable temporarily until everything works with Go 1.20
# - bodyclose
# - rowserrcheck
# - tparallel
# - unparam
# Disable temporarily until the following issue is resolved: https://github.com/golangci/golangci-lint/issues/3086
# - sqlclosecheck
# TODO: fix linter errors before enabling
# - exhaustivestruct
# - gochecknoglobals
# - errorlint
# - gocognit
# - godot
# - nlreturn
# - noctx
# - revive
# - wrapcheck
# TODO: fix linter errors before enabling (from original config)
# - dupl
# - errcheck
# - goconst
# - gocyclo
# - gosec
# - lll
# - scopelint
# unused
# - goheader
# - gomodguard
# don't enable:
# - asciicheck
# - funlen
# - godox
# - goerr113
# - gomnd
# - interfacer
# - maligned
# - nestif
# - testpackage
# - wsl
exclusions:
rules:
- linters:
- errcheck
- noctx
path: _test.go
presets:
- comments
- std-error-handling
settings:
misspell:
locale: US
nolintlint:
allow-unused: false # report any unused nolint directives
require-specific: false # don't require nolint directives to be specific about which linter is being skipped
gocritic:
# Enable multiple checks by tags. See "Tags" section in https://github.com/go-critic/go-critic#usage.
enabled-tags:
- diagnostic
- experimental
- opinionated
- style
disabled-checks:
- importShadow
- unnamedResult
depguard:
rules:
deprecated:
deny:
- pkg: "io/ioutil"
desc: "The 'io/ioutil' package is deprecated. Use corresponding 'os' or 'io' functions instead."
formatters:
enable:
- gci
- gofmt
- gofumpt
- goimports
# - golines
settings:
gci:
sections:
- standard
- default
- localmodule
# issues:
# exclude-dirs:
# - storage/ent/db # generated ent code

97
.golangci.yml

@ -1,97 +0,0 @@
run:
timeout: 4m
linters-settings:
depguard:
rules:
deprecated:
deny:
- pkg: "io/ioutil"
desc: "The 'io/ioutil' package is deprecated. Use corresponding 'os' or 'io' functions instead."
gci:
sections:
- standard
- default
- prefix(github.com/dexidp/dex)
goimports:
local-prefixes: github.com/dexidp/dex
linters:
disable-all: true
enable:
- depguard
- dogsled
- exhaustive
- gci
- gochecknoinits
- gocritic
- gofmt
- gofumpt
- goimports
- goprintffuncname
- gosimple
- govet
- ineffassign
- misspell
- nakedret
- nolintlint
- prealloc
# - revive
# - sqlclosecheck
- staticcheck
- stylecheck
- unconvert
- unused
- whitespace
# Disable temporarily until everything works with Go 1.20
# - bodyclose
# - rowserrcheck
# - tparallel
# - unparam
# Disable temporarily until everything works with Go 1.18
- typecheck
# Disable temporarily until the following issue is resolved: https://github.com/golangci/golangci-lint/issues/3086
# - sqlclosecheck
# TODO: fix linter errors before enabling
# - exhaustivestruct
# - gochecknoglobals
# - errorlint
# - gocognit
# - godot
# - nlreturn
# - noctx
# - revive
# - wrapcheck
# TODO: fix linter errors before enabling (from original config)
# - dupl
# - errcheck
# - goconst
# - gocyclo
# - gosec
# - lll
# - scopelint
# unused
# - goheader
# - gomodguard
# don't enable:
# - asciicheck
# - funlen
# - godox
# - goerr113
# - gomnd
# - interfacer
# - maligned
# - nestif
# - testpackage
# - wsl
issues:
exclude-dirs:
- storage/ent/db # generated ent code

6
Makefile

@ -17,7 +17,7 @@ export GOBIN=$(PWD)/bin
LD_FLAGS="-w -X main.version=$(VERSION)"
# Dependency versions
GOLANGCI_VERSION = 1.64.5
GOLANGCI_VERSION = 2.4.0
GOTESTSUM_VERSION ?= 1.12.0
PROTOC_VERSION = 29.3
@ -132,7 +132,7 @@ testrace: ## Test go code and check for possible race conditions.
testall: testrace ## Run all tests for go code.
.PHONY: lint lint-fix
.PHONY: lint
lint: ## Run linter.
@golangci-lint version
@golangci-lint run
@ -140,7 +140,7 @@ lint: ## Run linter.
.PHONY: fix
fix: ## Fix lint violations.
@golangci-lint version
@golangci-lint run --fix
@golangci-lint fmt
docker-compose.override.yaml:
cp docker-compose.override.yaml.dist docker-compose.override.yaml

2
connector/atlassiancrowd/atlassiancrowd_test.go

@ -113,7 +113,7 @@ func TestIdentityFromCrowdUser(t *testing.T) {
expectEquals(t, user.Name, "testuser")
expectEquals(t, user.Email, "testuser@example.com")
// Test unconfigured behaviour
// Test unconfigured behavior
i := c.identityFromCrowdUser(user)
expectEquals(t, i.UserID, "12345")
expectEquals(t, i.Username, "testuser")

5
flake.nix

@ -34,7 +34,10 @@
packages = with pkgs; [
gnumake
golangci-lint
# golangci-lint
(golangci-lint.override (o: {
buildGoModule = pkgs.buildGo125Module;
}))
gotestsum
protobuf
protoc-gen-go

2
storage/ent/mysql.go

@ -81,7 +81,7 @@ func (m *MySQL) driver() (*entSQL.Driver, error) {
}
if m.MaxIdleConns == 0 {
/* Override default behaviour to fix https://github.com/dexidp/dex/issues/1608 */
/* Override default behavior to fix https://github.com/dexidp/dex/issues/1608 */
drv.DB().SetMaxIdleConns(0)
} else {
drv.DB().SetMaxIdleConns(m.MaxIdleConns)

2
storage/sql/config.go

@ -272,7 +272,7 @@ func (s *MySQL) open(logger *slog.Logger) (*conn, error) {
}
if s.MaxIdleConns == 0 {
/*Override default behaviour to fix https://github.com/dexidp/dex/issues/1608*/
/*Override default behavior to fix https://github.com/dexidp/dex/issues/1608*/
db.SetMaxIdleConns(0)
} else {
db.SetMaxIdleConns(s.MaxIdleConns)

Loading…
Cancel
Save