aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/Abirdcfly
diff options
context:
space:
mode:
authorTaras Madan <tarasmadan@google.com>2023-02-22 22:16:50 +0100
committerTaras Madan <tarasmadan@google.com>2023-02-24 12:47:23 +0100
commit4165372ec8fd142475a4e35fd0cf4f8042132208 (patch)
tree21cd62211b4dd80bee469054c5b65db77342333c /vendor/github.com/Abirdcfly
parent2b3ed821a493b8936c8bacfa6f8b4f1c90a00855 (diff)
dependencies: update
set go min requirements to 1.19 update dependencies update vendor
Diffstat (limited to 'vendor/github.com/Abirdcfly')
-rw-r--r--vendor/github.com/Abirdcfly/dupword/.gitignore183
-rw-r--r--vendor/github.com/Abirdcfly/dupword/.goreleaser.yml72
-rw-r--r--vendor/github.com/Abirdcfly/dupword/LICENSE21
-rw-r--r--vendor/github.com/Abirdcfly/dupword/README.md151
-rw-r--r--vendor/github.com/Abirdcfly/dupword/dupword.go302
-rw-r--r--vendor/github.com/Abirdcfly/dupword/version.go41
6 files changed, 770 insertions, 0 deletions
diff --git a/vendor/github.com/Abirdcfly/dupword/.gitignore b/vendor/github.com/Abirdcfly/dupword/.gitignore
new file mode 100644
index 000000000..b5109d2bb
--- /dev/null
+++ b/vendor/github.com/Abirdcfly/dupword/.gitignore
@@ -0,0 +1,183 @@
+
+# Godot-specific ignores
+.import/
+export.cfg
+export_presets.cfg
+
+# Mono-specific ignores
+.mono/
+data_*/
+
+### JetBrains template
+# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
+# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
+
+# User-specific stuff
+.idea/**/workspace.xml
+.idea/**/tasks.xml
+.idea/**/usage.statistics.xml
+.idea/**/dictionaries
+.idea/**/shelf
+
+# Generated files
+.idea/**/contentModel.xml
+
+# Sensitive or high-churn files
+.idea/**/dataSources/
+.idea/**/dataSources.ids
+.idea/**/dataSources.local.xml
+.idea/**/sqlDataSources.xml
+.idea/**/dynamic.xml
+.idea/**/uiDesigner.xml
+.idea/**/dbnavigator.xml
+
+# Gradle
+.idea/**/gradle.xml
+.idea/**/libraries
+
+# Gradle and Maven with auto-import
+# When using Gradle or Maven with auto-import, you should exclude module files,
+# since they will be recreated, and may cause churn. Uncomment if using
+# auto-import.
+.idea/artifacts
+.idea/compiler.xml
+.idea/jarRepositories.xml
+.idea/modules.xml
+.idea/*.iml
+.idea/modules
+*.iml
+*.ipr
+
+# CMake
+cmake-build-*/
+
+# Mongo Explorer plugin
+.idea/**/mongoSettings.xml
+
+# File-based project format
+*.iws
+
+# IntelliJ
+out/
+
+# mpeltonen/sbt-idea plugin
+.idea_modules/
+
+# JIRA plugin
+atlassian-ide-plugin.xml
+
+# Cursive Clojure plugin
+.idea/replstate.xml
+
+# Crashlytics plugin (for Android Studio and IntelliJ)
+com_crashlytics_export_strings.xml
+crashlytics.properties
+crashlytics-build.properties
+fabric.properties
+
+# Editor-based Rest Client
+.idea/httpRequests
+
+# Android studio 3.1+ serialized cache file
+.idea/caches/build_file_checksums.ser
+
+### Emacs template
+# -*- mode: gitignore; -*-
+*~
+\#*\#
+/.emacs.desktop
+/.emacs.desktop.lock
+*.elc
+auto-save-list
+tramp
+.\#*
+
+# Org-mode
+.org-id-locations
+*_archive
+
+# flymake-mode
+*_flymake.*
+
+# eshell files
+/eshell/history
+/eshell/lastdir
+
+# elpa packages
+/elpa/
+
+# reftex files
+*.rel
+
+# AUCTeX auto folder
+/auto/
+
+# cask packages
+.cask/
+dist/
+
+# Flycheck
+flycheck_*.el
+
+# server auth directory
+/server/
+
+# projectiles files
+.projectile
+
+# directory configuration
+.dir-locals.el
+
+# network security
+/network-security.data
+
+
+### Vim template
+# Swap
+[._]*.s[a-v][a-z]
+!*.svg # comment out if you don't need vector files
+[._]*.sw[a-p]
+[._]s[a-rt-v][a-z]
+[._]ss[a-gi-z]
+[._]sw[a-p]
+
+# Session
+Session.vim
+Sessionx.vim
+
+# Temporary
+.netrwhist
+*~
+# Auto-generated tag files
+tags
+# Persistent undo
+[._]*.un~
+
+### macOS template
+# General
+.DS_Store
+.AppleDouble
+.LSOverride
+
+# Icon must end with two \r
+Icon
+
+# Thumbnails
+._*
+
+# Files that might appear in the root of a volume
+.DocumentRevisions-V100
+.fseventsd
+.Spotlight-V100
+.TemporaryItems
+.Trashes
+.VolumeIcon.icns
+.com.apple.timemachine.donotpresent
+
+# Directories potentially created on remote AFP share
+.AppleDB
+.AppleDesktop
+Network Trash Folder
+Temporary Items
+.apdisk
+
diff --git a/vendor/github.com/Abirdcfly/dupword/.goreleaser.yml b/vendor/github.com/Abirdcfly/dupword/.goreleaser.yml
new file mode 100644
index 000000000..c3401787a
--- /dev/null
+++ b/vendor/github.com/Abirdcfly/dupword/.goreleaser.yml
@@ -0,0 +1,72 @@
+---
+project_name: dupword
+
+release:
+ github:
+ owner: Abirdcfly
+ name: dupword
+
+builds:
+ - binary: dupword
+ goos:
+ - darwin
+ - windows
+ - linux
+ - freebsd
+ goarch:
+ - amd64
+ - arm64
+ - arm
+ - 386
+ - ppc64le
+ - s390x
+ - mips64
+ - mips64le
+ - riscv64
+ goarm:
+ - 6
+ - 7
+ gomips:
+ - hardfloat
+ env:
+ - CGO_ENABLED=0
+ ignore:
+ - goos: darwin
+ goarch: 386
+ - goos: freebsd
+ goarch: arm64
+ main: ./cmd/dupword/
+ flags:
+ - -trimpath
+ ldflags: -s -w -X main.version={{.Version}} -X main.commit={{.ShortCommit}} -X main.date={{.Date}}
+
+archives:
+ - format: tar.gz
+ wrap_in_directory: true
+ format_overrides:
+ - goos: windows
+ format: zip
+ name_template: '{{ .ProjectName }}-{{ .Version }}-{{ .Os }}-{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}'
+ files:
+ - LICENSE
+ - README.md
+
+snapshot:
+ name_template: SNAPSHOT-{{ .Commit }}
+
+checksum:
+ name_template: '{{ .ProjectName }}-{{ .Version }}-checksums.txt'
+
+changelog:
+ sort: asc
+ filters:
+ exclude:
+ - '(?i)^docs?:'
+ - '(?i)^docs\([^:]+\):'
+ - '(?i)^docs\[[^:]+\]:'
+ - '^tests?:'
+ - '(?i)^dev:'
+ - '^build\(deps\): bump .* in /docs \(#\d+\)'
+ - '^build\(deps\): bump .* in /\.github/peril \(#\d+\)'
+ - Merge pull request
+ - Merge branch
diff --git a/vendor/github.com/Abirdcfly/dupword/LICENSE b/vendor/github.com/Abirdcfly/dupword/LICENSE
new file mode 100644
index 000000000..afa64c6e1
--- /dev/null
+++ b/vendor/github.com/Abirdcfly/dupword/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2022 Abirdcfly
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/vendor/github.com/Abirdcfly/dupword/README.md b/vendor/github.com/Abirdcfly/dupword/README.md
new file mode 100644
index 000000000..6917acae2
--- /dev/null
+++ b/vendor/github.com/Abirdcfly/dupword/README.md
@@ -0,0 +1,151 @@
+# dupword
+
+![GitHub go.mod Go version](https://img.shields.io/github/go-mod/go-version/Abirdcfly/dupword?style=flat-square)
+[![GoDoc](https://godoc.org/github.com/Abirdcfly/dupword?status.svg)](https://pkg.go.dev/github.com/Abirdcfly/dupword)
+[![Actions Status](https://github.com/Abirdcfly/dupword/actions/workflows/lint.yml/badge.svg)](https://github.com/Abirdcfly/dupword/actions)
+[![Go Report Card](https://goreportcard.com/badge/github.com/Abirdcfly/dupword)](https://goreportcard.com/report/github.com/Abirdcfly/dupword)
+
+A linter that checks for duplicate words in the source code (usually miswritten)
+
+Examples in real code and related issues can be viewed in [dupword#3](https://github.com/Abirdcfly/dupword/issues/3)
+
+## example
+
+1. Repeated words appear on two adjacent lines [commit](https://github.com/golang/go/commit/d8f90ce0f8119bf593efb6fb91825de5b61fcda7)
+
+```diff
+--- a/src/cmd/compile/internal/ssa/schedule.go
++++ b/src/cmd/compile/internal/ssa/schedule.go
+@@ -179,7 +179,7 @@ func schedule(f *Func) {
+ // scored CarryChainTail (and prove w is not a tail).
+ score[w.ID] = ScoreFlags
+ }
+- // Verify v has not been scored. If v has not been visited, v may be the
++ // Verify v has not been scored. If v has not been visited, v may be
+ // the final (tail) operation in a carry chain. If v is not, v will be
+ // rescored above when v's carry-using op is scored. When scoring is done,
+ // only tail operations will retain the CarryChainTail score.
+```
+
+2. Repeated words appearing on the same line [commit](https://github.com/golang/go/commit/48da729e8468b630ee003ac51cbaac595d53bec8)
+
+```diff
+--- a/src/net/http/cookiejar/jar.go
++++ b/src/net/http/cookiejar/jar.go
+@@ -465,7 +465,7 @@ func (j *Jar) domainAndType(host, domain string) (string, bool, error) {
+ // dot in the domain-attribute before processing the cookie.
+ //
+ // Most browsers don't do that for IP addresses, only curl
+- // version 7.54) and and IE (version 11) do not reject a
++ // version 7.54) and IE (version 11) do not reject a
+ // Set-Cookie: a=1; domain=.127.0.0.1
+ // This leading dot is optional and serves only as hint for
+ // humans to indicate that a cookie with "domain=.bbc.co.uk"
+```
+
+## Install
+
+```bash
+go install github.com/Abirdcfly/dupword/cmd/dupword@latest
+```
+
+**Or** install the main branch (including the last commit) with:
+
+```bash
+go install github.com/Abirdcfly/dupword/cmd/dupword@main
+```
+
+## Usage
+
+### 1. default
+
+Run with default settings(include test file):
+
+**But note that not all repeated words are wrong** see [dupword#4](https://github.com/Abirdcfly/dupword/issues/4) for real code example.
+
+```bash
+$ dupword ./...
+/Users/xxx/go/src/dupword/dupword_test.go:88:10: Duplicate words (the) found
+exit status 3
+```
+
+### 2. skip test file
+
+Skip detection test file(`*_test.go`):
+
+```bash
+$ dupword -test=false ./...
+```
+
+### 3. auto-fix
+
+```bash
+$ dupword -fix ./...
+```
+
+### 4. all options
+
+All options:
+
+```bash
+$ dupword --help
+dupword: checks for duplicate words in the source code (usually miswritten)
+
+Usage: dupword [-flag] [package]
+
+This analyzer checks miswritten duplicate words in comments or package doc or string declaration
+
+Flags:
+ -V print version and exit
+ -all
+ no effect (deprecated)
+ -c int
+ display offending line with this many lines of context (default -1)
+ -cpuprofile string
+ write CPU profile to this file
+ -debug string
+ debug flags, any subset of "fpstv"
+ -fix
+ apply all suggested fixes
+ -flags
+ print analyzer flags in JSON
+ -json
+ emit JSON output
+ -keyword value
+ key words for detecting duplicate words
+ -memprofile string
+ write memory profile to this file
+ -source
+ no effect (deprecated)
+ -tags string
+ no effect (deprecated)
+ -test
+ indicates whether test files should be analyzed, too (default true)
+ -trace string
+ write trace log to this file
+ -v no effect (deprecated)
+```
+
+### 5. my advice
+
+use `--keyword=the,and,a` and `-fix` together. I personally think that specifying only common repeated prepositions can effectively avoid false positives.
+
+see [dupword#4](https://github.com/Abirdcfly/dupword/issues/4) for real code example.
+
+```bash
+$ dupword --keyword=the,and,a -fix ./...
+```
+
+## TODO
+
+- [x] add this linter to golangci-lint
+- [ ] rewrite the detection logic to make it more efficient
+
+## Limitation
+
+1. Only for `*.go` file.But some miswritten occurs in `*.md` or `*.json` file.(example: kubernetes), In this case, my advice is to use [rg](https://github.com/BurntSushi/ripgrep) to do the lookup and replace manually.
+2. When use `-fix`, also running `go fmt` in the dark.([This logic is determined upstream](https://github.com/golang/tools/blob/248c34b88a4148128f89e41923498bd86f805b7d/go/analysis/internal/checker/checker.go#L424-L433), the project does not have this part of the code.)
+
+## License
+
+MIT
diff --git a/vendor/github.com/Abirdcfly/dupword/dupword.go b/vendor/github.com/Abirdcfly/dupword/dupword.go
new file mode 100644
index 000000000..508caca52
--- /dev/null
+++ b/vendor/github.com/Abirdcfly/dupword/dupword.go
@@ -0,0 +1,302 @@
+// MIT License
+//
+// Copyright (c) 2022 Abirdcfly
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+// Package dupword defines an Analyzer that checks that duplicate words
+// int the source code.
+package dupword
+
+import (
+ "flag"
+ "fmt"
+ "go/ast"
+ "go/token"
+ "sort"
+ "strconv"
+ "strings"
+ "unicode"
+ "unicode/utf8"
+
+ "golang.org/x/tools/go/analysis"
+ "golang.org/x/tools/go/analysis/passes/inspect"
+ "golang.org/x/tools/go/ast/inspector"
+)
+
+const (
+ Name = "dupword"
+ Doc = `checks for duplicate words in the source code (usually miswritten)
+
+This analyzer checks miswritten duplicate words in comments or package doc or string declaration`
+ Message = "Duplicate words (%s) found"
+ CommentPrefix = `//`
+)
+
+var (
+ defaultWord = []string{}
+ // defaultWord = []string{"the", "and", "a"}
+)
+
+type analyzer struct {
+ KeyWord []string
+}
+
+func (a *analyzer) String() string {
+ return strings.Join(a.KeyWord, ",")
+}
+
+func (a *analyzer) Set(w string) error {
+ if len(w) != 0 {
+ a.KeyWord = make([]string, 0)
+ a.KeyWord = append(a.KeyWord, strings.Split(w, ",")...)
+ }
+ return nil
+}
+
+func NewAnalyzer() *analysis.Analyzer {
+ analyzer := &analyzer{KeyWord: defaultWord}
+ a := &analysis.Analyzer{
+ Name: Name,
+ Doc: Doc,
+ Requires: []*analysis.Analyzer{inspect.Analyzer},
+ Run: analyzer.run,
+ RunDespiteErrors: true,
+ }
+ a.Flags.Init(Name, flag.ExitOnError)
+ a.Flags.Var(analyzer, "keyword", "key words for detecting duplicate words")
+ a.Flags.Var(version{}, "V", "print version and exit")
+ return a
+}
+
+func (a *analyzer) run(pass *analysis.Pass) (interface{}, error) {
+ for _, file := range pass.Files {
+ a.fixDuplicateWordInComment(pass, file)
+ }
+ inspect := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
+ nodeFilter := []ast.Node{
+ (*ast.BasicLit)(nil),
+ }
+ inspect.Preorder(nodeFilter, func(n ast.Node) {
+ if lit, ok := n.(*ast.BasicLit); ok {
+ a.fixDuplicateWordInString(pass, lit)
+ }
+ })
+ return nil, nil
+}
+
+func (a *analyzer) fixDuplicateWordInComment(pass *analysis.Pass, f *ast.File) {
+ for _, cg := range f.Comments {
+ var preLine *ast.Comment
+ for _, c := range cg.List {
+ update, keyword, find := a.Check(c.Text)
+ if find {
+ pass.Report(analysis.Diagnostic{Pos: c.Slash, End: c.End(), Message: fmt.Sprintf(Message, keyword), SuggestedFixes: []analysis.SuggestedFix{{
+ Message: "Update",
+ TextEdits: []analysis.TextEdit{{
+ Pos: c.Slash,
+ End: c.End(),
+ NewText: []byte(update),
+ }},
+ }}})
+ }
+ if preLine != nil {
+ fields := strings.Fields(preLine.Text)
+ if len(fields) < 1 {
+ continue
+ }
+ preLineContent := fields[len(fields)-1] + "\n"
+ thisLineContent := c.Text
+ if find {
+ thisLineContent = update
+ }
+ before, after, _ := strings.Cut(thisLineContent, CommentPrefix)
+ update, keyword, find := a.Check(preLineContent + after)
+ if find {
+ var suggestedFixes []analysis.SuggestedFix
+ if strings.Contains(update, preLineContent) {
+ update = before + CommentPrefix + strings.TrimPrefix(update, preLineContent)
+ suggestedFixes = []analysis.SuggestedFix{{
+ Message: "Update",
+ TextEdits: []analysis.TextEdit{{
+ Pos: c.Slash,
+ End: c.End(),
+ NewText: []byte(update),
+ }},
+ }}
+ }
+ pass.Report(analysis.Diagnostic{Pos: c.Slash, End: c.End(), Message: fmt.Sprintf(Message, keyword), SuggestedFixes: suggestedFixes})
+ }
+ }
+ preLine = c
+ }
+ }
+}
+
+func (a *analyzer) fixDuplicateWordInString(pass *analysis.Pass, lit *ast.BasicLit) {
+ if lit.Kind != token.STRING {
+ return
+ }
+ value, err := strconv.Unquote(lit.Value)
+ if err != nil {
+ fmt.Printf("lit.Value:%v, err: %v\n", lit.Value, err)
+ // fall back to default
+ value = lit.Value
+ }
+ quote := value != lit.Value
+ update, keyword, find := a.Check(value)
+ if quote {
+ update = strconv.Quote(update)
+ }
+ if find {
+ pass.Report(analysis.Diagnostic{Pos: lit.Pos(), End: lit.End(), Message: fmt.Sprintf(Message, keyword), SuggestedFixes: []analysis.SuggestedFix{{
+ Message: "Update",
+ TextEdits: []analysis.TextEdit{{
+ Pos: lit.Pos(),
+ End: lit.End(),
+ NewText: []byte(update),
+ }},
+ }}})
+ }
+}
+
+// CheckOneKey use to check there is defined duplicate word in a string.
+// raw is checked line. key is the keyword to check. empty means just check duplicate word.
+func CheckOneKey(raw, key string) (new string, findWord string, find bool) {
+ if key == "" {
+ has := false
+ fields := strings.Fields(raw)
+ for i := range fields {
+ if i == len(fields)-1 {
+ break
+ }
+ if fields[i] == fields[i+1] {
+ has = true
+ }
+ }
+ if !has {
+ return
+ }
+ } else {
+ if x := strings.Split(raw, key); len(x) < 2 {
+ return
+ }
+ }
+
+ findWordMap := make(map[string]bool, 4)
+ newLine := strings.Builder{}
+ wordStart, spaceStart := 0, 0
+ curWord, preWord := "", ""
+ lastSpace := ""
+ var lastRune int32
+ for i, r := range raw {
+ if !unicode.IsSpace(r) && unicode.IsSpace(lastRune) {
+ // word start position
+ /*
+ i
+ |
+ hello[ spaceA ]the[ spaceB ]the[ spaceC ]word
+ ^ ^
+ | curWord: the
+ preWord: the
+ */
+ symbol := raw[spaceStart:i]
+ if ((key != "" && curWord == key) || key == "") && curWord == preWord && curWord != "" {
+ if !ExcludeWords(curWord) {
+ find = true
+ findWordMap[curWord] = true
+ newLine.WriteString(lastSpace)
+ symbol = ""
+ }
+ } else {
+ newLine.WriteString(lastSpace)
+ newLine.WriteString(curWord)
+ }
+ lastSpace = symbol
+ preWord = curWord
+ wordStart = i
+ } else if unicode.IsSpace(r) && !unicode.IsSpace(lastRune) {
+ // space start position
+ spaceStart = i
+ curWord = raw[wordStart:i]
+ } else if i == len(raw)-1 {
+ // last position
+ word := raw[wordStart:]
+ if ((key != "" && word == key) || key == "") && word == preWord {
+ if !ExcludeWords(word) {
+ find = true
+ findWordMap[word] = true
+ }
+ } else {
+ newLine.WriteString(lastSpace)
+ newLine.WriteString(word)
+ }
+ }
+ lastRune = r
+ }
+ if find {
+ new = newLine.String()
+ findWordSlice := make([]string, len(findWordMap))
+ i := 0
+ for k := range findWordMap {
+ findWordSlice[i] = k
+ i++
+ }
+ sort.Strings(findWordSlice)
+ findWord = strings.Join(findWordSlice, ",")
+ }
+ return
+}
+
+func (a *analyzer) Check(raw string) (update string, keyword string, find bool) {
+ for _, key := range a.KeyWord {
+ updateOne, _, findOne := CheckOneKey(raw, key)
+ if findOne {
+ raw = updateOne
+ find = findOne
+ update = updateOne
+ if keyword == "" {
+ keyword = key
+ } else {
+ keyword = keyword + "," + key
+ }
+ }
+ }
+ if len(a.KeyWord) == 0 {
+ return CheckOneKey(raw, "")
+ }
+ return
+}
+
+// ExcludeWords determines whether duplicate words should be reported,
+//
+// e.g. %s, </div> should not be reported.
+func ExcludeWords(word string) (exclude bool) {
+ firstRune, _ := utf8.DecodeRuneInString(word)
+ if unicode.IsDigit(firstRune) {
+ return true
+ }
+ if unicode.IsPunct(firstRune) {
+ return true
+ }
+ if unicode.IsSymbol(firstRune) {
+ return true
+ }
+ return false
+}
diff --git a/vendor/github.com/Abirdcfly/dupword/version.go b/vendor/github.com/Abirdcfly/dupword/version.go
new file mode 100644
index 000000000..9d892d0c9
--- /dev/null
+++ b/vendor/github.com/Abirdcfly/dupword/version.go
@@ -0,0 +1,41 @@
+// MIT License
+//
+// # Copyright (c) 2022 Abirdcfly
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+package dupword
+
+import (
+ "fmt"
+ "os"
+)
+
+var Version = "dev"
+
+type version struct{}
+
+func (version) IsBoolFlag() bool { return true }
+func (version) Get() interface{} { return nil }
+func (version) String() string { return "" }
+func (version) Set(_ string) error {
+ fmt.Println(Version)
+ os.Exit(0)
+ return nil
+}