Skip to content
This repository has been archived by the owner on Sep 7, 2024. It is now read-only.

feat: golangci-linter config file #28

Merged
merged 1 commit into from
Sep 1, 2023
Merged
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
4 changes: 2 additions & 2 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ jobs:
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: 1.19
go-version: '1.21.0'

- name: Checkout code
uses: actions/checkout@v3

- name: Installing golangci-lint
run: go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
run: go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.54.1

- name: Formatting and linting the project
run: make check
82 changes: 82 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
linters:
enable-all: true
disable:
- scopelint # deprecated
- maligned # deprecated
- nosnakecase # deprecated
- interfacer # deprecated
- deadcode # deprecated
- ifshort # deprecated
- golint # deprecated
- structcheck # deprecated
- varcheck # deprecated
- exhaustivestruct # deprecated
- varnamelen
- wrapcheck
- paralleltest
- interfacebloat
- depguard
- gochecknoglobals
- gomnd
- cyclop
- nestif
- gochecknoinits
- dupl
- goconst
- gocognit # Consider to enable it
- funlen # Consider to enable it
- forbidigo # Consider to enable it
- gci # Consider to enable it (add it to make fmt)
- godox # Consider to enable it (only show warning)
- gocritic # Consider to enable it
- wsl # Consider to enable it
- testpackage # Consider to enable it (??)
- containedctx # Consider to enable it
- contextcheck # Consider to enable it
- exhaustive # Consider to enable it
- exhaustruct # Consider to enable it
- goerr113 # Consider to enable it
- wastedassign # Consider to enable it
- nonamedreturns # Consider to enable it
- nlreturn # Consider to enable it
- ireturn # Consider to enable it (??)

linters-settings:
gosimple:
checks: ["all"]

govet:
enable-all: true
disable: fieldalignment
shadow:
strict: true

godox:
severity: warning

predeclared:
# Comma-separated list of predeclared identifiers to not report on.
# Default: ""
ignore: "len"
# Include method names and field names (i.e., qualified names) in checks.
# Default: false
q: true

tagliatelle:
# Check the struct tag name case.
case:
use-field-name: false
rules:
json: snake
yaml: snake

issues:
exclude-rules:
# disable funlen for all _test.go files
- path: _test.go
linters:
- funlen

- linters:
- govet
text: "shadow: declaration of \"err\" shadows"
28 changes: 8 additions & 20 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
PACKAGES=$(shell go list ./... | grep -v 'tests')

### Tools needed for development
devtools:
@echo "Installing devtools"
go install github.com/golangci/golangci-lint/cmd/[email protected]
go install mvdan.cc/gofumpt@latest

### Testing
unit_test:
go test $(PACKAGES)
Expand All @@ -9,26 +15,8 @@ test:

### Formatting, linting, and vetting
fmt:
gofmt -s -w .
gofumpt -l -w .
go mod tidy

check:
golangci-lint run \
--build-tags "${BUILD_TAG}" \
--timeout=20m0s \
--enable=gofmt \
--enable=unconvert \
--enable=unparam \
--enable=asciicheck \
--enable=misspell \
--enable=revive \
--enable=decorder \
--enable=reassign \
--enable=usestdlibvars \
--enable=nilerr \
--enable=gosec \
--enable=exportloopref \
--enable=whitespace \
--enable=goimports \
--enable=gocyclo \
--enable=lll
golangci-lint run --build-tags "${BUILD_TAG}" --timeout=20m0s
4 changes: 2 additions & 2 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func LoadFromFile(path string) *Config {
if err != nil {
log.Error("Can not decode the Config Yaml file", "error: ", err)
}
//TODO: validate config
//TODO: Log
// TODO: validate config
// TODO: Log
return config
}
6 changes: 4 additions & 2 deletions core/database/subSets.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package database

type SubSets map[string]SubSet
type SubSet []Element
type (
SubSets map[string]SubSet
SubSet []Element
)

func NewSubSets() SubSets {
return SubSets{}
Expand Down
Loading