argon-0.3.1.0: Measure your code's complexity

Copyright(c) 2015 Michele Lacchia
LicenseISC
MaintainerMichele Lacchia <michelelacchia@gmail.com>
Stabilityalpha
Portabilityportable
Safe HaskellNone
LanguageHaskell2010

Argon

Contents

Description

Programmatic interface to Argon.

Synopsis

Types

type AnalysisResult = Either String [ComplexityBlock] Source

Represent the result of the analysis of one file. It can either be an error message or a list of ComplexityBlocks.

newtype ComplexityBlock Source

Hold the data associated to a function binding: (location, function name, complexity).

Constructors

CC (Loc, String, Int) 

data OutputMode Source

Type describing how the results should be exported.

Constructors

BareText

Text-only output, no colors.

Colored

Text-only output, with colors.

JSON

Data is serialized to JSON.

data Config Source

Type holding all the options passed from the command line.

Constructors

Config 

Fields

minCC :: Int

Minimum complexity a block has to have to be shown in results.

outputMode :: OutputMode

Describe how the results should be exported.

type Loc = (Int, Int) Source

Type synonym representing a location in the source code. The tuple represents the following: (start line, start col).

type LModule = Located (HsModule RdrName) Source

Type synonym for a syntax node representing a module tagged with a SrcSpan

Parsing

analyze Source

Arguments

:: FilePath

The filename corresponding to the source code

-> IO (FilePath, AnalysisResult) 

Parse the code in the given filename and compute cyclomatic complexity for every function binding.

parseModule :: FilePath -> IO (Either String LModule) Source

Parse a module with the default instructions for the C pre-processor

Manipulating results

order :: [ComplexityBlock] -> [ComplexityBlock] Source

Order a list of blocks. Ordering is done with respect to:

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

filterResults :: Config -> (FilePath, AnalysisResult) -> (FilePath, AnalysisResult) Source

Filter the results of the analysis, with respect to the given Config.

export :: Config -> [(FilePath, AnalysisResult)] -> String Source

Export analysis' results. How to export the data is defined by the Config parameter.