mixingcheck
mixingcheck is a static analyzer to check forbidden structs and method calls.
Installation
Execute:
$ go get github.com/ormanli/mixingcheck
Or using Homebrew 🍺
brew tap ormanli/mixingcheck https://github.com/ormanli/mixingcheck
brew install mixingcheck
Or download from Releases page.
How to use
Add .mixingcheck.yaml
to your project.
github.com/ormanli/mixingcheck: #1
rules:
- package: #2
value: github.com/spf13/viper
name:
value: NewWithOptions
type: call #3
- package:
value: github.com/ormanli/mixingcheck/internal/config
name:
value: Packages
type: struct
github.com/ormanli/mixingcheck/internal: #4
ignore_parent_rules: true #5
rules:
- package:
value: regexp
name:
regex: true #6
value: .*
type: struct
- Name of the package you want to execute rules.
- The package that contains struct or function you want to check for rule match.
- Type is either struct or call.
- It is possible to define additional rules for child packages.
- If a is true, parent packages rules ignored.
- If regex is true, value can be a regular expression.
Run mixingcheck, if there is any error it won't return zero.
$ mixingcheck .
Using config file: ~/ormanli/git/mixingcheck/.mixingcheck.yaml
~/ormanli/git/mixingcheck/main.go:13:19: hit struct rule github.com/ormanli/mixingcheck/internal/config.Packages
~/ormanli/git/mixingcheck/main.go:26:8: hit struct rule github.com/ormanli/mixingcheck/internal/config.Packages
~/ormanli/git/mixingcheck/main.go:14:7: hit call rule github.com/spf13/viper.NewWithOptions