diff --git a/.gitleaks.toml b/.gitleaks.toml deleted file mode 100644 index b66bdee..0000000 --- a/.gitleaks.toml +++ /dev/null @@ -1,12 +0,0 @@ -[extend] - useDefault = true - -[allowlist] - description = "Allowlist false positives" - regexTarget = "match" - regexes = [ - # Mark CDP build secret_version as false positive since it does not contain a secret. - '''(?i)(?:secret_version:)(?:['|\"|\s]{0,5})([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})(?:['|\"|\n|\r|\s]{0,5}|$)''', - # Mark api-id or api_id or x-api-id as false positive since they are uuids that are used in OAS and stacksets to track apis. - '''(?i)(?:api[_-]id(?:['|\"|\s|:]{0,5}))(?:['|\"|\s]{0,5})([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})(?:['|\"|\n|\r|\s]{0,5}|$)''' - ] diff --git a/.golangci.yaml b/.golangci.yaml deleted file mode 100644 index 970bbcd..0000000 --- a/.golangci.yaml +++ /dev/null @@ -1,201 +0,0 @@ -run: - # Timeout for analysis, e.g. 30s, 5m. - # Default: 1m - timeout: 3m - -linters: {} - # Placeholder for dynamically enabled linters. - -issues: - # Maximum count of issues with the same text. - # Set to 0 to disable. - # Default: 3 (we recommend 10-20) - max-same-issues: 10 - - # Use default exclusions for common false positives as defined in - # https://golangci-lint.run/usage/false-positives/#default-exclusions - # Default: true (we use false to sync behavior with Codacy) - exclude-use-default: false - - # Defining manually exclusions that make sense. - exclude-rules: - # Exclude go:generate directives from line length checking. - - source: "^//\\s*go:generate\\s" - linters: [ lll, revive ] - # Exclude magic number in time setups and bit shifting. - - source: "[0-9]+ ?\\* ?time\\.|(<<|>>) ?[0-9]+|[0-9]+ ?(<<|>>)" - linters: [ gomnd ] - # Exclude certain standards from being applied in test. - - path: "_test\\.go" - linters: [ bodyclose, contextcheck, dupl, funlen, goconst, gosec, noctx, - goerr113, wrapcheck ] - - # Exclude error return value check because of too many false positives. - - text: 'Error return value of .((os\.)?std(out|err)\..*|.*Close|.*Flush|os\.Remove(All)?|.*print(f|ln)?|os\.(Un)?Setenv). is not checked' - linters: [ errcheck ] - # Exclude certain revive standards from being applied in tests. - - path: "_test\\.go" - text: "^(max-public-structs|function-length|cognitive-complexity):" - linters: [ revive ] - # Exclude dots in unfinished thoughts. - - source: "(noinspection|TODO)" - linters: [ godot ] - - -# This contains only configs which differ from defaults. For other configs see -# https://github.com/golangci/golangci-lint/blob/master/.golangci.reference.yml -linters-settings: - cyclop: - # The maximal code complexity to report. - # Default: 10 (we allow up to 20) - max-complexity: 20 - # The maximal average package complexity. - # If it's higher than 0.0 (float) the check is enabled - # Default: 0.0 (we recommend 10.0 as baseline) - package-average: 10.0 - - gocognit: - # Minimal code complexity to report. - # Default: 30 (we recommend 10-20) - min-complexity: 20 - - lll: - # Max line length, lines longer will be reported. '\t' is counted as 1 - # character by default, and can be changed with the tab-width option. - # Default: 120 (we recommend 80 but compromise at 100) - line-length: 100 - # Tab width in spaces. - # Default: 1 (go uses 4 for visualization) - tab-width: 4 - - nolintlint: - # Exclude following linters from requiring an explanation. - # Default: [] (but some lll does not need explanation) - allow-no-explanation: [ lll, wrapcheck ] - # Enable to require an explanation of nonzero length after each nolint - # directive. - # Default: false - require-explanation: true - # Enable to require nolint directives to mention the specific linter being - # suppressed. - # Default: false - require-specific: true - - govet: - # Enable all analyzers. - # Default: false - enable-all: true - # Disable analyzers by name. - # Run `go tool vet help` to see all analyzers. - # Default: [] - disable: - - fieldalignment # too strict - - shadow # too strict to always work around - - gosec: - # To specify a set of rules to explicitly exclude. - # Available rules: https://github.com/securego/gosec#available-rules - # Default: [] (issues are fixed) - excludes: [ G307 ] - - gocritic: - # Settings passed to gocritic. The settings key is the name of a supported - # gocritic checker. The list of supported checkers can be find in - # https://go-critic.github.io/overview. - settings: - captLocal: - # Whether to restrict checker to params only. - # Default: true - paramsOnly: false - underef: - # Whether to skip (*x).method() calls where x is a pointer receiver. - # Default: true - skipRecvDeref: false - - tenv: - # The option `all` will run the linter on the whole test files regardless - # of method signatures. Otherwise, only methods that take `*testing.T`, - # `*testing.B`, and `testing.TB` as arguments are checked. - # Default: false - all: true - - revive: - # Enable all available rules. - # Default: false - enable-all-rules: true - # When set to false, ignores files with "GENERATED" header, similar to golint. - # See https://github.com/mgechev/revive#available-rules for details. - # Default: false - ignore-generated-header: true - # Sets the default severity. - # See https://github.com/mgechev/revive#configuration - # Default: warning - severity: error - - rules: - # No need to enforce a file header. - - name: file-header - disabled: true - # Reports on each file in a package. - - name: package-comments - disabled: true - # Reports on comments not matching the name as first word. - - name: exported - disabled: true - # Ident error flow is buggy and throws false alerts. - - name: indent-error-flow - disabled: true - # No need to exclude import shadowing. - - name: import-shadowing - disabled: true - # Restricted alias naming conflicts with '.'-imports. - - name: import-alias-naming - disabled: true - # Exluding '.'-import makes test package separation unnecessary difficult. - - name: dot-imports - disabled: true - # Fails to exclude nolint directives from reporting. - - name: comment-spacings - disabled: true - # Fails to disable writers that actually cannot return errors. - - name: unhandled-error - disabled: true - # Fails to detect and exclude type safe usages of type assertions. - - name: unchecked-type-assertion - disabled: true - # Fails to restrict sufficiently in switches with numeric values. - - name: add-constant - disabled: true - # Rule prevents intentional usage of similar variable names. - - name: flag-parameter - disabled: true - # Rule prevents intentional usage of similar private method names. - - name: confusing-naming - disabled: true - - # Enables a more experienced cyclomatic complexity (we enabled a lot of - # rules to counter-act the complexity trap). - - name: cyclomatic - arguments: [20] - # Enables a more experienced cognitive complexity (we enabled a lot of - # rules to counter-act the complexity trap). - - name: cognitive-complexity - arguments: [20] - # Limit line-length to increase readability. - - name: line-length-limit - arguments: [100] - # We are a bit more relaxed with function length consistent with funlen. - - name: function-length - arguments: [40, 60] - # Limit arguments of functions to the maximum understandable value. - - name: argument-limit - arguments: [6] - # Limit results of functions to the maximum understandable value. - - name: function-result-limit - arguments: [4] - # Raise the limit a bit to allow more complex package models. - - name: max-public-structs - arguments: [8] - # I do not know what I'm doing here... - - name: banned-characters - arguments: ["Ω", "Σ", "σ"] diff --git a/Makefile b/Makefile index 2a7c29a..24c2f44 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,5 @@ SHELL := /bin/bash -GOBIN ?= $(shell go env GOPATH)/bin -GOMAKE ?= github.com/tkrop/go-make@latest -TARGETS := $(shell command -v go-make >/dev/null || \ - go install $(GOMAKE) && go-make targets) - - # Include custom variables to modify behavior. ifneq ("$(wildcard Makefile.vars)","") include Makefile.vars @@ -13,20 +7,15 @@ else $(warning warning: please customize variables in Makefile.vars) endif +GOBIN ?= $(shell go env GOPATH)/bin +GOMAKE ?= github.com/tkrop/go-make@v0.0.11 +TARGETS := $(shell command -v go-make >/dev/null || \ + go install $(GOMAKE) && go-make targets) -# Include standard targets from go-make providing group targets as well as -# single target targets. The group target is used to delegate the remaining -# request targets, while the single target can be used to define the -# precondition of custom target. -.PHONY: $(TARGETS) $(addprefix target/,$(TARGETS)) -$(eval $(lastwords $(MAKECMDGOALS)):;@:) -$(firstword $(MAKECMDGOALS)): - $(GOBIN)/go-make $(MAKEFLAGS) $(MAKECMDGOALS); -$(addprefix target/,$(TARGETS)): target/%: - $(GOBIN)/go-make $(MAKEFLAGS) $*; - +# Declare all targets phony to make them available for auto-completion. +.PHONY: $(TARGETS) -# Include custom targets to extend scripts. -ifneq ("$(wildcard Makefile.ext)","") - include Makefile.ext -endif +# Delegate all targets to go-make in one call. +# TODO: consider solution that does not delegate local goals. +$(firstword $(MAKECMDGOALS) all):: + $(GOBIN)/go-make $(MAKEFLAGS) $(MAKECMDGOALS); diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..8acdd82 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +0.0.1 diff --git a/go.mod b/go.mod index 3c86ae9..eda7192 100644 --- a/go.mod +++ b/go.mod @@ -2,14 +2,14 @@ module github.com/tkrop/go-testing go 1.21 -toolchain go1.21.0 +toolchain go1.21.5 require ( github.com/golang/mock v1.6.0 github.com/h2non/gock v1.2.0 github.com/huandu/go-clone v1.6.0 github.com/stretchr/testify v1.8.4 - golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb + golang.org/x/exp v0.0.0-20231219180239-dc181d75b848 golang.org/x/text v0.13.0 golang.org/x/tools v0.16.1 ) diff --git a/go.sum b/go.sum index c6e461d..ac43f78 100644 --- a/go.sum +++ b/go.sum @@ -33,8 +33,8 @@ github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXl github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb h1:c0vyKkb6yr3KR7jEfJaOSv4lG7xPkbN6r52aJz1d8a8= -golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI= +golang.org/x/exp v0.0.0-20231219180239-dc181d75b848 h1:+iq7lrkxmFNBM7xx+Rae2W6uyPfhPeDWD+n+JgppptE= +golang.org/x/exp v0.0.0-20231219180239-dc181d75b848/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0= golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=