https://github.com/ormanli/mixingcheck
mixingcheck is a static analyzer to check forbidden structs and method calls.
https://github.com/ormanli/mixingcheck
cli go golang static-analysis
Last synced: about 1 year ago
JSON representation
mixingcheck is a static analyzer to check forbidden structs and method calls.
- Host: GitHub
- URL: https://github.com/ormanli/mixingcheck
- Owner: ormanli
- License: apache-2.0
- Created: 2020-07-12T17:26:11.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2023-02-23T11:06:23.000Z (over 3 years ago)
- Last Synced: 2025-03-31T07:11:15.294Z (over 1 year ago)
- Topics: cli, go, golang, static-analysis
- Language: Go
- Homepage:
- Size: 77.1 KB
- Stars: 5
- Watchers: 0
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# mixingcheck
mixingcheck is a static analyzer to check forbidden structs and method calls.
## Installation
Execute:
```bash
$ go get github.com/ormanli/mixingcheck
```
Or using [Homebrew 🍺](https://brew.sh)
```bash
brew tap ormanli/mixingcheck https://github.com/ormanli/mixingcheck
brew install mixingcheck
```
Or download from [Releases](https://github.com/ormanli/mixingcheck/releases) page.
## How to use
Add `.mixingcheck.yaml` to your project.
```yaml
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
```
1. Name of the package you want to execute rules.
2. The package that contains struct or function you want to check for rule match.
3. Type is either struct or call.
4. It is possible to define additional rules for child packages.
5. If a is true, parent packages rules ignored.
6. If regex is true, value can be a regular expression.
Run mixingcheck, if there is any error it won't return zero.
```bash
$ 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
```