mirror of
https://github.com/onyx-and-iris/vbantxt.git
synced 2026-02-15 00:47:51 +00:00
migrate golangci config to version 2.
update golang-cl workflow
This commit is contained in:
parent
acac22f70e
commit
510d43ca33
13
.github/workflows/golang-ci.yml
vendored
13
.github/workflows/golang-ci.yml
vendored
@ -2,11 +2,11 @@ name: CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "main" ]
|
||||
branches: ['main']
|
||||
paths:
|
||||
- '**.go'
|
||||
pull_request:
|
||||
branches: [ "main" ]
|
||||
branches: ['main']
|
||||
paths:
|
||||
- '**.go'
|
||||
jobs:
|
||||
@ -23,7 +23,8 @@ jobs:
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: '1.24'
|
||||
- name: Install golangci-lint
|
||||
run: go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
|
||||
- name: Run golangci-lint
|
||||
run: golangci-lint run ./...
|
||||
- name: golangci-lint
|
||||
uses: golangci/golangci-lint-action@v9
|
||||
with:
|
||||
version: v2.6.0
|
||||
args: --config .golangci.yml
|
||||
|
||||
138
.golangci.yml
138
.golangci.yml
@ -1,54 +1,110 @@
|
||||
version: '2'
|
||||
|
||||
run:
|
||||
# timeout for analysis, e.g. 30s, 3m, default is 1m
|
||||
timeout: 3m
|
||||
# exclude test files
|
||||
tests: true
|
||||
go: '1.24'
|
||||
|
||||
linters:
|
||||
# Set to true runs only fast linters.
|
||||
# Good option for 'lint on save', pre-commit hook or CI.
|
||||
fast: true
|
||||
|
||||
disable-all: true
|
||||
|
||||
enable:
|
||||
- gosimple
|
||||
- govet
|
||||
- ineffassign
|
||||
- staticcheck
|
||||
- unused
|
||||
- gofmt
|
||||
- gofumpt
|
||||
- misspell
|
||||
- unparam
|
||||
- gosec
|
||||
- asciicheck
|
||||
- errname
|
||||
- gci
|
||||
- godot
|
||||
- goimports
|
||||
- revive
|
||||
# Default enabled linters
|
||||
- errcheck # Check for unchecked errors
|
||||
- govet # Go's built-in vetting tool
|
||||
- ineffassign # Detect ineffectual assignments
|
||||
- staticcheck # Advanced static analysis
|
||||
- unused # Check for unused code
|
||||
# Additional useful linters
|
||||
- misspell # Detect common misspellings
|
||||
- unparam # Check for unused function parameters
|
||||
- gosec # Security checks
|
||||
- asciicheck # Check for non-ASCII characters
|
||||
- errname # Check error variable names
|
||||
- godot # Check for missing periods in comments
|
||||
- revive # Highly configurable linter for style and correctness
|
||||
- gocritic # Detect code issues and suggest improvements
|
||||
- gocyclo # Check for cyclomatic complexity
|
||||
- dupl # Check for code duplication
|
||||
- predeclared # Check for shadowing of predeclared identifiers
|
||||
- copyloopvar # Check for loop variable capture in goroutines
|
||||
- errorlint # Check for common mistakes in error handling
|
||||
- goconst # Check for repeated strings that could be constants
|
||||
- gosmopolitan # Check for non-portable code
|
||||
|
||||
linters-settings:
|
||||
gofmt:
|
||||
rewrite-rules:
|
||||
- pattern: 'interface{}'
|
||||
replacement: 'any'
|
||||
- pattern: 'a[b:len(a)]'
|
||||
replacement: 'a[b:]'
|
||||
settings:
|
||||
misspell:
|
||||
locale: UK
|
||||
|
||||
misspell:
|
||||
locale: UK
|
||||
errcheck:
|
||||
check-type-assertions: true
|
||||
check-blank: true
|
||||
|
||||
errcheck:
|
||||
check-type-assertions: true
|
||||
revive:
|
||||
rules:
|
||||
# Code quality and style
|
||||
- name: exported
|
||||
arguments:
|
||||
- 'checkPrivateReceivers'
|
||||
- 'sayRepetitiveInsteadOfStutters'
|
||||
- name: var-naming
|
||||
- name: package-comments
|
||||
- name: range-val-in-closure
|
||||
- name: time-naming
|
||||
- name: context-as-argument
|
||||
- name: context-keys-type
|
||||
- name: dot-imports
|
||||
- name: empty-block
|
||||
- name: error-return
|
||||
- name: error-strings
|
||||
- name: error-naming
|
||||
- name: if-return
|
||||
- name: increment-decrement
|
||||
- name: indent-error-flow
|
||||
- name: receiver-naming
|
||||
- name: redefines-builtin-id
|
||||
- name: superfluous-else
|
||||
- name: unexported-return
|
||||
- name: unreachable-code
|
||||
- name: unused-parameter
|
||||
- name: var-declaration
|
||||
- name: blank-imports
|
||||
|
||||
# Disabled rules (can be enabled if needed)
|
||||
# - name: line-length-limit
|
||||
# arguments: [120]
|
||||
# - name: function-length
|
||||
# arguments: [50, 0]
|
||||
# - name: cyclomatic
|
||||
# arguments: [10]
|
||||
|
||||
gosec:
|
||||
excludes:
|
||||
- G104 # Duplicated errcheck checks
|
||||
- G115 # integer overflow conversion int -> uint32
|
||||
|
||||
# Formatters configuration
|
||||
formatters:
|
||||
# Enable specific formatters
|
||||
enable:
|
||||
- gofumpt # Stricter gofmt alternative
|
||||
- goimports # Organizes imports
|
||||
- gci # Controls import order/grouping
|
||||
- golines # Enforces line length
|
||||
|
||||
# Formatter-specific settings
|
||||
settings:
|
||||
goimports:
|
||||
local-prefixes: [github.com/onyx-and-iris/vbantxt]
|
||||
|
||||
gci:
|
||||
# Define import sections order
|
||||
sections:
|
||||
- standard # Standard library
|
||||
- default # Everything else
|
||||
- prefix(github.com/onyx-and-iris/vbantxt) # Current module
|
||||
|
||||
gofumpt:
|
||||
extra-rules: true # Enable additional formatting rules
|
||||
|
||||
issues:
|
||||
max-same-issues: 0
|
||||
max-issues-per-linter: 0
|
||||
exclude-use-default: false
|
||||
exclude:
|
||||
# gosec: Duplicated errcheck checks
|
||||
- G104
|
||||
# gosec: integer overflow conversion int -> uint32
|
||||
- G115
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user