Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor #75

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
168 changes: 163 additions & 5 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,167 @@
linters:
disable-all: true
# One can't use disable and disable-all. disable-all is preferred to avoid lint failing when golangci gets updated and linters are added.
# at the same time but it is nice to explicitly state which linters we do not want.
#disable:
#- containedctx # Context.Context within a struct a struct (as opposed to a func parameter) is nasty for many reasons, but actually sometimes useful.
#- contextcheck # Not that useful/false positives.
#- cyclop # Cyclo complexity already calculated by other linters.
#- depguard # We do not restrict imports.
#- dogsled # Could be nice in the future.
#- dupl # Could be nice in the future.
#- exhaustive # Not that useful/false positives.
#- exhaustruct # Not that useful/false positives.
#- forcetypeassert # We want a panic in situations when a type is asserted.
#- funlen # We really like long functions.
#- gci # Conflicts with other linters.
#- gochecknoglobals # We need globals.
#- gochecknoinits # We have a lot of those.
#- gocognit # Not that useful/false positives.
#- godox # Not that useful/false positives.
#- gomnd # The annoy is strong.
#- gomoddirectives # Not that useful/false positives.
#- interfacebloat # WE do bloaty interfaces.
#- inamedparam # Not that useful.
#- ireturn # Not that useful/false positives.
#- musttag # Dislikes our deps.
#- nakedret # Naked return good return.
#- nlreturn # Could be nice in the future.
#- nonamedreturns # Named return good return.
#- rowserrcheck # No SQL here.
#- sqlclosecheck # No SQL here.
#- testpackage # Could be nice in the future.
#- unparam # Not that useful/false positives.
#- varnamelen # Not that useful/false positives.
#- wrapcheck # Not that useful/false positives.
#- wsl # Not that useful/false positives.
#- zerologlint # No zerolog here.
enable:
- asasalint
- asciicheck
- bidichk
- bodyclose
- decorder
- dupword
- durationcheck
- errcheck
- errchkjson
- errname
- errorlint
- execinquery
- exportloopref
- forbidigo
- ginkgolinter
- gocheckcompilerdirectives
- gochecksumtype
- goconst
- gocritic
- gocyclo
- godot
- goerr113
- gofmt
- gofumpt
- goheader
- goimports
- gosmopolitan
- govet
- grouper
- importas
- ineffassign
- lll
- loggercheck
- maintidx
- makezero
- mirror
- misspell
- musttag
- nestif
- nilerr
- nilnil
disable:
- scopelint # deprecated
- exhaustive # was creating false positives left and right
presets:
- bugs
- noctx
- nolintlint
- nosprintfhostport
- paralleltest
- perfsprint
- prealloc
- predeclared
- promlinter
- protogetter
- reassign
- revive
- sloglint
- staticcheck
- stylecheck
- tagalign
- tagliatelle
- tenv
- testableexamples
- testifylint
- thelper
- tparallel
- typecheck
- unconvert
- unused
- usestdlibvars
- wastedassign
- whitespace
issues:
max-same-issues: 0
max-issues-per-linter: 0
exclude-rules:
# Integration tests MUST NOT run in parallel.
- path: '.*_test.go'
linters:
- goerr113
include:
- EXC0001 # Check errors returned by io.Closer.
- EXC0002 # Require docs on exported pkg.
- EXC0003 # Just don't name a test pkg `test`.
- EXC0004 # Unsafe pkg is scary.
- EXC0005 # No ineffectual breaks.
- EXC0006 # Unsafe pkg is scary.
#- EXC0007 # Launching a subprocess using variables is not that odd.
#- EXC0008 # Duplicated check.
#- EXC0009 # World readable files are actually not a CVE
#- EXC0010 # Reading a file with a non literal path is not a CVE either.
- EXC0011 # Docs.
- EXC0012 # Docs.
- EXC0013 # Docs.
- EXC0014 # Docs.
- EXC0015 # Docs.
run:
skip-files: [ "zz_generated.deepcopy.go$" ]
linters-settings:
goimports:
local-prefixes: github.com/mt-sre/devkube
importas:
no-unaliased: false
no-extra-aliases: true
alias:
- pkg: k8s\.io\/api\/([^\/]+)\/([^\/]+)
alias: $1$2
- pkg: k8s\.io\/apimachinery\/pkg\/([^\/]+)
alias: $1
- pkg: k8s\.io\/apimachinery\/pkg\/apis\/([^\/]+)\/([^\/]+)
alias: $1$2
- pkg: k8s\.io\/apiextensions-apiserver\/pkg\/apis\/([^\/]+)\/([^\/]+)
alias: $1$2
- pkg: github\.com\/openshift\/api\/([^\/]+)\/([^\/]+)
alias: $1$2
- pkg: k8s\.io\/apimachinery\/pkg\/api\/([^\/]+)
alias: apimachinery$1
- pkg: sigs\.k8s\.io\/controller-runtime
alias: ctrl
- pkg: github\.com\/google\/go-containerregistry\/pkg\/v1
alias: containerregistrypkgv1
- pkg: k8s\.io\/utils\/clock\/testing
alias: clocktesting
- pkg: k8s\.io\/apiserver\/pkg\/cel
alias: apiservercel
- pkg: k8s\.io\/apiserver\/pkg\/apis\/cel
alias: apiserverapiscel
- pkg: sigs\.k8s\.io\/kind\/pkg\/cluster
alias: kindcluster
- pkg: sigs\.k8s\.io\/kind\/pkg\/cmd
alias: kindcmd
- pkg: sigs\.k8s\.io\/kind\/pkg\/apis\/([^\/]+)\/([^\/]+)
alias: kind$1$2
44 changes: 15 additions & 29 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
exclude: |
(?x)(
(^vendor/)|
(.deepcopy.go$)|
(mage_output_file.go$)
(^.vscode/)|
(mage_output_file.go)|
(.deepcopy.go$)
)
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.4.0
rev: v4.5.0
hooks:
- id: check-added-large-files
- id: check-case-conflict
Expand All @@ -15,38 +16,23 @@ repos:
- id: check-symlinks
- id: detect-private-key
- id: end-of-file-fixer
exclude: ".test-fixtures\/.*"
- id: pretty-format-json
args:
- --autofix
- id: trailing-whitespace

- repo: https://github.com/dnephin/pre-commit-golang
rev: v0.3.5
hooks:
- id: go-fmt

- repo: local
hooks:
- id: goimports
name: goimports
entry: hack/ensure-and-run-goimports.sh
language: script
types: [go]
require_serial: true # mage does not like multiple parallel compiles

- id: golangci-lint
name: golangci-lint
entry: hack/ensure-and-run-golangci-lint.sh
language: script
pass_filenames: false
types: [go]
require_serial: true # mage does not like multiple parallel compiles

- id: go-mod-tidy
name: go-mod-tidy
entry: ./mage tidy
language: script
- id: lint
name: lint
entry: ./mage test:fixlint
language: system
exclude: ".*"
always_run: true
- id: code-gen
name: code-gen
entry: ./mage generate:all
language: system
exclude: ".*"
pass_filenames: false
always_run: true
require_serial: true # mage does not like multiple parallel compiles
158 changes: 0 additions & 158 deletions dev/build.go

This file was deleted.

Loading