Skip to content

static analysis tool for Go that detects variables with bool values that use comparison operators.

Notifications You must be signed in to change notification settings

kyosu-1/boolcmp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

boolcmp

The boolcmp tool is a static analysis tool for Go that detects variables with bool values that use comparison operators, and reports them as potentially simplifiable.

install

$ go install github.com/kyosu-1/boolcmp

Usage

$ go vet -vettool=$(which boolcmp) path/to/your/package

Example

Consider the following Go code:

package main

func main() {
    var a bool = true
    if a == true {
        // do something
    }
}

The boolcmp tool will detect the comparison a == true and report it as a warning. The output might look something like this:

main.go:5:10: bool value used in comparison

The warning indicates that the comparison a == true can be simplified to just a. This can make the code more concise and easier to read, since the comparison with true is unnecessary.

About

static analysis tool for Go that detects variables with bool values that use comparison operators.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages