argon: Measure your code's complexity

[ development, static-analysis ] [ Propose Tags ]

Argon performs static analysis on your code in order to compute cyclomatic complexity. It is a quantitative measure of the number of linearly indipendent paths through the code.

The intended usage is through Argon's executable, which accepts a list of file paths to analyze. The data can be optionally exported to JSON.


[Skip to Readme]

Modules

[Index]

Downloads

Note: This package has metadata revisions in the cabal description newer than included in the tarball. To unpack the package including the revisions, use 'cabal get'.

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0.0, 0.2.0.0, 0.3.0.0, 0.3.1.0, 0.3.1.1, 0.3.1.2, 0.3.2.0, 0.4.0.0, 0.4.1.0
Change log CHANGELOG.md
Dependencies aeson (>=0.8 && <0.11), ansi-terminal (>=0.6), argon, base (>=4.7 && <5), bytestring (>=0.10), containers (>=0.5), directory (>=1.2), docopt (>=0.7), filepath (>=1.4), ghc (>=7.10.2 && <8), ghc-paths (>=0.1), pathwalk (>=0.3), syb (>=0.5) [details]
License ISC
Copyright 2015 Michele Lacchia
Author Michele Lacchia
Maintainer michelelacchia@gmail.com
Revised Revision 1 made by phadej at 2016-02-10T09:00:42Z
Category Web
Home page http://github.com/rubik/argon
Bug tracker http://github.com/rubik/argon/issues
Source repo head: git clone https://github.com/rubik/argon
Uploaded by rubik at 2015-10-27T16:47:50Z
Distributions
Executables argon
Downloads 7152 total (24 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2015-10-30 [all 1 reports]

Readme for argon-0.3.0.0

[back to package description]

Argon

Tests License Version

Argon measures your code's cyclomatic complexity.

Argon screenshot


Installing

Simple as stack install argon or cabal install argon.

Running

The Argon executable expects a list of file paths:

$ argon --no-color src/**/*.hs
src/Argon/Formatters.hs
    47:1 formatResult - 3
    33:1 coloredFunc - 2
    27:1 fore - 1
    37:1 coloredRank - 1
src/Argon/Parser.hs
    51:1 parseCode - 2
    44:1 handleExc - 1
src/Argon/Results.hs
    17:1 filterResults - 2
    22:1 export - 2
src/Argon/Visitor.hs
    35:1 visitExp - 5
    42:1 visitOp - 4
    14:1 funCC - 3
    16:11 name - 2
    11:1 funcsCC - 1
    20:1 sumWith - 1
    23:1 complexity - 1
    28:11 descend - 1
    32:11 inspect - 1

For every file, Argon sorts results with the following criteria (and in this order):

* complexity (descending)
* line number (ascending)
* alphabetically

When colors are enabled (default), Argon computes a rank associated with the coomplexity score:

Complexity Rank
0..5 A
5..10 B
above 10 C

JSON

Results can also be exported to JSON:

$ argon --json src/**/*.hs
[
  {
    "blocks": [
      { "complexity": 3, "name": "formatResult", "lineno": 58, "col": 1 },
      { "complexity": 2, "name": "coloredFunc", "lineno": 39, "col": 1 },
      { "complexity": 1, "name": "fore", "lineno": 33, "col": 1 },
      { "complexity": 1, "name": "coloredRank", "lineno": 43, "col": 1 },
      { "complexity": 1, "name": "formatSingle", "lineno": 52, "col": 1 }
    ],
    "path": "src/Argon/Formatters.hs",
    "type": "result"
  },
  { "blocks": [ ], "path": "src/Argon.hs", "type": "result" },
  {
    "blocks": [
      { "complexity": 2, "name": "parseCode", "lineno": 55, "col": 1 },
      { "complexity": 1, "name": "handleExc", "lineno": 48, "col": 1 }
    ],
    "path": "src/Argon/Parser.hs",
    "type": "result"
  },
  {
    "blocks": [
      { "complexity": 3, "name": "export", "lineno": 35, "col": 1 },
      { "complexity": 2, "name": "filterResults", "lineno": 28, "col": 1 },
      { "complexity": 1, "name": "sortOn", "lineno": 12, "col": 1 }
    ],
    "path": "src/Argon/Results.hs",
    "type": "result"
  },
  {
    "blocks": [
      { "complexity": 2, "name": "toJSON", "lineno": 30, "col": 5 },
      { "complexity": 1, "name": "toJSON", "lineno": 18, "col": 5 }
    ],
    "path": "src/Argon/Types.hs",
    "type": "result"
  },
  {
    "blocks": [
      { "complexity": 5, "name": "visitExp", "lineno": 36, "col": 1 },
      { "complexity": 4, "name": "visitOp", "lineno": 43, "col": 1 },
      { "complexity": 3, "name": "funCC", "lineno": 15, "col": 1 },
      { "complexity": 2, "name": "name", "lineno": 17, "col": 11 },
      { "complexity": 1, "name": "funcsCC", "lineno": 12, "col": 1 },
      { "complexity": 1, "name": "sumWith", "lineno": 21, "col": 1 },
      { "complexity": 1, "name": "complexity", "lineno": 24, "col": 1 },
      { "complexity": 1, "name": "descend", "lineno": 29, "col": 11 },
      { "complexity": 1, "name": "inspect", "lineno": 33, "col": 11 }
    ],
    "path": "src/Argon/Visitor.hs",
    "type": "result"
  }
]