Anticycle is a tool for static code analysis which search for dependency cycles. It scans recursively all source files and parses theirs dependencies. Anticycle does not compile the code, so it is ideal for searching for complex, difficult to debug cycles.
Anticycle is published under GNU GENERAL PUBLIC LICENSE Version 3, from 29 June 2007
You may need sudo privileges to unpack into system specific directories.
- Download binary from latest release.
- Unpack binary to your PATH for example:
tar xvf anticycle.linux-amd64.tar.gz -C /usr/local/bin
- Verify installation:
anticycle -version
anticycle [options] [directory]
-all Output all packages, with and without cycles.
-format="text" Output format. Available: text, json.
-exclude="" A space-separated list of directories that should
not be scanned. The list will be added to the
default list of directories.
-excludeDefault="" A space-separated list of directories that should
not be scanned. The list will override the default.
-showExcluded Shows list of excluded directories.
-help Shows this help text.
-version Shows version and build hash.
An optional path to the analyzed project. If the directory is not defined, the current working directory will be used.
Analyze recursively from current working directory but skip internal/
anywhere in dir tree.
$ anticycle -exclude="internal"
Analyze recursively given directory with JSON output format
$ anticycle -all -format=json $GOPATH/src/github.com/anticycle/anticycle
Real case scenario:
Command without flags and directories.
$ cd $GOPATH/src/github.com/Juniper/contrail
$ anticycle
Found 4 cycles
db -> models -> db
ipam -> models -> db -> models
models -> db -> models
services -> models -> db -> models
Details
[db -> models] "github.com/Juniper/contrail/pkg/models"
pkg/db/address_manager.go
pkg/db/address_manager_test.go
pkg/db/db.go
pkg/db/db_test.go
pkg/db/useragent_kv.go
[models -> db] "github.com/Juniper/contrail/pkg/db"
pkg/models/validation.go
[services -> models] "github.com/Juniper/contrail/pkg/models"
pkg/services/contrail_service_test.go
pkg/services/event_test.go
pkg/services/list_response_test.go
[ipam -> models] "github.com/Juniper/contrail/pkg/models"
pkg/types/ipam/address_manager.go
How to read:
[package -> wants] "fully/qualified/import/name"
path/to/affected/file.go
path/to/another/file.go
This gives us a hint that few files in db
package wants to import models
, but
validation.go
file in models
want to import db
package.
The cycle looks like: db -> models -> db
.
Require GO v1.11.x
Make sure you have GO in version 1.11. If not, follow official instructions.
Use Make
to run tests, benchmarks, build process and more.
sudo apt install make
$ make help
$ go get github.com/anticycle/anticycle
$ make devdeps install test-all
After each change use make install
to update dev binary. Then run sanity tests.
Sanity tests are called on built binary, not the source code.
Make sure you had installed anticycle in your OS before run sanity or acceptance tests.
$ make test-unit test-sanity test-acceptance
or just
$ make test
Artifacts will be moved to /bin directory after building.
$ make build tarball
Your help is very desirable. We are open to all kinds of contribution:
- Reporting found bugs
- Requesting new features
- Typos or bug fixing
- Filling gaps in documentation
- Creating new features
- Building tools for other contributors
If you don't know how to GO, you can report a bug or request a new feature by creating new issue at https://github.com/anticycle/anticycle/issues
If you want to be involved in development:
- Fork this repository.
- Create new issue with description of what you are plan to do.
- Create new feature or bug branch in your forked repository.
- Make changes, and create pull request to our master branch.
- Attach pull request to issue and wait for community response.
- always follow conventions found in this repository
- be kind to other contributors and never attack them for any reason
- if you are reviewing pull requests, focus on source code, never on developer who wrote it
- always write a unittests
- if it is required create new sanity or end-to-end test