MyNixOS website logo
Description

Measure your code's complexity.

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 files or directories to analyze. The data can be optionally exported to JSON.

Argon

Tests Code coverage License Version

Argon measures your code's cyclomatic complexity.

Argon screenshot


Installing

Simple as stack install argon or cabal install argon. Note: if you are using Stack and your resolver if too old, you might have to add some packages to your stack.yaml file.

GHC compatibility

Argon is compatible with GHC 7.8 and 7.10, it's tested against those versions only.

Running

The Argon executable expects a list of file paths (files or directories):

$ argon --no-color --min 2 src
src/Argon/Types.hs
    61:5 toJSON - 2
src/Argon/Visitor.hs
    55:1 visitExp - 5
    62:1 visitOp - 4
    28:11 visit - 2
    35:1 getFuncName - 2
src/Argon/Parser.hs
    55:1 parseModuleWithCpp - 3
    88:1 customLogAction - 3
    35:1 analyze - 2
    39:9 analysis - 2
src/Argon/Formatters.hs
    61:1 formatResult - 3
    42:1 coloredFunc - 2
    43:11 color - 2
src/Argon/Results.hs
    35:1 export - 3
    28:1 filterResults - 2
src/Argon/Loc.hs
    18:11 toRealSrcLoc - 2

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

  1. complexity (descending)
  2. line number (ascending)
  3. alphabetically

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

ComplexityRank
0..5A
5..10B
above 10C

JSON

Results can also be exported to JSON:

$ argon --json --min 2 src
[
  { "blocks": [ ], "path": "src/Argon.hs", "type": "result" },
  {
    "blocks": [{ "complexity": 2, "name": "toJSON", "lineno": 61, "col": 5 }],
    "path": "src/Argon/Types.hs",
    "type": "result"
  },
  {
    "blocks": [
      { "complexity": 5, "name": "visitExp", "lineno": 55, "col": 1 },
      { "complexity": 4, "name": "visitOp", "lineno": 62, "col": 1 },
      { "complexity": 2, "name": "visit", "lineno": 28, "col": 11 },
      { "complexity": 2, "name": "getFuncName", "lineno": 35, "col": 1 }
    ],
    "path": "src/Argon/Visitor.hs",
    "type": "result"
  },
  {
    "blocks": [
      { "complexity": 3, "name": "parseModuleWithCpp", "lineno": 55, "col": 1 },
      { "complexity": 3, "name": "customLogAction", "lineno": 88, "col": 1 },
      { "complexity": 2, "name": "analyze", "lineno": 35, "col": 1 },
      { "complexity": 2, "name": "analysis", "lineno": 39, "col": 9 }
    ],
    "path": "src/Argon/Parser.hs",
    "type": "result"
  },
  {
    "blocks": [
      { "complexity": 3, "name": "formatResult", "lineno": 61, "col": 1 },
      { "complexity": 2, "name": "coloredFunc", "lineno": 42, "col": 1 },
      { "complexity": 2, "name": "color", "lineno": 43, "col": 11 }
    ],
    "path": "src/Argon/Formatters.hs",
    "type": "result"
  },
  {
    "blocks": [
      { "complexity": 3, "name": "export", "lineno": 35, "col": 1 },
      { "complexity": 2, "name": "filterResults", "lineno": 28, "col": 1 }
    ],
    "path": "src/Argon/Results.hs",
    "type": "result"
  },
  {
    "blocks": [{ "complexity": 2, "name": "toRealSrcLoc", "lineno": 18, "col": 11 }],
    "path": "src/Argon/Loc.hs",
    "type": "result"
  },
  { "blocks": [ ], "path": "src/Argon/Preprocess.hs", "type": "result" }
]
Metadata

Version

0.4.1.0

License

Platforms (75)

    Darwin
    FreeBSD 13
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd13
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd13
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows