aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/ultraware
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2020-09-15 18:05:35 +0200
committerDmitry Vyukov <dvyukov@google.com>2020-09-15 19:34:30 +0200
commit712de1c63d9db97c81af68cd0dc4372c53d2e57a (patch)
treeae1761fec52c3ae4ddd003a4130ddbda8d0a2d69 /vendor/github.com/ultraware
parent298a69c38dd5c8a9bbd7a022e88f4ddbcf885e16 (diff)
vendor/github.com/golangci/golangci-lint: update to v1.31
Diffstat (limited to 'vendor/github.com/ultraware')
-rw-r--r--vendor/github.com/ultraware/funlen/README.md64
-rw-r--r--vendor/github.com/ultraware/funlen/main.go20
2 files changed, 15 insertions, 69 deletions
diff --git a/vendor/github.com/ultraware/funlen/README.md b/vendor/github.com/ultraware/funlen/README.md
index ca7e9a0f7..aaf348521 100644
--- a/vendor/github.com/ultraware/funlen/README.md
+++ b/vendor/github.com/ultraware/funlen/README.md
@@ -2,68 +2,8 @@
Funlen is a linter that checks for long functions. It can checks both on the number of lines and the number of statements.
-The default limits are 50 lines and 35 statements. You can configure these with the `-l` and `-s` flags.
-
-Example code:
-
-```go
-package main
-
-import "fmt"
-
-func fiveStatements() {
- fmt.Println(1)
- fmt.Println(2)
- fmt.Println(3)
- fmt.Println(4)
- fmt.Println(5)
-}
-
-func sevenLines() {
- fmt.Println(1)
-
- fmt.Println(2)
-
- fmt.Println(3)
-
- fmt.Println(4)
-}
-```
-
-Reults in:
-
-```
-$ funlen -l=6 -s=4 .
-main.go:5:6:Function 'fiveStatements' has too many statements (5 > 4)
-main.go:13:6:Function 'sevenLines' is too long (7 > 6)
-```
+The default limits are 60 lines and 40 statements. You can configure these.
## Installation guide
-```bash
-go get git.ultraware.nl/NiseVoid/funlen
-```
-
-### Gometalinter
-
-You can add funlen to gometalinter and enable it.
-
-`.gometalinter.json`:
-
-```json
-{
- "Linters": {
- "funlen": "funlen -l=50 -s=35:PATH:LINE:COL:MESSAGE"
- },
-
- "Enable": [
- "funlen"
- ]
-}
-```
-
-commandline:
-
-```bash
-gometalinter --linter "funlen:funlen -l=50 -s=35:PATH:LINE:COL:MESSAGE" --enable "funlen"
-```
+Funlen is included in [golangci-lint](https://github.com/golangci/golangci-lint/). Install it and enable funlen.
diff --git a/vendor/github.com/ultraware/funlen/main.go b/vendor/github.com/ultraware/funlen/main.go
index 19e48e2ff..2ba353002 100644
--- a/vendor/github.com/ultraware/funlen/main.go
+++ b/vendor/github.com/ultraware/funlen/main.go
@@ -7,8 +7,10 @@ import (
"reflect"
)
-const defaultLineLimit = 60
-const defaultStmtLimit = 40
+const (
+ defaultLineLimit = 60
+ defaultStmtLimit = 40
+)
// Run runs this linter on the provided code
func Run(file *ast.File, fset *token.FileSet, lineLimit, stmtLimit int) []Message {
@@ -26,13 +28,17 @@ func Run(file *ast.File, fset *token.FileSet, lineLimit, stmtLimit int) []Messag
continue
}
- if stmts := parseStmts(decl.Body.List); stmts > stmtLimit {
- msgs = append(msgs, makeStmtMessage(fset, decl.Name, stmts, stmtLimit))
- continue
+ if stmtLimit > 0 {
+ if stmts := parseStmts(decl.Body.List); stmts > stmtLimit {
+ msgs = append(msgs, makeStmtMessage(fset, decl.Name, stmts, stmtLimit))
+ continue
+ }
}
- if lines := getLines(fset, decl); lines > lineLimit {
- msgs = append(msgs, makeLineMessage(fset, decl.Name, lines, lineLimit))
+ if lineLimit > 0 {
+ if lines := getLines(fset, decl); lines > lineLimit {
+ msgs = append(msgs, makeLineMessage(fset, decl.Name, lines, lineLimit))
+ }
}
}