aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/matoous
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/matoous')
-rw-r--r--vendor/github.com/matoous/godox/.gitignore19
-rw-r--r--vendor/github.com/matoous/godox/.golangci.yml71
-rw-r--r--vendor/github.com/matoous/godox/.revive.toml135
-rw-r--r--vendor/github.com/matoous/godox/LICENSE21
-rw-r--r--vendor/github.com/matoous/godox/README.md18
-rw-r--r--vendor/github.com/matoous/godox/go.mod5
-rw-r--r--vendor/github.com/matoous/godox/go.sum8
-rw-r--r--vendor/github.com/matoous/godox/godox.go84
8 files changed, 361 insertions, 0 deletions
diff --git a/vendor/github.com/matoous/godox/.gitignore b/vendor/github.com/matoous/godox/.gitignore
new file mode 100644
index 000000000..30d94b102
--- /dev/null
+++ b/vendor/github.com/matoous/godox/.gitignore
@@ -0,0 +1,19 @@
+# Binaries for programs and plugins
+*.exe
+*.dll
+*.so
+*.dylib
+.idea
+
+# Test binary, build with `go test -c`
+*.test
+
+# Output of the go coverage tool, specifically when used with LiteIDE
+*.out
+
+# Project-local glide cache, RE: https://github.com/Masterminds/glide/issues/736
+.glide/
+
+.vscode/
+debug
+debug.test
diff --git a/vendor/github.com/matoous/godox/.golangci.yml b/vendor/github.com/matoous/godox/.golangci.yml
new file mode 100644
index 000000000..3f0fcdb19
--- /dev/null
+++ b/vendor/github.com/matoous/godox/.golangci.yml
@@ -0,0 +1,71 @@
+linters-settings:
+ depguard:
+ list-type: blacklist
+ include-go-root: true
+ packages:
+ # we are using "github.com/json-iterator/go" instead of json encoder from stdlib
+ - "encoding/json"
+ dupl:
+ threshold: 100
+ gocritic:
+ # Enable multiple checks by tags, run `GL_DEBUG=gocritic golangci-lint` run to see all tags and checks.
+ # Empty list by default. See https://github.com/go-critic/go-critic#usage -> section "Tags".
+ enabled-tags:
+ - performance
+ - diagnostic
+ - style
+ disabled-checks:
+ - emptyStringTest
+ - unnamedResult # it is experimental currently and doesn't handle typed channels correctly
+ gocyclo:
+ min-complexity: 14 # TODO go lower
+ golint:
+ min-confidence: 0
+ govet:
+ check-shadowing: true
+ goconst:
+ min-len: 2
+ min-occurrences: 3
+ goimports:
+ local-prefixes: gitlab.skypicker.com/search-team/gonuts/conveyance-store
+ lll:
+ line-length: 140
+ maligned:
+ suggest-new: true
+ misspell:
+ locale: US
+
+linters:
+ enable-all: true
+ disable:
+ # prealloc is not recommended by `golangci-lint` developers.
+ - prealloc
+ - gochecknoglobals
+
+issues:
+ exclude-rules:
+ - path: _test\.go
+ linters:
+ - goconst
+ - dupl
+
+ - path: fixtures
+ linters:
+ - gocritic
+ - varcheck
+ - deadcode
+ - unused
+
+run:
+ modules-download-mode: readonly
+
+# output configuration options
+output:
+ # colored-line-number|line-number|json|tab|checkstyle|code-climate, default is "colored-line-number"
+ format: tab
+
+ # print lines of code with issue, default is true
+ print-issued-lines: true
+
+ # print linter name in the end of issue text, default is true
+ print-linter-name: true
diff --git a/vendor/github.com/matoous/godox/.revive.toml b/vendor/github.com/matoous/godox/.revive.toml
new file mode 100644
index 000000000..db0e4edb6
--- /dev/null
+++ b/vendor/github.com/matoous/godox/.revive.toml
@@ -0,0 +1,135 @@
+ignoreGeneratedHeader = false
+severity = "warning"
+
+# confidence <= 0.2 generate a lot of errors from package-comments rule. It marks files that do not contain
+# package-level comments as a warning irrespective of existing package-level coment in one file.
+confidence = 0.25
+errorCode = 1
+warningCode = 1
+
+# Rules block.
+# ⚠ Make sure to sort rules alpabetically for readability! ⚠
+
+# argument-limit rule is setting up a maximum number of parameters that can be passed to the functions/methods.
+[rule.argument-limit]
+ arguments = [5]
+
+# atomic rule checks for commonly mistaken usages of the sync/atomic package.
+[rule.atomic]
+
+# blank-imports rule disallows blank imports.
+[rule.blank-imports]
+
+# bool-literal-in-expr suggests removing boolean literals from logic expressions like `bar == true`, `arg == false`,
+# `r != true`, `false && boolExpr` and `boolExpr || true`.
+[rule.bool-literal-in-expr]
+
+# constant-logical-expr rule warns on constant logical expressions, like `name == name`.
+[rule.constant-logical-expr]
+
+# context-as-argument rule makes sure that context.Context is the first argument of a function.
+[rule.context-as-argument]
+
+# context-keys-type rule disallows the usage of basic types in context.WithValue
+[rule.context-keys-type]
+
+# confusing-naming rule warns on methods with names that differ only by capitalization.
+[rule.confusing-naming]
+
+# confusing-results rule suggests to name potentially confusing function results.
+[rule.confusing-results]
+
+# cyclomatic rule sets restriction for maximum Cyclomatic complexity.
+[rule.cyclomatic]
+ arguments = [15]
+
+# deep-exit rule looks for program exits in funcs other than `main()` or `init()`.
+[rule.deep-exit]
+
+# dot-imports rule forbids `.` imports.
+[rule.dot-imports]
+
+# empty-block warns on empty code blocks.
+[rule.empty-block]
+
+# error-return rule ensure that the error return parameter is the last.
+[rule.error-return]
+
+# error-strings rule ensure conventions around error strings.
+[rule.error-strings]
+
+# error-naming rule ensure naming of error variables (has `Err` or `err` prefix).
+[rule.error-naming]
+
+# errorf rule warns on usage errors.New(fmt.Sprintf()) instead of fmt.Errorf()
+[rule.errorf]
+
+# exported rule ensure naming and commenting conventions on exported symbols.
+[rule.exported]
+
+# flag-parameter rule warns on boolean parameters that create a control coupling.
+[rule.flag-parameter]
+
+# get-return rule warns on getters that do not yield any result.
+[rule.get-return]
+
+# if-return rule warns redundant if when returning an error.
+[rule.if-return]
+
+# increment-decrement rule forces to use `i++` and `i--` instead of `i += 1` and `i -= 1`.
+[rule.increment-decrement]
+
+# indent-error-flow rule prevents redundant else statements.
+[rule.indent-error-flow]
+
+# modifies-value-receiver warns on assignments to value-passed method receivers.
+[rule.modifies-value-receiver]
+
+# package-comments rule ensures package commenting conventions.
+[rule.package-comments]
+
+# range rule prevents redundant variables when iterating over a collection.
+[rule.range]
+
+# range-val-in-closure warns if range value is used in a closure dispatched as goroutine.
+[rule.range-val-in-closure]
+
+# receiver-naming ensures conventions around the naming of receivers.
+[rule.receiver-naming]
+
+# redefines-builtin-id warns on redefinitions of built-in (constants, variables, function and types) identifiers,
+# like `true := "false"` etc.
+[rule.redefines-builtin-id]
+
+# rule.superfluous-else prevents redundant else statements (extends indent-error-flow). Checks for `if-then-else`where
+# the then block ends with branching statement like `continue`, `break`, or `goto`.
+[rule.superfluous-else]
+
+# rule.struct-tag checks common struct tags like `json`, `xml`, `yaml`.
+[rule.struct-tag]
+
+# time-naming rule conventions around the naming of time variables. Like not to use unit suffixes (sec, min etc.) in
+# naming variables of type `time.Time` or `time.Duration`.
+[rule.time-naming]
+
+# unexported-return rule warns when a public return is from unexported type.
+[rule.unexported-return]
+
+# unnecessary-stmt suggests removing or simplifying unnecessary statements like breaks at the end of cases or return at
+# the end of bodies of functions returning nothing.
+[rule.unnecessary-stmt]
+
+# unreachable-code rule warns on the unreachable code.
+[rule.unreachable-code]
+
+# unused-parameter rule suggests to rename or remove unused function parameters.
+[rule.unused-parameter]
+
+# var-declaration rule reduces redundancies around variable declaration.
+[rule.var-declaration]
+
+# var-naming checks naming rules.
+[rule.var-naming]
+
+# waitgroup-by-value rule warns on functions taking `sync.WaitGroup` as a by-value parameter.
+[rule.waitgroup-by-value]
diff --git a/vendor/github.com/matoous/godox/LICENSE b/vendor/github.com/matoous/godox/LICENSE
new file mode 100644
index 000000000..49e1b1e3a
--- /dev/null
+++ b/vendor/github.com/matoous/godox/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2018 Matous Dzivjak
+
+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/matoous/godox/README.md b/vendor/github.com/matoous/godox/README.md
new file mode 100644
index 000000000..6d5f54fc6
--- /dev/null
+++ b/vendor/github.com/matoous/godox/README.md
@@ -0,0 +1,18 @@
+GoDoX
+===
+
+[![Tests](https://github.com/matoous/godox/workflows/.github/workflows/test.yml/badge.svg)](https://github.com/matoous/godox/actions)
+[![Lint](https://github.com/matoous/godox/workflows/.github/workflows/lint.yml/badge.svg)](https://github.com/matoous/godox/actions)
+[![GoDoc](https://godoc.org/github.com/matoous/godox?status.svg)](https://godoc.org/github.com/matoous/godox)
+[![Go Report Card](https://goreportcard.com/badge/github.com/matoous/godox)](https://goreportcard.com/report/github.com/matoous/godox)
+[![GitHub issues](https://img.shields.io/github/issues/matoous/godox.svg)](https://github.com/matoous/godox/issues)
+[![License](https://img.shields.io/badge/license-MIT%20License-blue.svg)](https://github.com/matoous/godox/LICENSE)
+
+GoDoX extracts comments from Go code based on keywords. This repository is fork of https://github.com/766b/godox
+but a lot of code has changed, this repository is updated and the code was adjusted for better integration with
+https://github.com/golangci/golangci-lint.
+
+Installation
+---
+
+ go get github.com/matoous/godox
diff --git a/vendor/github.com/matoous/godox/go.mod b/vendor/github.com/matoous/godox/go.mod
new file mode 100644
index 000000000..69b34f0e9
--- /dev/null
+++ b/vendor/github.com/matoous/godox/go.mod
@@ -0,0 +1,5 @@
+module github.com/matoous/godox
+
+go 1.13
+
+require golang.org/x/tools v0.0.0-20190910044552-dd2b5c81c578
diff --git a/vendor/github.com/matoous/godox/go.sum b/vendor/github.com/matoous/godox/go.sum
new file mode 100644
index 000000000..970cb25dd
--- /dev/null
+++ b/vendor/github.com/matoous/godox/go.sum
@@ -0,0 +1,8 @@
+golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
+golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
+golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
+golang.org/x/tools v0.0.0-20190910044552-dd2b5c81c578 h1:f0Gfd654rnnfXT1+BK1YHPTS1qQdKrPIaGQwWxNE44k=
+golang.org/x/tools v0.0.0-20190910044552-dd2b5c81c578/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
+golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
diff --git a/vendor/github.com/matoous/godox/godox.go b/vendor/github.com/matoous/godox/godox.go
new file mode 100644
index 000000000..13f3f3bec
--- /dev/null
+++ b/vendor/github.com/matoous/godox/godox.go
@@ -0,0 +1,84 @@
+package godox
+
+import (
+ "bufio"
+ "bytes"
+ "fmt"
+ "go/ast"
+ "go/token"
+ "path/filepath"
+ "strings"
+)
+
+var (
+ defaultKeywords = []string{"TODO", "BUG", "FIXME"}
+)
+
+// Message contains a message and position
+type Message struct {
+ Pos token.Position
+ Message string
+}
+
+func getMessages(c *ast.Comment, fset *token.FileSet, keywords []string) []Message {
+ commentText := c.Text
+ switch commentText[1] {
+ case '/':
+ commentText = commentText[2:]
+ if len(commentText) > 0 && commentText[0] == ' ' {
+ commentText = commentText[1:]
+ }
+ case '*':
+ commentText = commentText[2 : len(commentText)-2]
+ }
+
+ b := bufio.NewReader(bytes.NewBufferString(commentText))
+ var comments []Message
+
+ for lineNum := 0; ; lineNum++ {
+ line, _, err := b.ReadLine()
+ if err != nil {
+ break
+ }
+ sComment := bytes.TrimSpace(line)
+ if len(sComment) < 4 {
+ continue
+ }
+ for _, kw := range keywords {
+ if bytes.EqualFold([]byte(kw), sComment[0:len(kw)]) {
+ pos := fset.Position(c.Pos())
+ // trim the comment
+ if len(sComment) > 40 {
+ sComment = []byte(fmt.Sprintf("%s...", sComment[:40]))
+ }
+ comments = append(comments, Message{
+ Pos: pos,
+ Message: fmt.Sprintf(
+ "%s:%d: Line contains %s: \"%s\"",
+ filepath.Join(pos.Filename),
+ pos.Line+lineNum,
+ strings.Join(keywords, "/"),
+ sComment,
+ ),
+ })
+ break
+ }
+ }
+ }
+ return comments
+}
+
+// Run runs the godox linter on given file.
+// Godox searches for comments starting with given keywords and reports them.
+func Run(file *ast.File, fset *token.FileSet, keywords ...string) []Message {
+ if len(keywords) == 0 {
+ keywords = defaultKeywords
+ }
+ var messages []Message
+ for _, c := range file.Comments {
+ for _, ci := range c.List {
+ messages = append(messages, getMessages(ci, fset, keywords)...)
+ }
+ }
+ return messages
+}