aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/butuzov
diff options
context:
space:
mode:
authorTaras Madan <tarasmadan@google.com>2024-09-10 12:16:33 +0200
committerTaras Madan <tarasmadan@google.com>2024-09-10 14:05:26 +0000
commitc97c816133b42257d0bcf1ee4bd178bb2a7a2b9e (patch)
tree0bcbc2e540bbf8f62f6c17887cdd53b8c2cee637 /vendor/github.com/butuzov
parent54e657429ab892ad06c90cd7c1a4eb33ba93a3dc (diff)
vendor: update
Diffstat (limited to 'vendor/github.com/butuzov')
-rw-r--r--vendor/github.com/butuzov/mirror/.act2
-rw-r--r--vendor/github.com/butuzov/mirror/.goreleaser.yaml41
-rw-r--r--vendor/github.com/butuzov/mirror/MIRROR_FUNCS.md213
-rw-r--r--vendor/github.com/butuzov/mirror/Makefile135
-rw-r--r--vendor/github.com/butuzov/mirror/Taskfile.yml95
-rw-r--r--vendor/github.com/butuzov/mirror/checkers_bufio.go20
-rw-r--r--vendor/github.com/butuzov/mirror/checkers_bytes.go47
-rw-r--r--vendor/github.com/butuzov/mirror/checkers_httptest.go4
-rw-r--r--vendor/github.com/butuzov/mirror/checkers_maphash.go4
-rw-r--r--vendor/github.com/butuzov/mirror/checkers_os.go4
-rw-r--r--vendor/github.com/butuzov/mirror/checkers_regexp.go24
-rw-r--r--vendor/github.com/butuzov/mirror/checkers_strings.go49
-rw-r--r--vendor/github.com/butuzov/mirror/checkers_utf8.go20
-rw-r--r--vendor/github.com/butuzov/mirror/internal/checker/violation.go11
-rw-r--r--vendor/github.com/butuzov/mirror/readme.md62
15 files changed, 472 insertions, 259 deletions
diff --git a/vendor/github.com/butuzov/mirror/.act b/vendor/github.com/butuzov/mirror/.act
deleted file mode 100644
index 8182d703a..000000000
--- a/vendor/github.com/butuzov/mirror/.act
+++ /dev/null
@@ -1,2 +0,0 @@
---platform ubuntu-latest=butuzov/act-go:latest
---env DRY_RUN=1
diff --git a/vendor/github.com/butuzov/mirror/.goreleaser.yaml b/vendor/github.com/butuzov/mirror/.goreleaser.yaml
index 11749ed2b..fa91fa97e 100644
--- a/vendor/github.com/butuzov/mirror/.goreleaser.yaml
+++ b/vendor/github.com/butuzov/mirror/.goreleaser.yaml
@@ -5,33 +5,17 @@ builds:
- binary: mirror
env:
- CGO_ENABLED=0
+ main: ./cmd/mirror/
+ flags:
+ - -trimpath
+ ldflags: -s -w
goos:
- - darwin
- linux
+ - darwin
- windows
goarch:
- amd64
- - 386
- arm64
- - arm
- goarm:
- - 6
- ignore:
- - goos: windows
- goarm: 6
- - goos: windows
- goarch: arm64
- - goos: linux
- goarm: 6
- - goos: darwin
- goarch: 386
- main: ./cmd/mirror/
- flags:
- - -trimpath
- ldflags: -s -w
-
-checksum:
- name_template: 'checksums.txt'
changelog:
sort: asc
@@ -45,14 +29,15 @@ changelog:
- Merge pull request
- Merge branch
+
+checksum:
+ name_template: 'checksums.txt'
+
+
archives:
- - name_template: '{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}{{ if .Mips }}_{{ .Mips }}{{ end }}'
- replacements:
- darwin: darwin
- linux: linux
- windows: windows
- 386: i386
- amd64: x86_64
+ - format: tar.gz
+ name_template: >-
+ {{ .ProjectName }}_{{- tolower .Os }}_{{ .Arch }}
format_overrides:
- goos: windows
format: zip
diff --git a/vendor/github.com/butuzov/mirror/MIRROR_FUNCS.md b/vendor/github.com/butuzov/mirror/MIRROR_FUNCS.md
index 776816e51..3dcc01e96 100644
--- a/vendor/github.com/butuzov/mirror/MIRROR_FUNCS.md
+++ b/vendor/github.com/butuzov/mirror/MIRROR_FUNCS.md
@@ -1,150 +1,201 @@
-<table><tr>
-<td><code>func (b *bufio.Writer) WriteString(s string) (int, error)</code></td>
-<td>
- <code>func (b *bufio.Writer) Write(p []byte) (int, error)</code>
- <code>func (b *bufio.Writer) WriteRune(r rune) (int, error)</code>
-</td>
+<tr>
+<td><code>func (*bufio.Writer) Write([]byte) (int, error)</code></td>
+<td><code>func (*bufio.Writer) WriteString(string) (int, error)</code></td>
+</tr>
+<tr>
+<td><code>func (*bufio.Writer) WriteRune(rune) (int, error)</code></td>
+<td><code>func (*bufio.Writer) WriteString(string) (int, error)</code></td>
+</tr>
+<tr>
+<td><code>func (*bytes.Buffer) Write([]byte) (int, error)</code></td>
+<td><code>func (*bytes.Buffer) WriteString(string) (int, error)</code></td>
+</tr>
+<tr>
+<td><code>func (*bytes.Buffer) WriteRune(rune) (int, error)</code></td>
+<td><code>func (*bytes.Buffer) WriteString(string) (int, error)</code></td>
+</tr>
+<tr>
+<td><code>func bytes.Compare([]byte, []byte) int</code></td>
+<td><code>func strings.Compare(string, string) int</code></td>
+</tr>
+<tr>
+<td><code>func bytes.Contains([]byte, []byte) bool</code></td>
+<td><code>func strings.Contains(string, string) bool</code></td>
+</tr>
+<tr>
+<td><code>func bytes.ContainsAny([]byte, string) bool</code></td>
+<td><code>func strings.ContainsAny(string, string) bool</code></td>
+</tr>
+<tr>
+<td><code>func bytes.ContainsRune([]byte, byte) bool</code></td>
+<td><code>func strings.ContainsRune(string, byte) bool</code></td>
+</tr>
+<tr>
+<td><code>func bytes.Count([]byte, []byte) int</code></td>
+<td><code>func strings.Count(string, string) int</code></td>
+</tr>
+<tr>
+<td><code>func bytes.EqualFold([]byte, []byte) bool</code></td>
+<td><code>func strings.EqualFold(string, string) bool</code></td>
+</tr>
+<tr>
+<td><code>func bytes.HasPrefix([]byte, []byte) bool</code></td>
+<td><code>func strings.HasPrefix(string, string) bool</code></td>
+</tr>
+<tr>
+<td><code>func bytes.HasSuffix([]byte, []byte) bool</code></td>
+<td><code>func strings.HasSuffix(string, string) bool</code></td>
+</tr>
+<tr>
+<td><code>func bytes.Index([]byte, []byte) int</code></td>
+<td><code>func strings.Index(string, string) int</code></td>
+</tr>
+<tr>
+<td><code>func bytes.IndexAny([]byte, string) int</code></td>
+<td><code>func strings.IndexAny(string, string) int</code></td>
+</tr>
+<tr>
+<td><code>func bytes.IndexByte([]byte, byte) int</code></td>
+<td><code>func strings.IndexByte(string, byte) int</code></td>
+</tr>
+<tr>
+<td><code>func bytes.IndexFunc([]byte, func(rune) bool) int</code></td>
+<td><code>func strings.IndexFunc(string, func(rune) bool) int</code></td>
</tr>
<tr>
-<td><code>func (b *bytes.Buffer) WriteString(s string) (int, error)</code></td>
-<td>
- <code>func (b *bytes.Buffer) Write(p []byte) (int, error)</code>
- <code>func (b *bytes.Buffer) WriteRune(r rune) (int, error)</code>
- </td>
+<td><code>func bytes.IndexRune([]byte, rune) int</code></td>
+<td><code>func strings.IndexRune(string, rune) int</code></td>
</tr>
<tr>
-<td><code>func strings.Compare(a, b string) int</code></td>
-<td><code>func bytes.Compare(a, b []byte) int</code></td>
+<td><code>func bytes.LastIndex([]byte, []byte) int</code></td>
+<td><code>func strings.LastIndex(string, string) int</code></td>
</tr>
<tr>
-<td><code>func strings.Contains(s, substr string) bool</code></td>
-<td><code>func bytes.Contains(b, subslice []byte) bool</code></td>
+<td><code>func bytes.LastIndexAny([]byte, string) int</code></td>
+<td><code>func strings.LastIndexAny(string, string) int</code></td>
</tr>
<tr>
-<td><code>func strings.ContainsAny(s, chars string) bool</code></td>
-<td><code>func bytes.ContainsAny(b []byte, chars string) bool</code></td>
+<td><code>func bytes.LastIndexByte([]byte, byte) int</code></td>
+<td><code>func strings.LastIndexByte(string, byte) int</code></td>
</tr>
<tr>
-<td><code>func strings.ContainsRune(s string, r rune) bool</code></td>
-<td><code>func bytes.ContainsRune(b []byte, r rune) bool</code></td>
+<td><code>func bytes.LastIndexFunc([]byte, func(rune) bool) int</code></td>
+<td><code>func strings.LastIndexFunc(string, func(rune) bool) int</code></td>
</tr>
<tr>
-<td><code>func strings.Count(s, substr string) int</code></td>
-<td><code>func bytes.Count(s, sep []byte) int</code></td>
+<td><code>func bytes.NewBuffer([]byte) *bytes.Buffer</code></td>
+<td><code>func bytes.NewBufferString(string) *bytes.Buffer</code></td>
</tr>
<tr>
-<td><code>func strings.EqualFold(s, t string) bool</code></td>
-<td><code>func bytes.EqualFold(s, t []byte) bool</code></td>
+<td><code>func (*httptest.ResponseRecorder) Write([]byte) (int, error)</code></td>
+<td><code>func (*httptest.ResponseRecorder) WriteString(string) (int, error)</code></td>
</tr>
<tr>
-<td><code>func strings.HasPrefix(s, prefix string) bool</code></td>
-<td><code>func bytes.HasPrefix(s, prefix []byte) bool</code></td>
+<td><code>func (*maphash.Hash) Write([]byte) (int, error)</code></td>
+<td><code>func (*maphash.Hash) WriteString(string) (int, error)</code></td>
</tr>
<tr>
-<td><code>func strings.HasSuffix(s, suffix string) bool</code></td>
-<td><code>func bytes.HasSuffix(s, suffix []byte) bool</code></td>
+<td><code>func (*os.File) Write([]byte) (int, error)</code></td>
+<td><code>func (*os.File) WriteString(string) (int, error)</code></td>
</tr>
<tr>
-<td><code>func strings.Index(s, substr string) int</code></td>
-<td><code>func bytes.Index(s, sep []byte) int</code></td>
+<td><code>func regexp.Match(string, []byte) (bool, error)</code></td>
+<td><code>func regexp.MatchString(string, string) (bool, error)</code></td>
</tr>
<tr>
-<td><code>func strings.IndexAny(s, chars string) int</code></td>
-<td><code>func bytes.IndexAny(s []byte, chars string) int</code></td>
+<td><code>func (*regexp.Regexp) FindAllIndex([]byte, int) [][]int</code></td>
+<td><code>func (*regexp.Regexp) FindAllStringIndex(string, int) [][]int</code></td>
</tr>
<tr>
-<td><code>func strings.IndexByte(s string, c byte) int</code></td>
-<td><code>func bytes.IndexByte(b []byte, c byte) int</code></td>
+<td><code>func (*regexp.Regexp) FindAllSubmatchIndex([]byte, int) [][]int</code></td>
+<td><code>func (*regexp.Regexp) FindAllStringSubmatchIndex(string, int) [][]int</code></td>
</tr>
<tr>
-<td><code>func strings.IndexFunc(s string, f func(rune) bool) int</code></td>
-<td><code>func bytes.IndexFunc(s []byte, f func(r rune) bool) int</code></td>
+<td><code>func (*regexp.Regexp) FindIndex([]byte) []int</code></td>
+<td><code>func (*regexp.Regexp) FindStringIndex(string) []int</code></td>
</tr>
<tr>
-<td><code>func strings.IndexRune(s string, r rune) int</code></td>
-<td><code>func bytes.IndexRune(s []byte, r rune) int</code></td>
+<td><code>func (*regexp.Regexp) FindSubmatchIndex([]byte) []int</code></td>
+<td><code>func (*regexp.Regexp) FindStringSubmatchIndex(string) []int</code></td>
</tr>
<tr>
-<td><code>func strings.LastIndex(s, sep string) int</code></td>
-<td><code>func bytes.LastIndex(s, sep []byte) int</code></td>
+<td><code>func (*regexp.Regexp) Match([]byte) bool</code></td>
+<td><code>func (*regexp.Regexp) MatchString(string) bool</code></td>
</tr>
<tr>
-<td><code>func strings.LastIndexAny(s, chars string) int</code></td>
-<td><code>func bytes.LastIndexAny(s []byte, chars string) int</code></td>
+<td><code>func (*strings.Builder) Write([]byte) (int, error)</code></td>
+<td><code>func (*strings.Builder) WriteString(string) (int, error)</code></td>
</tr>
<tr>
-<td><code>func strings.LastIndexByte(s string, c byte) int</code></td>
-<td><code>func bytes.LastIndexByte(s []byte, c byte) int</code></td>
+<td><code>func (*strings.Builder) WriteRune(rune) (int, error)</code></td>
+<td><code>func (*strings.Builder) WriteString(string) (int, error)</code></td>
</tr>
<tr>
-<td><code>func strings.LastIndexFunc(s string, f func(rune) bool) int</code></td>
-<td><code>func bytes.LastIndexFunc(s []byte, f func(r rune) bool) int</code></td>
+<td><code>func strings.Compare(string) int</code></td>
+<td><code>func bytes.Compare([]byte) int</code></td>
</tr>
<tr>
-<td><code>func bytes.NewBufferString(s string) *bytes.Buffer</code></td>
-<td><code>func bytes.NewBuffer(buf []byte *bytes.Buffer</code></td>
+<td><code>func strings.Contains(string) bool</code></td>
+<td><code>func bytes.Contains([]byte) bool</code></td>
</tr>
<tr>
-<td><code>func (h *hash/maphash.Hash) WriteString(s string) (int, error)</code></td>
-<td><code>func (h *hash/maphash.Hash) Write(b []byte) (int, error)</code></td>
+<td><code>func strings.ContainsAny(string) bool</code></td>
+<td><code>func bytes.ContainsAny([]byte) bool</code></td>
</tr>
<tr>
-<td><code>func (rw *net/http/httptest.ResponseRecorder) WriteString(str string) (int, error)</code></td>
-<td><code>func (rw *net/http/httptest.ResponseRecorder) Write(buf []byte) (int, error)</code></td>
+<td><code>func strings.ContainsRune(string) bool</code></td>
+<td><code>func bytes.ContainsRune([]byte) bool</code></td>
</tr>
<tr>
-<td><code>func (f *os.File) WriteString(s string) (n int, err error)</code></td>
-<td><code>func (f *os.File) Write(b []byte) (n int, err error)</code></td>
+<td><code>func strings.EqualFold(string) bool</code></td>
+<td><code>func bytes.EqualFold([]byte) bool</code></td>
</tr>
<tr>
-<td><code>func regexp.MatchString(pattern string, s string) (bool, error)</code></td>
-<td><code>func regexp.Match(pattern string, b []byte) (bool, error)</code></td>
+<td><code>func strings.HasPrefix(string) bool</code></td>
+<td><code>func bytes.HasPrefix([]byte) bool</code></td>
</tr>
<tr>
-<td><code>func (re *regexp.Regexp) FindAllStringIndex(s string, n int) [][]int</code></td>
-<td><code>func (re *regexp.Regexp) FindAllIndex(b []byte, n int) [][]int</code></td>
+<td><code>func strings.HasSuffix(string) bool</code></td>
+<td><code>func bytes.HasSuffix([]byte) bool</code></td>
</tr>
<tr>
-<td><code>func (re *regexp.Regexp) FindAllStringSubmatch(s string, n int) [][]string</code></td>
-<td><code>func (re *regexp.Regexp) FindAllSubmatch(b []byte, n int) [][][]byte</code></td>
+<td><code>func strings.Index(string) int</code></td>
+<td><code>func bytes.Index([]byte) int</code></td>
</tr>
<tr>
-<td><code>func (re *regexp.Regexp) FindStringIndex(s string) (loc []int)</code></td>
-<td><code>func (re *regexp.Regexp) FindIndex(b []byte) (loc []int)</code></td>
+<td><code>func strings.IndexFunc(string, func(r rune) bool) int</code></td>
+<td><code>func bytes.IndexFunc([]byte, func(r rune) bool) int</code></td>
</tr>
<tr>
-<td><code>func (re *regexp.Regexp) FindStringSubmatchIndex(s string) []int</code></td>
-<td><code>func (re *regexp.Regexp) FindSubmatchIndex(b []byte) []int</code></td>
+<td><code>func strings.LastIndex(string) int</code></td>
+<td><code>func bytes.LastIndex([]byte) int</code></td>
</tr>
<tr>
-<td><code>func (re *regexp.Regexp) MatchString(s string) bool</code></td>
-<td><code>func (re *regexp.Regexp) Match(b []byte) bool</code></td>
+<td><code>func strings.LastIndexAny(string) int</code></td>
+<td><code>func bytes.LastIndexAny([]byte) int</code></td>
</tr>
<tr>
-<td><code>func (b *strings.Builder) WriteString(s string) error</code></td>
-<td>
- <code>func (b *strings.Builder) Write(p []byte) (int, error)</code>
- <code>func (b *strings.Builder) WriteRune(r rune) (int, error)</code>
- </td>
+<td><code>func strings.LastIndexFunc(string, func(r rune) bool) int</code></td>
+<td><code>func bytes.LastIndexFunc([]byte, func(r rune) bool) int</code></td>
</tr>
<tr>
-<td><code>func utf8.ValidString(s string) bool</code></td>
-<td><code>func utf8.Valid(p []byte) bool</code></td>
+<td><code>func utf8.DecodeLastRune([]byte) (rune, int)</code></td>
+<td><code>func utf8.DecodeLastRuneInString(string) (rune, int)</code></td>
</tr>
<tr>
-<td><code>func utf8.FullRuneInString(s string) bool</code></td>
-<td><code>func utf8.FullRune(p []byte) bool</code></td>
+<td><code>func utf8.DecodeRune([]byte) (rune, int)</code></td>
+<td><code>func utf8.DecodeRuneInString(string) (rune, int)</code></td>
</tr>
<tr>
-<td><code>func utf8.RuneCountInString(s string) (n int)</code></td>
-<td><code>func utf8.RuneCount(p []byte) int</code></td>
+<td><code>func utf8.FullRune([]byte) bool</code></td>
+<td><code>func utf8.FullRuneInString(string) bool</code></td>
</tr>
<tr>
-<td><code>func utf8.DecodeLastRuneInString(s string) (rune, int)</code></td>
-<td><code>func utf8.DecodeLastRune(p []byte) (rune, int)</code></td>
+<td><code>func utf8.RuneCount([]byte) int</code></td>
+<td><code>func utf8.RuneCountInString(string) int</code></td>
</tr>
<tr>
-<td><code>func utf8.DecodeRuneInString(s string) (une, int)</code></td>
-<td><code>func utf8.DecodeRune(p []byte) (rune, int)</code></td>
+<td><code>func utf8.Valid([]byte) bool</code></td>
+<td><code>func utf8.ValidString(string) bool</code></td>
</tr>
-</table>
+
diff --git a/vendor/github.com/butuzov/mirror/Makefile b/vendor/github.com/butuzov/mirror/Makefile
index b4b952b01..ac267208f 100644
--- a/vendor/github.com/butuzov/mirror/Makefile
+++ b/vendor/github.com/butuzov/mirror/Makefile
@@ -2,57 +2,130 @@
export PATH := $(PWD)/bin:$(PATH) # ./bin to $PATH
export SHELL := bash # Default Shell
-GOPKGS := $(shell go list ./... | grep -vE "(cmd|sandbox|testdata)" | tr -s '\n' ',' | sed 's/.\{1\}$$//' )
+define install_go_bin
+ @ which $(1) 2>&1 1>/dev/null || GOBIN=$(PWD)/bin go install $(2)
+endef
+.DEFAULT_GOAL := help
-build:
- @ go build -trimpath -ldflags="-w -s" \
- -o bin/mirror ./cmd/mirror/
+# Generate Artifacts ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+generate: ## Generate Assets
+ $(MAKE)
-build-race:
- @ go build -race -trimpath -ldflags="-w -s" \
- -o bin/mirror ./cmd/mirror/
+generate-tests: ## Generates Assets at testdata
+ go run ./cmd/internal/tests/ "$(PWD)/testdata"
-tests:
- go test -v -count=1 -race \
+generate-mirror-table: ## Generate Asset MIRROR_FUNCS.md
+ go run ./cmd/internal/mirror-table/ > "$(PWD)/MIRROR_FUNCS.md"
+
+
+# Build Artifacts ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+build: ## Build binary
+ @ go build -trimpath -ldflags="-w -s" -o bin/mirror ./cmd/mirror/
+
+build-race: ## Build binary with race flag
+ @ go build -race -trimpath -ldflags="-w -s" -o bin/mirror ./cmd/mirror/
+
+install: ## Installs binary
+ @ go install -trimpath -v -ldflags="-w -s" ./cmd/mirror
+
+# Run Tests ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+tests: ## Run Tests (Summary)
+ @ go test -v -count=1 -race \
-failfast \
-parallel=2 \
-timeout=1m \
-covermode=atomic \
- -coverpkg=$(GOPKGS) -coverprofile=coverage.cov ./...
+ -coverprofile=coverage.cov ./...
-tests-summary:
- go test -v -count=1 -race \
+tests-summary: ## Run Tests, but shows summary
+tests-summary: bin/tparse
+ @ go test -v -count=1 -race \
-failfast \
-parallel=2 \
-timeout=1m \
-covermode=atomic \
- -coverpkg=$(GOPKGS) -coverprofile=coverage.cov --json ./... | tparse -all
+ -coverprofile=coverage.cov --json ./... | tparse -all
-test-generate:
- go run ./cmd/internal/generate-tests/ "$(PWD)/testdata"
+# Linter ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+lints: ## Run golangci-lint
+lints: bin/golangci-lint
lints:
- golangci-lint run --no-config ./... -D deadcode --skip-dirs "^(cmd|sandbox|testdata)"
+ golangci-lint run --no-config ./... --skip-dirs "^(cmd|testdata)"
-cover:
- go tool cover -html=coverage.cov
+cover: ## Run Coverage
+ @ go tool cover -html=coverage.cov
+
+# Other ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+test-release: bin/goreleaser
+ goreleaser release --help
+ goreleaser release --skip=publish --skip=validate --clean
+
+# Install ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-install:
- go install -trimpath -v -ldflags="-w -s" \
- ./cmd/mirror
+bin/tparse: ## Installs tparse@v0.13.2 (if not exists)
+bin/tparse: INSTALL_URL=github.com/mfridman/tparse@v0.13.2
+bin/tparse:
+ $(call install_go_bin, tparse, $(INSTALL_URL))
-funcs:
- echo "" > "out/results.txt"
- go list std | grep -v "vendor" | grep -v "internal" | \
- xargs -I {} sh -c 'go doc -all {} > out/$(basename {}).txt'
+bin/golangci-lint: ## Installs golangci-lint@v1.55.2 (if not exists)
+bin/golangci-lint: INSTALL_URL=github.com/golangci/golangci-lint@v1.55.2
+bin/golangci-lint:
+ $(call install_go_bin, golangci-lint, $(INSTALL_URL))
+bin/goreleaser: ## Installs goreleaser@v1.24.0 (if not exists)
+bin/goreleaser: INSTALL_URL=github.com/goreleaser/goreleaser@v1.24.0
bin/goreleaser:
- @curl -Ls https://github.com/goreleaser/goreleaser/releases/download/v1.17.2/goreleaser_Darwin_all.tar.gz | tar -zOxf - goreleaser > ./bin/goreleaser
- chmod 0755 ./bin/goreleaser
+ $(call install_go_bin, goreleaser, $(INSTALL_URL))
-test-release: bin/goreleaser
- goreleaser release --help
- goreleaser release -f .goreleaser.yaml \
- --skip-validate --skip-publish --clean
+# Help ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+help: dep-gawk
+ @ echo "=============================================================================="
+ @ echo " Makefile: github.com/butuzov/mirror "
+ @ echo "=============================================================================="
+ @ cat $(MAKEFILE_LIST) | \
+ grep -E '^# ~~~ .*? [~]+$$|^[a-zA-Z0-9_-]+:.*?## .*$$' | \
+ gawk '{if ( $$1=="#" ) { \
+ match($$0, /^# ~~~ (.+?) [~]+$$/, a);\
+ {print "\n", a[1], ""}\
+ } else { \
+ match($$0, /^([a-zA-Z/_-]+):.*?## (.*)$$/, a); \
+ {printf " - \033[32m%-20s\033[0m %s\n", a[1], a[2]} \
+ }}'
+ @ echo ""
+
+
+# Helper Mehtods ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+dep-gawk:
+ @ if [ -z "$(shell command -v gawk)" ]; then \
+ if [ -x /usr/local/bin/brew ]; then $(MAKE) _brew_gawk_install; exit 0; fi; \
+ if [ -x /usr/bin/apt-get ]; then $(MAKE) _ubuntu_gawk_install; exit 0; fi; \
+ if [ -x /usr/bin/yum ]; then $(MAKE) _centos_gawk_install; exit 0; fi; \
+ if [ -x /sbin/apk ]; then $(MAKE) _alpine_gawk_install; exit 0; fi; \
+ echo "GNU Awk Required.";\
+ exit 1; \
+ fi
+
+_brew_gawk_install:
+ @ echo "Instaling gawk using brew... "
+ @ brew install gawk --quiet
+ @ echo "done"
+
+_ubuntu_gawk_install:
+ @ echo "Instaling gawk using apt-get... "
+ @ apt-get -q install gawk -y
+ @ echo "done"
+
+_alpine_gawk_install:
+ @ echo "Instaling gawk using yum... "
+ @ apk add --update --no-cache gawk
+ @ echo "done"
+
+_centos_gawk_install:
+ @ echo "Instaling gawk using yum... "
+ @ yum install -q -y gawk;
+ @ echo "done"
diff --git a/vendor/github.com/butuzov/mirror/Taskfile.yml b/vendor/github.com/butuzov/mirror/Taskfile.yml
index 26c9ba257..4bc7cfeda 100644
--- a/vendor/github.com/butuzov/mirror/Taskfile.yml
+++ b/vendor/github.com/butuzov/mirror/Taskfile.yml
@@ -1,28 +1,73 @@
version: '3'
tasks:
- default:
- sources:
- - "./**/*.go"
- method: timestamp
- cmds:
- - clear
- - make build
- - make build-race
- - task: lints
- # - make test-generate
- - task: tests
- - cmd: go run ./cmd/mirror/ --with-tests --with-debug ./sandbox
- ignore_error: true
-
- testcase: go test -v -failfast -count=1 -run "TestAll/{{ .Case }}" ./...
-
- tests:
- cmds:
- - cmd: make tests
- ignore_error: true
-
- lints:
- cmds:
- - cmd: make lints
- ignore_error: true
+ default: task --list-all
+
+ # Continues Development ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ watcher:
+ desc: watcher
+ sources:
+ - ./**/*.go
+ method: timestamp
+ cmds:
+ - task: lints
+ - task: test-summary
+ - task: build-race
+
+ # Generating assets ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ generate:
+ desc: Generate Assets
+ sources:
+ - ./checkers_*.go
+ - ./cmd/internal/**/*.go
+ method: timestamp
+ cmds:
+ - task generate-mirror-table
+ - task generate-tests
+
+ generate-mirror-table:
+ desc: Generates Assets at testdata
+ cmd: make generate-mirror-table
+
+ generate-tests:
+ desc: Generate Asset MIRROR_FUNCS.md
+ cmd: make generate-tests
+
+ # Run Tests ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ tests:
+ desc: Run Tests
+ cmd: make tests
+ ignore_error: true
+
+ test-summary:
+ desc: Run Tests (Summary)
+ cmd: make tests-summary
+ ignore_error: true
+
+ testcase: go test -v -failfast -count=1 -run "TestAll/{{ .Case }}" ./...
+
+ # Build Artifacts ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ build:
+ desc: Build binary
+ cmd: make build
+
+ build-race:
+ desc: Build binary with race flag
+ cmd: make build-race
+
+ install:
+ desc: Install binary
+ cmd: make install
+
+ # Linter ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ lints:
+ cmd: make lints
+
+ # Other
+ cover:
+ desc: Run Coverage
+ cmd: make cover
+
+ test-release:
+ desc: Testing Release
+ cmd: make test-release
diff --git a/vendor/github.com/butuzov/mirror/checkers_bufio.go b/vendor/github.com/butuzov/mirror/checkers_bufio.go
index 292ed269a..0985edad3 100644
--- a/vendor/github.com/butuzov/mirror/checkers_bufio.go
+++ b/vendor/github.com/butuzov/mirror/checkers_bufio.go
@@ -15,7 +15,7 @@ var BufioMethods = []checker.Violation{
Generate: &checker.Generate{
PreCondition: `b := bufio.Writer{}`,
Pattern: `Write($0)`,
- Returns: 2,
+ Returns: []string{"int", "error"},
},
},
{ // (*bufio.Writer).WriteString
@@ -30,7 +30,7 @@ var BufioMethods = []checker.Violation{
Generate: &checker.Generate{
PreCondition: `b := bufio.Writer{}`,
Pattern: `WriteString($0)`,
- Returns: 2,
+ Returns: []string{"int", "error"},
},
},
{ // (*bufio.Writer).WriteString -> (*bufio.Writer).WriteRune
@@ -42,15 +42,11 @@ var BufioMethods = []checker.Violation{
Args: []int{0},
ArgsType: checker.Rune,
AltCaller: "WriteRune",
+
+ Generate: &checker.Generate{
+ SkipGenerate: true,
+ Pattern: `WriteString($0)`,
+ Returns: []string{"int", "error"},
+ },
},
- // { // (*bufio.Writer).WriteString -> (*bufio.Writer).WriteByte
- // Targets: checker.Strings,
- // Type: checker.Method,
- // Package: "strings",
- // Struct: "Builder",
- // Caller: "WriteString",
- // Args: []int{0},
- // ArgsType: checker.Byte,
- // AltCaller: "WriteByte", // byte
- // },
}
diff --git a/vendor/github.com/butuzov/mirror/checkers_bytes.go b/vendor/github.com/butuzov/mirror/checkers_bytes.go
index c490a3784..b8819879c 100644
--- a/vendor/github.com/butuzov/mirror/checkers_bytes.go
+++ b/vendor/github.com/butuzov/mirror/checkers_bytes.go
@@ -14,7 +14,7 @@ var (
Generate: &checker.Generate{
Pattern: `NewBuffer($0)`,
- Returns: 1,
+ Returns: []string{"*bytes.Buffer"},
},
},
{ // bytes.NewBufferString
@@ -27,7 +27,7 @@ var (
Generate: &checker.Generate{
Pattern: `NewBufferString($0)`,
- Returns: 1,
+ Returns: []string{"*bytes.Buffer"},
},
},
{ // bytes.Compare:
@@ -41,7 +41,7 @@ var (
Generate: &checker.Generate{
Pattern: `Compare($0, $1)`,
- Returns: 1,
+ Returns: []string{"int"},
},
},
{ // bytes.Contains:
@@ -55,7 +55,7 @@ var (
Generate: &checker.Generate{
Pattern: `Contains($0, $1)`,
- Returns: 1,
+ Returns: []string{"bool"},
},
},
{ // bytes.ContainsAny
@@ -69,7 +69,7 @@ var (
Generate: &checker.Generate{
Pattern: `ContainsAny($0, "f")`,
- Returns: 1,
+ Returns: []string{"bool"},
},
},
{ // bytes.ContainsRune
@@ -83,7 +83,7 @@ var (
Generate: &checker.Generate{
Pattern: `ContainsRune($0, 'ф')`,
- Returns: 1,
+ Returns: []string{"bool"},
},
},
{ // bytes.Count
@@ -97,7 +97,7 @@ var (
Generate: &checker.Generate{
Pattern: `Count($0, $1)`,
- Returns: 1,
+ Returns: []string{"int"},
},
},
{ // bytes.EqualFold
@@ -111,7 +111,7 @@ var (
Generate: &checker.Generate{
Pattern: `EqualFold($0, $1)`,
- Returns: 1,
+ Returns: []string{"bool"},
},
},
@@ -126,7 +126,7 @@ var (
Generate: &checker.Generate{
Pattern: `HasPrefix($0, $1)`,
- Returns: 1,
+ Returns: []string{"bool"},
},
},
{ // bytes.HasSuffix
@@ -140,7 +140,7 @@ var (
Generate: &checker.Generate{
Pattern: `HasSuffix($0, $1)`,
- Returns: 1,
+ Returns: []string{"bool"},
},
},
{ // bytes.Index
@@ -154,7 +154,7 @@ var (
Generate: &checker.Generate{
Pattern: `Index($0, $1)`,
- Returns: 1,
+ Returns: []string{"int"},
},
},
{ // bytes.IndexAny
@@ -168,7 +168,7 @@ var (
Generate: &checker.Generate{
Pattern: `IndexAny($0, "f")`,
- Returns: 1,
+ Returns: []string{"int"},
},
},
{ // bytes.IndexByte
@@ -182,7 +182,7 @@ var (
Generate: &checker.Generate{
Pattern: `IndexByte($0, 'f')`,
- Returns: 1,
+ Returns: []string{"int"},
},
},
{ // bytes.IndexFunc
@@ -196,7 +196,7 @@ var (
Generate: &checker.Generate{
Pattern: `IndexFunc($0, func(rune) bool {return true })`,
- Returns: 1,
+ Returns: []string{"int"},
},
},
{ // bytes.IndexRune
@@ -210,7 +210,7 @@ var (
Generate: &checker.Generate{
Pattern: `IndexRune($0, rune('ф'))`,
- Returns: 1,
+ Returns: []string{"int"},
},
},
{ // bytes.LastIndex
@@ -224,7 +224,7 @@ var (
Generate: &checker.Generate{
Pattern: `LastIndex($0, $1)`,
- Returns: 1,
+ Returns: []string{"int"},
},
},
{ // bytes.LastIndexAny
@@ -238,7 +238,7 @@ var (
Generate: &checker.Generate{
Pattern: `LastIndexAny($0, "ф")`,
- Returns: 1,
+ Returns: []string{"int"},
},
},
{ // bytes.LastIndexByte
@@ -252,7 +252,7 @@ var (
Generate: &checker.Generate{
Pattern: `LastIndexByte($0, 'f')`,
- Returns: 1,
+ Returns: []string{"int"},
},
},
{ // bytes.LastIndexFunc
@@ -266,7 +266,7 @@ var (
Generate: &checker.Generate{
Pattern: `LastIndexFunc($0, func(rune) bool {return true })`,
- Returns: 1,
+ Returns: []string{"int"},
},
},
}
@@ -284,7 +284,7 @@ var (
Generate: &checker.Generate{
PreCondition: `bb := bytes.Buffer{}`,
Pattern: `Write($0)`,
- Returns: 2,
+ Returns: []string{"int", "error"},
},
},
{ // (*bytes.Buffer).WriteString
@@ -299,7 +299,7 @@ var (
Generate: &checker.Generate{
PreCondition: `bb := bytes.Buffer{}`,
Pattern: `WriteString($0)`,
- Returns: 2,
+ Returns: []string{"int", "error"},
},
},
{ // (*bytes.Buffer).WriteString -> (*bytes.Buffer).WriteRune
@@ -311,6 +311,11 @@ var (
Args: []int{0},
ArgsType: checker.Rune,
AltCaller: "WriteRune",
+ Generate: &checker.Generate{
+ SkipGenerate: true,
+ Pattern: `WriteString($0)`,
+ Returns: []string{"int", "error"},
+ },
},
// { // (*bytes.Buffer).WriteString -> (*bytes.Buffer).WriteByte
// Targets: checker.Strings,
diff --git a/vendor/github.com/butuzov/mirror/checkers_httptest.go b/vendor/github.com/butuzov/mirror/checkers_httptest.go
index ae6750930..c28bb1ade 100644
--- a/vendor/github.com/butuzov/mirror/checkers_httptest.go
+++ b/vendor/github.com/butuzov/mirror/checkers_httptest.go
@@ -15,7 +15,7 @@ var HTTPTestMethods = []checker.Violation{
Generate: &checker.Generate{
PreCondition: `h := httptest.ResponseRecorder{}`,
Pattern: `Write($0)`,
- Returns: 2,
+ Returns: []string{"int", "error"},
},
},
{ // (*net/http/httptest.ResponseRecorder).WriteString
@@ -30,7 +30,7 @@ var HTTPTestMethods = []checker.Violation{
Generate: &checker.Generate{
PreCondition: `h := httptest.ResponseRecorder{}`,
Pattern: `WriteString($0)`,
- Returns: 2,
+ Returns: []string{"int", "error"},
},
},
}
diff --git a/vendor/github.com/butuzov/mirror/checkers_maphash.go b/vendor/github.com/butuzov/mirror/checkers_maphash.go
index 4d184d2a9..0aa43ff7b 100644
--- a/vendor/github.com/butuzov/mirror/checkers_maphash.go
+++ b/vendor/github.com/butuzov/mirror/checkers_maphash.go
@@ -15,7 +15,7 @@ var MaphashMethods = []checker.Violation{
Generate: &checker.Generate{
PreCondition: `h := maphash.Hash{}`,
Pattern: `Write($0)`,
- Returns: 2,
+ Returns: []string{"int", "error"},
},
},
{ // (*hash/maphash).WriteString
@@ -30,7 +30,7 @@ var MaphashMethods = []checker.Violation{
Generate: &checker.Generate{
PreCondition: `h := maphash.Hash{}`,
Pattern: `WriteString($0)`,
- Returns: 2,
+ Returns: []string{"int", "error"},
},
},
}
diff --git a/vendor/github.com/butuzov/mirror/checkers_os.go b/vendor/github.com/butuzov/mirror/checkers_os.go
index 09f5a18e5..40973576b 100644
--- a/vendor/github.com/butuzov/mirror/checkers_os.go
+++ b/vendor/github.com/butuzov/mirror/checkers_os.go
@@ -15,7 +15,7 @@ var OsFileMethods = []checker.Violation{
Generate: &checker.Generate{
PreCondition: `f := &os.File{}`,
Pattern: `Write($0)`,
- Returns: 2,
+ Returns: []string{"int", "error"},
},
},
{ // (*os.File).WriteString
@@ -30,7 +30,7 @@ var OsFileMethods = []checker.Violation{
Generate: &checker.Generate{
PreCondition: `f := &os.File{}`,
Pattern: `WriteString($0)`,
- Returns: 2,
+ Returns: []string{"int", "error"},
},
},
}
diff --git a/vendor/github.com/butuzov/mirror/checkers_regexp.go b/vendor/github.com/butuzov/mirror/checkers_regexp.go
index 17175e028..2cd4dc9f8 100644
--- a/vendor/github.com/butuzov/mirror/checkers_regexp.go
+++ b/vendor/github.com/butuzov/mirror/checkers_regexp.go
@@ -14,7 +14,7 @@ var (
Generate: &checker.Generate{
Pattern: `Match("foo", $0)`,
- Returns: 2,
+ Returns: []string{"bool", "error"},
},
},
{ // regexp.MatchString
@@ -27,7 +27,7 @@ var (
Generate: &checker.Generate{
Pattern: `MatchString("foo", $0)`,
- Returns: 2,
+ Returns: []string{"bool", "error"},
},
},
}
@@ -45,7 +45,7 @@ var (
Generate: &checker.Generate{
PreCondition: `re := regexp.MustCompile(".*")`,
Pattern: `Match($0)`,
- Returns: 1,
+ Returns: []string{"bool"},
},
},
{ // (*regexp.Regexp).MatchString
@@ -60,7 +60,7 @@ var (
Generate: &checker.Generate{
PreCondition: `re := regexp.MustCompile(".*")`,
Pattern: `MatchString($0)`,
- Returns: 1,
+ Returns: []string{"bool"},
},
},
{ // (*regexp.Regexp).FindAllIndex
@@ -75,7 +75,7 @@ var (
Generate: &checker.Generate{
PreCondition: `re := regexp.MustCompile(".*")`,
Pattern: `FindAllIndex($0, 1)`,
- Returns: 1,
+ Returns: []string{"[][]int"},
},
},
{ // (*regexp.Regexp).FindAllStringIndex
@@ -90,7 +90,7 @@ var (
Generate: &checker.Generate{
PreCondition: `re := regexp.MustCompile(".*")`,
Pattern: `FindAllStringIndex($0, 1)`,
- Returns: 1,
+ Returns: []string{"[][]int"},
},
},
{ // (*regexp.Regexp).FindAllSubmatchIndex
@@ -105,7 +105,7 @@ var (
Generate: &checker.Generate{
PreCondition: `re := regexp.MustCompile(".*")`,
Pattern: `FindAllSubmatchIndex($0, 1)`,
- Returns: 1,
+ Returns: []string{"[][]int"},
},
},
{ // (*regexp.Regexp).FindAllStringSubmatchIndex
@@ -120,7 +120,7 @@ var (
Generate: &checker.Generate{
PreCondition: `re := regexp.MustCompile(".*")`,
Pattern: `FindAllStringSubmatchIndex($0, 1)`,
- Returns: 1,
+ Returns: []string{"[][]int"},
},
},
{ // (*regexp.Regexp).FindIndex
@@ -135,7 +135,7 @@ var (
Generate: &checker.Generate{
PreCondition: `re := regexp.MustCompile(".*")`,
Pattern: `FindIndex($0)`,
- Returns: 1,
+ Returns: []string{"[]int"},
},
},
{ // (*regexp.Regexp).FindStringIndex
@@ -150,7 +150,7 @@ var (
Generate: &checker.Generate{
PreCondition: `re := regexp.MustCompile(".*")`,
Pattern: `FindStringIndex($0)`,
- Returns: 1,
+ Returns: []string{"[]int"},
},
},
{ // (*regexp.Regexp).FindSubmatchIndex
@@ -165,7 +165,7 @@ var (
Generate: &checker.Generate{
PreCondition: `re := regexp.MustCompile(".*")`,
Pattern: `FindSubmatchIndex($0)`,
- Returns: 1,
+ Returns: []string{"[]int"},
},
},
{ // (*regexp.Regexp).FindStringSubmatchIndex
@@ -180,7 +180,7 @@ var (
Generate: &checker.Generate{
PreCondition: `re := regexp.MustCompile(".*")`,
Pattern: `FindStringSubmatchIndex($0)`,
- Returns: 1,
+ Returns: []string{"[]int"},
},
},
}
diff --git a/vendor/github.com/butuzov/mirror/checkers_strings.go b/vendor/github.com/butuzov/mirror/checkers_strings.go
index ead7e9cc7..3bd59a62f 100644
--- a/vendor/github.com/butuzov/mirror/checkers_strings.go
+++ b/vendor/github.com/butuzov/mirror/checkers_strings.go
@@ -15,7 +15,7 @@ var (
Generate: &checker.Generate{
Pattern: `Compare($0,$1)`,
- Returns: 1,
+ Returns: []string{"int"},
},
},
{ // strings.Contains
@@ -29,7 +29,7 @@ var (
Generate: &checker.Generate{
Pattern: `Contains($0,$1)`,
- Returns: 1,
+ Returns: []string{"bool"},
},
},
{ // strings.ContainsAny
@@ -43,7 +43,7 @@ var (
Generate: &checker.Generate{
Pattern: `ContainsAny($0,"foobar")`,
- Returns: 1,
+ Returns: []string{"bool"},
},
},
{ // strings.ContainsRune
@@ -57,7 +57,7 @@ var (
Generate: &checker.Generate{
Pattern: `ContainsRune($0,'ф')`,
- Returns: 1,
+ Returns: []string{"bool"},
},
},
{ // strings.Count
@@ -71,7 +71,7 @@ var (
Generate: &checker.Generate{
Pattern: `Count($0, $1)`,
- Returns: 1,
+ Returns: []string{"int"},
},
},
{ // strings.EqualFold
@@ -85,7 +85,7 @@ var (
Generate: &checker.Generate{
Pattern: `EqualFold($0,$1)`,
- Returns: 1,
+ Returns: []string{"bool"},
},
},
{ // strings.HasPrefix
@@ -99,7 +99,7 @@ var (
Generate: &checker.Generate{
Pattern: `HasPrefix($0,$1)`,
- Returns: 1,
+ Returns: []string{"bool"},
},
},
{ // strings.HasSuffix
@@ -113,7 +113,7 @@ var (
Generate: &checker.Generate{
Pattern: `HasSuffix($0,$1)`,
- Returns: 1,
+ Returns: []string{"bool"},
},
},
{ // strings.Index
@@ -127,7 +127,7 @@ var (
Generate: &checker.Generate{
Pattern: `Index($0,$1)`,
- Returns: 1,
+ Returns: []string{"int"},
},
},
{ // strings.IndexAny
@@ -141,7 +141,7 @@ var (
Generate: &checker.Generate{
Pattern: `IndexAny($0, "f")`,
- Returns: 1,
+ Returns: []string{"int"},
},
},
{ // strings.IndexByte
@@ -154,8 +154,8 @@ var (
AltCaller: "IndexByte",
Generate: &checker.Generate{
- Pattern: `IndexByte($0, byte('f'))`,
- Returns: 1,
+ Pattern: `IndexByte($0, 'f')`,
+ Returns: []string{"int"},
},
},
{ // strings.IndexFunc
@@ -168,8 +168,8 @@ var (
AltCaller: "IndexFunc",
Generate: &checker.Generate{
- Pattern: `IndexFunc($0,func(r rune) bool { return true })`,
- Returns: 1,
+ Pattern: `IndexFunc($0, func(r rune) bool { return true })`,
+ Returns: []string{"int"},
},
},
{ // strings.IndexRune
@@ -183,7 +183,7 @@ var (
Generate: &checker.Generate{
Pattern: `IndexRune($0, rune('ф'))`,
- Returns: 1,
+ Returns: []string{"int"},
},
},
{ // strings.LastIndex
@@ -197,7 +197,7 @@ var (
Generate: &checker.Generate{
Pattern: `LastIndex($0,$1)`,
- Returns: 1,
+ Returns: []string{"int"},
},
},
{ // strings.LastIndexAny
@@ -211,7 +211,7 @@ var (
Generate: &checker.Generate{
Pattern: `LastIndexAny($0,"f")`,
- Returns: 1,
+ Returns: []string{"int"},
},
},
{ // strings.LastIndexByte
@@ -224,8 +224,8 @@ var (
AltCaller: "LastIndexByte",
Generate: &checker.Generate{
- Pattern: `LastIndexByte($0, byte('f'))`,
- Returns: 1,
+ Pattern: `LastIndexByte($0, 'f')`,
+ Returns: []string{"int"},
},
},
{ // strings.LastIndexFunc
@@ -239,7 +239,7 @@ var (
Generate: &checker.Generate{
Pattern: `LastIndexFunc($0, func(r rune) bool { return true })`,
- Returns: 1,
+ Returns: []string{"int"},
},
},
}
@@ -257,7 +257,7 @@ var (
Generate: &checker.Generate{
PreCondition: `builder := strings.Builder{}`,
Pattern: `Write($0)`,
- Returns: 2,
+ Returns: []string{"int", "error"},
},
},
{ // (*strings.Builder).WriteString
@@ -272,7 +272,7 @@ var (
Generate: &checker.Generate{
PreCondition: `builder := strings.Builder{}`,
Pattern: `WriteString($0)`,
- Returns: 2,
+ Returns: []string{"int", "error"},
},
},
{ // (*strings.Builder).WriteString -> (*strings.Builder).WriteRune
@@ -284,6 +284,11 @@ var (
Args: []int{0},
ArgsType: checker.Rune,
AltCaller: "WriteRune",
+ Generate: &checker.Generate{
+ SkipGenerate: true,
+ Pattern: `WriteString($0)`,
+ Returns: []string{"int", "error"},
+ },
},
// { // (*strings.Builder).WriteString -> (*strings.Builder).WriteByte
// Targets: checker.Strings,
diff --git a/vendor/github.com/butuzov/mirror/checkers_utf8.go b/vendor/github.com/butuzov/mirror/checkers_utf8.go
index e7c4d5ba4..fd3010c37 100644
--- a/vendor/github.com/butuzov/mirror/checkers_utf8.go
+++ b/vendor/github.com/butuzov/mirror/checkers_utf8.go
@@ -13,7 +13,7 @@ var UTF8Functions = []checker.Violation{
Generate: &checker.Generate{
Pattern: `Valid($0)`,
- Returns: 1,
+ Returns: []string{"bool"},
},
},
{ // utf8.ValidString
@@ -26,7 +26,7 @@ var UTF8Functions = []checker.Violation{
Generate: &checker.Generate{
Pattern: `ValidString($0)`,
- Returns: 1,
+ Returns: []string{"bool"},
},
},
{ // utf8.FullRune
@@ -39,7 +39,7 @@ var UTF8Functions = []checker.Violation{
Generate: &checker.Generate{
Pattern: `FullRune($0)`,
- Returns: 1,
+ Returns: []string{"bool"},
},
},
{ // utf8.FullRuneInString
@@ -52,7 +52,7 @@ var UTF8Functions = []checker.Violation{
Generate: &checker.Generate{
Pattern: `FullRuneInString($0)`,
- Returns: 1,
+ Returns: []string{"bool"},
},
},
@@ -66,7 +66,7 @@ var UTF8Functions = []checker.Violation{
Generate: &checker.Generate{
Pattern: `RuneCount($0)`,
- Returns: 1,
+ Returns: []string{"int"},
},
},
{ // bytes.RuneCountInString
@@ -79,7 +79,7 @@ var UTF8Functions = []checker.Violation{
Generate: &checker.Generate{
Pattern: `RuneCountInString($0)`,
- Returns: 1,
+ Returns: []string{"int"},
},
},
@@ -93,7 +93,7 @@ var UTF8Functions = []checker.Violation{
Generate: &checker.Generate{
Pattern: `DecodeLastRune($0)`,
- Returns: 2,
+ Returns: []string{"rune", "int"},
},
},
{ // utf8.DecodeLastRuneInString
@@ -106,7 +106,7 @@ var UTF8Functions = []checker.Violation{
Generate: &checker.Generate{
Pattern: `DecodeLastRuneInString($0)`,
- Returns: 2,
+ Returns: []string{"rune", "int"},
},
},
{ // utf8.DecodeRune
@@ -119,7 +119,7 @@ var UTF8Functions = []checker.Violation{
Generate: &checker.Generate{
Pattern: `DecodeRune($0)`,
- Returns: 2,
+ Returns: []string{"rune", "int"},
},
},
{ // utf8.DecodeRuneInString
@@ -132,7 +132,7 @@ var UTF8Functions = []checker.Violation{
Generate: &checker.Generate{
Pattern: `DecodeRuneInString($0)`,
- Returns: 2,
+ Returns: []string{"rune", "int"},
},
},
}
diff --git a/vendor/github.com/butuzov/mirror/internal/checker/violation.go b/vendor/github.com/butuzov/mirror/internal/checker/violation.go
index 375d3c8e6..3d8acf141 100644
--- a/vendor/github.com/butuzov/mirror/internal/checker/violation.go
+++ b/vendor/github.com/butuzov/mirror/internal/checker/violation.go
@@ -52,9 +52,10 @@ type Violation struct {
// Tests (generation) related struct.
type Generate struct {
- PreCondition string // Precondition we want to be generated
- Pattern string // Generate pattern (for the `want` message)
- Returns int // Expected to return n elements
+ SkipGenerate bool
+ PreCondition string // Precondition we want to be generated
+ Pattern string // Generate pattern (for the `want` message)
+ Returns []string // ReturnTypes as slice
}
func (v *Violation) With(base []byte, e *ast.CallExpr, args map[int]ast.Expr) *Violation {
@@ -165,7 +166,7 @@ type GolangIssue struct {
Original string
}
-// Issue inteanded to be used only with golangci-lint, bu you can use use it
+// Issue intended to be used only within `golangci-lint`, bu you can use use it
// alongside Diagnostic if you wish.
func (v *Violation) Issue(fSet *token.FileSet) GolangIssue {
issue := GolangIssue{
@@ -174,7 +175,7 @@ func (v *Violation) Issue(fSet *token.FileSet) GolangIssue {
Message: v.Message(),
}
- // original expression (useful for debug & requied for replace)
+ // original expression (useful for debug & required for replace)
var buf bytes.Buffer
printer.Fprint(&buf, fSet, v.callExpr)
issue.Original = buf.String()
diff --git a/vendor/github.com/butuzov/mirror/readme.md b/vendor/github.com/butuzov/mirror/readme.md
index fcfd1de11..f830ea72e 100644
--- a/vendor/github.com/butuzov/mirror/readme.md
+++ b/vendor/github.com/butuzov/mirror/readme.md
@@ -1,10 +1,7 @@
-# `mirror` [![Code Coverage](https://coveralls.io/repos/github/butuzov/mirror/badge.svg?branch=main)](https://coveralls.io/github/butuzov/mirror?branch=main) [![build status](https://github.com/butuzov/mirror/actions/workflows/main.yaml/badge.svg?branch=main)]()
+# `mirror` [![Stand with Ukraine](https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/main/badges/StandWithUkraine.svg)](https://u24.gov.ua/) [![Code Coverage](https://coveralls.io/repos/github/butuzov/mirror/badge.svg?branch=main)](https://coveralls.io/github/butuzov/mirror?branch=main) [![build status](https://github.com/butuzov/mirror/actions/workflows/main.yaml/badge.svg?branch=main)]()
`mirror` suggests use of alternative functions/methods in order to gain performance boosts by avoiding unnecessary `[]byte/string` conversion calls. See [MIRROR_FUNCS.md](MIRROR_FUNCS.md) list of mirror functions you can use in go's stdlib.
-## 🇺🇦 PLEASE HELP ME 🇺🇦
-Fundrise for scout drone **DJI Matrice 30T** for my squad (Ukrainian Forces). See more details at [butuzov/README.md](https://github.com/butuzov/butuzov/)
-
## Linter Use Cases
### `github.com/argoproj/argo-cd`
@@ -35,6 +32,10 @@ func IsValidHostname(hostname string, fqdn bool) bool {
go install github.com/butuzov/mirror/cmd/mirror@latest
```
+### `golangci-lint`
+`golangci-lint` supports `mirror` since `v1.53.0`
+
+
## How to use
You run `mirror` with [`go vet`](https://pkg.go.dev/cmd/vet):
@@ -55,6 +56,59 @@ mirror ./...
/air/runner/util.go:173:14: avoid allocations with (*os.File).WriteString
```
+With [`golangci-lint`](https://github.com/golangci/golangci-lint)
+
+```
+golangci-lint run --no-config --disable-all -Emirror
+# github.com/argoproj/argo-cd
+test/e2e/fixture/app/actions.go:83:11: avoid allocations with (*os.File).WriteString (mirror)
+ _, err = tmpFile.Write([]byte(data))
+ ^
+server/server.go:1166:9: avoid allocations with (*regexp.Regexp).MatchString (mirror)
+ return mainJsBundleRegex.Match([]byte(filename))
+ ^
+server/account/account.go:91:6: avoid allocations with (*regexp.Regexp).MatchString (mirror)
+ if !validPasswordRegexp.Match([]byte(q.NewPassword)) {
+ ^
+server/badge/badge.go:52:20: avoid allocations with (*regexp.Regexp).FindAllStringSubmatchIndex (mirror)
+ for _, v := range re.FindAllSubmatchIndex([]byte(str), -1) {
+ ^
+util/cert/cert.go:82:10: avoid allocations with (*regexp.Regexp).MatchString (mirror)
+ return validHostNameRegexp.Match([]byte(hostname)) || validIPv6Regexp.Match([]byte(hostname))
+```
+
## Command line
- You can add checks for `_test.go` files with cli option `--with-tests`
+
+### `golangci-lint`
+ With `golangci-lint` tests are checked by default and can be can be turned off by using the regular `golangci-lint` ways to do it:
+
+ - flag `--tests` (e.g. `--tests=false`)
+ - flag `--skip-files` (e.g. `--skip-files="_test.go"`)
+ - yaml confguration `run.skip-files`:
+ ```yaml
+ run:
+ skip-files:
+ - '(.+)_test\.go'
+ ```
+ - yaml confguration `issues.exclude-rules`:
+ ```yaml
+ issues:
+ exclude-rules:
+ - path: '(.+)_test\.go'
+ linters:
+ - mirror
+ ```
+
+
+## Contributing
+
+```shell
+# Update Assets (testdata/(strings|bytes|os|utf8|maphash|regexp|bufio).go)
+(task|make) generated
+# Run Tests
+(task|make) tests
+# Lint Code
+(task|make) lints
+```