Skip to content

Commit 262c700

Browse files
committed
Accept negative limits to skip checks
1 parent 8b55b30 commit 262c700

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

main.go

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ import (
77
"reflect"
88
)
99

10-
const defaultLineLimit = 60
11-
const defaultStmtLimit = 40
10+
const (
11+
defaultLineLimit = 60
12+
defaultStmtLimit = 40
13+
)
1214

1315
// Run runs this linter on the provided code
1416
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
2628
continue
2729
}
2830

29-
if stmts := parseStmts(decl.Body.List); stmts > stmtLimit {
30-
msgs = append(msgs, makeStmtMessage(fset, decl.Name, stmts, stmtLimit))
31-
continue
31+
if stmtLimit > 0 {
32+
if stmts := parseStmts(decl.Body.List); stmts > stmtLimit {
33+
msgs = append(msgs, makeStmtMessage(fset, decl.Name, stmts, stmtLimit))
34+
continue
35+
}
3236
}
3337

34-
if lines := getLines(fset, decl); lines > lineLimit {
35-
msgs = append(msgs, makeLineMessage(fset, decl.Name, lines, lineLimit))
38+
if lineLimit > 0 {
39+
if lines := getLines(fset, decl); lines > lineLimit {
40+
msgs = append(msgs, makeLineMessage(fset, decl.Name, lines, lineLimit))
41+
}
3642
}
3743
}
3844

0 commit comments

Comments
 (0)