You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Socket
Socket
Sign inDemoInstall

github.com/anticycle/anticycle

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/anticycle/anticycle

Package 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 consists of three parts: 1. Main package which exists in cmd/anticycle directory. It compiles to CLI binary 2. Public API which is importable for other applications. 3. Internal, private interface which should not be imported and use directly. It may change at any moment without warnings.


Version published

Readme

Source

Anticycle

Godoc CircleCI Goreportcard Release License Platforms

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

Installation

You may need sudo privileges to unpack into system specific directories.

  1. Download binary from latest release.
  2. Unpack binary to your PATH for example: tar xvf anticycle.linux-amd64.tar.gz -C /usr/local/bin
  3. Verify installation: anticycle -version

Usage

anticycle [options] [directory]

Options

-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.

Directory

An optional path to the analyzed project. If the directory is not defined, the current working directory will be used.

Example

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

Example output

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.

Development

Require GO v1.11.x

Make sure you have GO in version 1.11. If not, follow official instructions.

Makefile

Use Make to run tests, benchmarks, build process and more.

sudo apt install make
$ make help

Download project

$ 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.

Run tests

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

Build artifacts

Artifacts will be moved to /bin directory after building.

$ make build tarball

Contribution

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:

  1. Fork this repository.
  2. Create new issue with description of what you are plan to do.
  3. Create new feature or bug branch in your forked repository.
  4. Make changes, and create pull request to our master branch.
  5. Attach pull request to issue and wait for community response.

Remember to

  • 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

FAQs

Package last updated on 21 Dec 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc