Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kyosu-1/boolcmp
static analysis tool for Go that detects variables with bool values that use comparison operators.
https://github.com/kyosu-1/boolcmp
go static-analysis
Last synced: 26 days ago
JSON representation
static analysis tool for Go that detects variables with bool values that use comparison operators.
- Host: GitHub
- URL: https://github.com/kyosu-1/boolcmp
- Owner: kyosu-1
- Created: 2023-03-15T23:39:20.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-03-16T01:03:16.000Z (almost 2 years ago)
- Last Synced: 2024-06-20T13:23:06.683Z (7 months ago)
- Topics: go, static-analysis
- Language: Go
- Homepage:
- Size: 8.79 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 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:
```go
package mainfunc 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.