funlen

package module
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 8, 2019 License: MIT Imports: 4 Imported by: 0

README

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:

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

go get git.ultraware.nl/NiseVoid/funlen
Gometalinter

You can add funlen to gometalinter and enable it.

.gometalinter.json:

{
	"Linters": {
		"funlen": "funlen -l=50 -s=35:PATH:LINE:COL:MESSAGE"
	},

	"Enable": [
		"funlen"
	]
}

commandline:

gometalinter --linter "funlen:funlen -l=50 -s=35:PATH:LINE:COL:MESSAGE" --enable "funlen"

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Message

type Message struct {
	Pos     token.Position
	Message string
}

Message contains a message

func Run

func Run(file *ast.File, fset *token.FileSet, lineLimit, stmtLimit int) []Message

Run runs this linter on the provided code

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL