-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0157ca7
commit e88e3ac
Showing
7 changed files
with
355 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
use flake |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,18 @@ | ||
# Copyright (c) 2024 by SPYDER. | ||
# | ||
# This software is proprietary information of SPYDER. | ||
# Unauthorized use, copying, modification, distribution, and/or | ||
# disclosure is strictly prohibited, except as provided under the terms | ||
# of the commercial license agreement you have entered into with | ||
# SPYDER. | ||
# | ||
# For more details, see the LICENSE file in the root directory of this | ||
# source code repository or contact SPYDER at [email protected]. | ||
|
||
run: | ||
# Timeout for analysis, e.g. 30s, 5m. | ||
# Default: 1m | ||
timeout: 3m | ||
skip-dirs: | ||
- testdata | ||
|
||
|
||
# This file contains only configs which differ from defaults. | ||
|
@@ -23,6 +32,7 @@ linters-settings: | |
# Such cases aren't reported by default. | ||
# Default: false | ||
check-type-assertions: true | ||
exclude-functions: [] | ||
|
||
exhaustive: | ||
# Program elements to check for exhaustiveness. | ||
|
@@ -60,7 +70,7 @@ linters-settings: | |
# Default: true | ||
skipRecvDeref: false | ||
|
||
gomnd: | ||
mnd: | ||
# List of function patterns to exclude from analysis. | ||
# Values always ignored: `time.Date`, | ||
# `strconv.FormatInt`, `strconv.FormatUint`, `strconv.FormatFloat`, | ||
|
@@ -153,15 +163,13 @@ linters-settings: | |
linters: | ||
disable-all: true | ||
enable: | ||
## enabled by default | ||
- errcheck # checking for unchecked errors, these unchecked errors can be critical bugs in some cases | ||
- gosimple # specializes in simplifying a code | ||
- govet # reports suspicious constructs, such as Printf calls whose arguments do not align with the format string | ||
- ineffassign # detects when assignments to existing variables are not used | ||
- staticcheck # is a go vet on steroids, applying a ton of static analysis checks | ||
- typecheck # like the front-end of a Go compiler, parses and type-checks Go code | ||
- unused # checks for unused constants, variables, functions and types | ||
## disabled by default | ||
- asasalint # checks for pass []any as any in variadic func(...any) | ||
- asciicheck # checks that your code does not contain non-ASCII identifiers | ||
- bidichk # checks for dangerous unicode character sequences | ||
|
@@ -170,8 +178,6 @@ linters: | |
- dupl # tool for code clone detection | ||
- durationcheck # checks for two durations multiplied together | ||
- errname # checks that sentinel errors are prefixed with the Err and error types are suffixed with the Error | ||
#- errorlint # finds code that will cause problems with the error wrapping scheme introduced in Go 1.13 | ||
- execinquery # checks query string in Query function which reads your Go src files and warning it finds | ||
- exhaustive # checks exhaustiveness of enum switch statements | ||
- exportloopref # checks for pointers to enclosing loop variables | ||
- forbidigo # forbids identifiers | ||
|
@@ -184,7 +190,7 @@ linters: | |
- gocyclo # computes and checks the cyclomatic complexity of functions | ||
- godot # checks if comments end in a period | ||
- goimports # in addition to fixing imports, goimports also formats your code in the same style as gofmt | ||
- gomnd # detects magic numbers | ||
- mnd # detects magic numbers | ||
- gomoddirectives # manages the use of 'replace', 'retract', and 'excludes' directives in go.mod | ||
- gomodguard # allow and block lists linter for direct Go module dependencies. This is different from depguard where there are different block types for example version constraints and module recommendations | ||
- goprintffuncname # checks that printf-like functions are named with f at the end | ||
|
@@ -209,66 +215,24 @@ linters: | |
- stylecheck # is a replacement for golint | ||
- tenv # detects using os.Setenv instead of t.Setenv since Go1.17 | ||
- testableexamples # checks if examples are testable (have an expected output) | ||
- testpackage # makes you use a separate _test package | ||
#- testpackage # makes you use a separate _test package | ||
- tparallel # detects inappropriate usage of t.Parallel() method in your Go test codes | ||
- unconvert # removes unnecessary type conversions | ||
- unparam # reports unused function parameters | ||
- usestdlibvars # detects the possibility to use variables/constants from the Go standard library | ||
- wastedassign # finds wasted assignment statements | ||
- whitespace # detects leading and trailing whitespace | ||
|
||
## you may want to enable | ||
#- decorder # checks declaration order and count of types, constants, variables and functions | ||
#- exhaustruct # checks if all structure fields are initialized | ||
#- gci # controls golang package import order and makes it always deterministic | ||
#- godox # detects FIXME, TODO and other comment keywords | ||
#- goheader # checks is file header matches to pattern | ||
#- interfacebloat # checks the number of methods inside an interface | ||
#- ireturn # accept interfaces, return concrete types | ||
#- prealloc # [premature optimization, but can be used in some cases] finds slice declarations that could potentially be preallocated | ||
#- varnamelen # [great idea, but too many false positives] checks that the length of a variable's name matches its scope | ||
#- wrapcheck # checks that errors returned from external packages are wrapped | ||
|
||
## disabled | ||
#- containedctx # detects struct contained context.Context field | ||
#- contextcheck # [too many false positives] checks the function whether use a non-inherited context | ||
#- depguard # [replaced by gomodguard] checks if package imports are in a list of acceptable packages | ||
#- dogsled # checks assignments with too many blank identifiers (e.g. x, _, _, _, := f()) | ||
#- dupword # [useless without config] checks for duplicate words in the source code | ||
#- errchkjson # [don't see profit + I'm against of omitting errors like in the first example https://github.com/breml/errchkjson] checks types passed to the json encoding functions. Reports unsupported types and optionally reports occasions, where the check for the returned error can be omitted | ||
#- forcetypeassert # [replaced by errcheck] finds forced type assertions | ||
#- goerr113 # [too strict] checks the errors handling expressions | ||
#- gofmt # [replaced by goimports] checks whether code was gofmt-ed | ||
#- gofumpt # [replaced by goimports, gofumports is not available yet] checks whether code was gofumpt-ed | ||
#- grouper # analyzes expression groups | ||
#- importas # enforces consistent import aliases | ||
#- maintidx # measures the maintainability index of each function | ||
#- misspell # [useless] finds commonly misspelled English words in comments | ||
#- nlreturn # [too strict and mostly code is not more readable] checks for a new line before return and branch statements to increase code clarity | ||
#- paralleltest # [too many false positives] detects missing usage of t.Parallel() method in your Go test | ||
#- tagliatelle # checks the struct tags | ||
#- thelper # detects golang test helpers without t.Helper() call and checks the consistency of test helpers | ||
#- wsl # [too strict and mostly code is not more readable] whitespace linter forces you to use empty lines | ||
|
||
## deprecated | ||
#- deadcode # [deprecated, replaced by unused] finds unused code | ||
#- exhaustivestruct # [deprecated, replaced by exhaustruct] checks if all struct's fields are initialized | ||
#- golint # [deprecated, replaced by revive] golint differs from gofmt. Gofmt reformats Go source code, whereas golint prints out style mistakes | ||
#- ifshort # [deprecated] checks that your code uses short syntax for if-statements whenever possible | ||
#- interfacer # [deprecated] suggests narrower interface types | ||
#- maligned # [deprecated, replaced by govet fieldalignment] detects Go structs that would take less memory if their fields were sorted | ||
#- nosnakecase # [deprecated, replaced by revive var-naming] detects snake case of variable naming and function name | ||
#- scopelint # [deprecated, replaced by exportloopref] checks for unpinned variables in go programs | ||
#- structcheck # [deprecated, replaced by unused] finds unused struct fields | ||
#- varcheck # [deprecated, replaced by unused] finds unused global variables and constants | ||
|
||
|
||
issues: | ||
# Maximum count of issues with the same text. | ||
# Set to 0 to disable. | ||
# Default: 3 | ||
max-same-issues: 50 | ||
|
||
exclude-dirs: | ||
- testdata | ||
|
||
|
||
exclude-rules: | ||
- source: "^//\\s*go:generate\\s" | ||
linters: [ lll ] | ||
|
@@ -287,7 +251,7 @@ issues: | |
- gosec | ||
- noctx | ||
- wrapcheck | ||
- gomnd | ||
- mnd | ||
- exportloopref | ||
- gocyclo | ||
- errcheck | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,35 @@ | ||
# Copyright (c) 2024 by SPYDER. | ||
# | ||
# This software is proprietary information of SPYDER. | ||
# Unauthorized use, copying, modification, distribution, and/or | ||
# disclosure is strictly prohibited, except as provided under the terms | ||
# of the commercial license agreement you have entered into with | ||
# SPYDER. | ||
# | ||
# For more details, see the LICENSE file in the root directory of this | ||
# source code repository or contact SPYDER at [email protected]. | ||
|
||
exclude: '^$' | ||
fail_fast: true | ||
repos: | ||
#- repo: https://github.com/Yelp/detect-secrets | ||
# rev: v1.2.0 | ||
# hooks: | ||
# - id: detect-secrets | ||
# name: Detect secrets | ||
# language: python | ||
# entry: detect-secrets-hook | ||
# args: ['--baseline', '.secrets.baseline'] | ||
- repo: https://github.com/golangci/golangci-lint | ||
rev: v1.52.2 | ||
hooks: | ||
- id: golangci-lint | ||
- repo: https://github.com/Bahjat/pre-commit-golang | ||
rev: v1.0.3 # pragma: allowlist secret | ||
hooks: | ||
- id: go-unit-tests | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.4.0 | ||
hooks: | ||
- id: check-json | ||
- id: check-added-large-files | ||
- id: pretty-format-json | ||
- id: check-merge-conflict | ||
- id: check-yaml | ||
- repo: https://github.com/igorshubovych/markdownlint-cli | ||
rev: v0.34.0 | ||
hooks: | ||
- id: markdownlint-fix | ||
- repo: https://github.com/koalaman/shellcheck-precommit | ||
rev: v0.9.0 | ||
hooks: | ||
- id: shellcheck | ||
- repo: https://github.com/Yelp/detect-secrets | ||
rev: v1.5.0 | ||
hooks: | ||
- id: detect-secrets | ||
name: Detect secrets | ||
language: python | ||
entry: detect-secrets-hook | ||
args: [ | ||
'--baseline', | ||
'.secrets.baseline', | ||
] | ||
- repo: https://github.com/sqlfluff/sqlfluff | ||
rev: 3.2.3 | ||
hooks: | ||
- id: sqlfluff-fix | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v5.0.0 | ||
hooks: | ||
- id: check-json | ||
- id: check-merge-conflict | ||
- id: check-yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
all: build tidy lint fmt test | ||
|
||
#------------------------------------------------------------------------- | ||
# Variables | ||
# ------------------------------------------------------------------------ | ||
env=CGO_ENABLED=1 | ||
|
||
test: lint | ||
CGO_ENABLED=1 go test -cover -failfast -race ./... | ||
|
||
fuzz: | ||
@fuzzTime=$${FUZZ_TIME:-10}; \ | ||
files=$$(grep -r --include='**_test.go' --files-with-matches 'func Fuzz' .); \ | ||
for file in $$files; do \ | ||
funcs=$$(grep -o 'func Fuzz\w*' $$file | sed 's/func //'); \ | ||
for func in $$funcs; do \ | ||
echo "Fuzzing $$func in $$file"; \ | ||
parentDir=$$(dirname $$file); \ | ||
go test $$parentDir -run=$$func -fuzz=$$func -fuzztime=$${fuzzTime}s; \ | ||
if [ $$? -ne 0 ]; then \ | ||
echo "Fuzzing $$func in $$file failed"; \ | ||
exit 1; \ | ||
fi; \ | ||
done; \ | ||
done | ||
|
||
bench: | ||
go test -bench=. -benchmem ./... | ||
|
||
lint: tidy | ||
golangci-lint run | ||
pre-commit run --all-files | ||
|
||
build: update tidy | ||
$(env) go build ./... | ||
|
||
release-dev: build-ci | ||
|
||
upgrade: | ||
pre-commit autoupdate | ||
go get -u ./... | ||
|
||
update: | ||
git submodule update --recursive | ||
|
||
fmt: | ||
gofmt -s -w . | ||
|
||
tidy: fmt | ||
go mod tidy | ||
|
||
clean: | ||
rm -rf dist | ||
rm -rf coverage | ||
|
||
#------------------------------------------------------------------------- | ||
# CI targets | ||
#------------------------------------------------------------------------- | ||
test-ci: tidy lint | ||
CGO_ENABLED=1 go test \ | ||
-cover \ | ||
-covermode=atomic \ | ||
-coverprofile=coverage.txt \ | ||
-failfast \ | ||
-race ./... | ||
make fuzz FUZZ_TIME=10 | ||
|
||
build-ci: test-ci | ||
$(env) go build ./... | ||
|
||
bench-ci: test-ci | ||
go test -bench=. ./... | tee output.txt | ||
|
||
release-ci: build-ci | ||
|
||
#------------------------------------------------------------------------- | ||
# Force targets | ||
#------------------------------------------------------------------------- | ||
|
||
FORCE: | ||
|
||
#------------------------------------------------------------------------- | ||
# Phony targets | ||
#------------------------------------------------------------------------- | ||
|
||
.PHONY: build test lint fuzz |
Oops, something went wrong.