Coder Social home page Coder Social logo

abcgo's Introduction

ABCGo

Go Report Card Build Status GoDoc

ABC metrics for Go source code.

Definition

ABCGo uses these rules to calculate ABC:

  • Add one to the assignment count when:
    • Occurrence of an assignment operator: =, *=, /=, %=, +=, <<=, >>=, &=, ^=.
    • Occurrence of an increment or a decrement operator: ++, --.
  • Add one to branch count when:
    • Occurrence of a function call.
  • Add one to condition count when:
    • Occurrence of a conditional operator: <, >, <=, >=, ==, !=.
    • Occurrence of the following keywords: else, case.

Final score is calculated as follows:

Read more about ABC metrics.

Getting Started

Installation

$ go get -u github.com/droptheplot/abcgo
$ (cd $GOPATH/src/github.com/droptheplot/abcgo && go install)

Usage

Single file

$ abcgo -path main.go
Source       Func   Score   A   B    C
main.go:28   init   9       1   8    5
main.go:54   main   13      5   13   1

Directory

$ abcgo -path ./
Source            Func            Score   A   B    C
main.go:28        init            9       1   8    5
main.go:54        main            13      5   13   1
main_test.go:54   TestSomething   9       0   9    2

JSON

$ abcgo -path main.go -format json
[
  {
    "path": "main.go",
    "line": 54,
    "name": "main",
    "assignment": 5,
    "branch": 13,
    "condition": 1,
    "score": 13
  },
  {
    "path": "main.go",
    "line": 54,
    "name": "init",
    "assignment": 1,
    "branch": 8,
    "condition": 5,
    "score": 9
  }
]

Raw

(source, line, function name, score)

$ abcgo -path main.go -format raw
main.go 28 init 9
main.go 54 main 13
main_test.go 54 TestSomething 9

Summary

$ abcgo -path ./ -format summary
                   A    B    C
Project summary:   22   43   15

Options

  • -path [path] - Path to file or directory.
  • -format [format] - Output format (table (default), raw or json).
  • -sort - Sort functions by score.
  • -no-test - Skip *_test.go files.

Plugins

abcgo's People

Contributors

collinalexbell avatar droptheplot avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.