aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/ultraware/funlen/README.md
blob: ca7e9a0f755e7141e97d711d39daa17e8e361af4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# Funlen linter

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)
```

## 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"
```