[#4] Synchronize with frostfs-node repository

- gitlint removed
- golangci-lint modified
- gofumpt added
- go-staticcheck-repo-mod and go-mod-tidy added
- linters.mk added with linter configuration scenarios

Signed-off-by: George Bartolomey <george@bh4.ru>
This commit is contained in:
George Bartolomey 2024-07-12 16:58:19 +03:00
parent 3b9c32fc1d
commit fedaf59bb8
Signed by: george.bartolomey
GPG key ID: 35BC54839D73BFAD
4 changed files with 82 additions and 30 deletions

View file

@ -1,11 +0,0 @@
[general]
fail-without-commits=True
regex-style-search=True
contrib=CC1
[title-match-regex]
regex=^\[\#[0-9Xx]+\]\s
[ignore-by-title]
regex=^Release(.*)
ignore=title-match-regex

View file

@ -4,7 +4,7 @@
# options for analysis running # options for analysis running
run: run:
# timeout for analysis, e.g. 30s, 5m, default is 1m # timeout for analysis, e.g. 30s, 5m, default is 1m
timeout: 10m timeout: 20m
# include test files or not, default is true # include test files or not, default is true
tests: false tests: false
@ -31,18 +31,38 @@ linters-settings:
statements: 60 # default 40 statements: 60 # default 40
gocognit: gocognit:
min-complexity: 40 # default 30 min-complexity: 40 # default 30
importas:
no-unaliased: true
no-extra-aliases: false
alias:
pkg: git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object
alias: objectSDK
custom:
truecloudlab-linters:
path: bin/linters/external_linters.so
original-url: git.frostfs.info/TrueCloudLab/linters.git
settings:
noliteral:
target-methods : ["reportFlushError", "reportError"]
disable-packages: ["codes", "err", "res","exec"]
constants-package: "git.frostfs.info/TrueCloudLab/frostfs-node/internal/logs"
linters: linters:
enable: enable:
# mandatory linters # mandatory linters
- govet - govet
- revive - revive
# some default golangci-lint linters
- errcheck - errcheck
- gosimple - gosimple
- godot
- ineffassign - ineffassign
- staticcheck - staticcheck
- typecheck - typecheck
- unused - unused
# extra linters
- bidichk - bidichk
- durationcheck - durationcheck
- exhaustive - exhaustive
@ -50,15 +70,17 @@ linters:
- gofmt - gofmt
- goimports - goimports
- misspell - misspell
- whitespace
# extra linters
- godot
- predeclared - predeclared
- reassign - reassign
- whitespace
- containedctx - containedctx
- funlen - funlen
- gocognit - gocognit
- contextcheck - contextcheck
- importas
- truecloudlab-linters
- perfsprint
- testifylint
- protogetter
disable-all: true disable-all: true
fast: false fast: false

View file

@ -2,15 +2,8 @@ ci:
autofix_prs: false autofix_prs: false
repos: repos:
- repo: https://github.com/jorisroovers/gitlint
rev: v0.19.1
hooks:
- id: gitlint
stages: [commit-msg]
- id: gitlint-ci
- repo: https://github.com/pre-commit/pre-commit-hooks - repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0 rev: v4.5.0
hooks: hooks:
- id: check-added-large-files - id: check-added-large-files
- id: check-case-conflict - id: check-case-conflict
@ -23,23 +16,41 @@ repos:
- id: trailing-whitespace - id: trailing-whitespace
args: [--markdown-linebreak-ext=md] args: [--markdown-linebreak-ext=md]
- id: end-of-file-fixer - id: end-of-file-fixer
exclude: ".key$" exclude: "(.key|.svg)$"
- repo: https://github.com/shellcheck-py/shellcheck-py - repo: https://github.com/shellcheck-py/shellcheck-py
rev: v0.9.0.2 rev: v0.9.0.6
hooks: hooks:
- id: shellcheck - id: shellcheck
- repo: https://github.com/golangci/golangci-lint - repo: local
rev: v1.51.2
hooks: hooks:
- id: golangci-lint - id: make-lint
name: Run Make Lint
entry: make lint
language: system
pass_filenames: false
- repo: local - repo: local
hooks: hooks:
- id: go-unit-tests - id: go-unit-tests
name: go unit tests name: go unit tests
entry: make test entry: make test GOFLAGS=''
pass_filenames: false pass_filenames: false
types: [go] types: [go]
language: system language: system
- repo: local
hooks:
- id: gofumpt
name: gofumpt
entry: make fumpt
pass_filenames: false
types: [go]
language: system
- repo: https://github.com/TekWizely/pre-commit-golang
rev: v1.0.0-rc.1
hooks:
- id: go-staticcheck-repo-mod
- id: go-mod-tidy

30
linters.mk Normal file
View file

@ -0,0 +1,30 @@
GO_VERSION ?= 1.22
LINT_VERSION ?= 1.56.1
TRUECLOUDLAB_LINT_VERSION ?= 0.0.5
BIN ?= bin
OUTPUT_LINT_DIR ?= $(abspath $(BIN))/linters
LINT_DIR ?= $(OUTPUT_LINT_DIR)/golangci-lint-$(LINT_VERSION)-v$(TRUECLOUDLAB_LINT_VERSION)
TMP_DIR := .cache
.PHONY: lint fumpt
# Install linters
$(LINT_DIR):
@rm -rf $(OUTPUT_LINT_DIR)
@mkdir $(OUTPUT_LINT_DIR)
@mkdir -p $(TMP_DIR)
@rm -rf $(TMP_DIR)/linters
@git -c advice.detachedHead=false clone --branch v$(TRUECLOUDLAB_LINT_VERSION) https://git.frostfs.info/TrueCloudLab/linters.git $(TMP_DIR)/linters
@@make -C $(TMP_DIR)/linters lib CGO_ENABLED=1 OUT_DIR=$(OUTPUT_LINT_DIR)
@rm -rf $(TMP_DIR)/linters
@rmdir $(TMP_DIR) 2>/dev/null || true
@CGO_ENABLED=1 GOBIN=$(LINT_DIR) go install github.com/golangci/golangci-lint/cmd/golangci-lint@v$(LINT_VERSION)
# Run linters
lint: $(LINT_DIR)
$(LINT_DIR)/golangci-lint run
# Run gofumpt
fumpt:
@echo "⇒ Processing gofumpt check"
@gofumpt -l -w cmd/ pkg/ misc/