funcheck

command module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: May 31, 2020 License: Apache-2.0 Imports: 2 Imported by: 0

README

Funcheck

Build Status

Funcheck is a Go linter that reports non-functional constructs. There is actually only one checker (assigncheck) which reports every case where we only assign variables (x = "whatever"), not combined by a declaration (x := "whatever"). See my Bachelor thesis for more info and background.

Currently, there is one exception to the above rule:

Anonymous function assignments. As it is not possible (because of scoping rules) to recursively call an anonymous function without declaring it first, this needed to be an exception. The following code block is not valid Go:

func x() {
    y := func(i int) int {
        if i == 0 {
            return -1
        }
        return y(i-1)
    }
}

As the function y is not in scope within y's body. To work around this, the following code works:

func x() {
    var y func(int) int
    y = func(i int) int {
        if i == 0 {
            return -1
        }
        return y(i-1)
    }
}

This is why this exception exists. However, this exception needs the function's declaration to be right before the function's assignment. This is not valid:

func x() {
    var y func(int) int
    z := 5
    y = func(i int) int {
        if i == 0 {
            return -1
        }
        return y(i-1)
    }
}

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
The prettyprint package visualises a Go AST, but only assignment nodes.
The prettyprint package visualises a Go AST, but only assignment nodes.

Jump to

Keyboard shortcuts

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