Skip to main content

Calculate code metrics in various languages

Project description

Build status PyPI version Python version Downloads Language grade: Python

Calculate code metrics in various languages

Purpose

This tool tries to calculate the following metrics for many, many programming languages

  • Comment to Code percentage

  • Cyclomatic complexity according to McCabe

  • Number of delivered bugs according to Halstead

  • Time required to program according to Halstead

  • Difficulty according to Halstead

  • Volume according to Halstead

  • Effort according to Halstead

  • Lines of code

  • Maintainability index

This tool was heavily inspired by metrics

Requirements

Installation

PyPi

simply run

pip3 install multimetric

From source

  • Install the needed requirements by running pip3 install pygments

  • git clone this repository

  • cd to <clone folder>

  • run python3 setup.py build

Usage

usage: multimetric [-h] [--bugpredict {old,new}]
                   [--maintindex {sei,classic,microsoft}]
                   files [files ...]

Calculate code metrics in various languages

positional arguments:
  files                 Files to parse

optional arguments:
  -h, --help            show this help message and exit
  --bugpredict {old,new}
                        Method how to calculate the bug prediction
  --maintindex {sei,classic,microsoft}
                        Method how to calculate the maintainability index

By default tool guesses the content type by the filename, if that doesn’t work for you please see below

Output

Output will be written to stdout as json.

Output structure

  • files contains a list of each file passed by CLI

  • overall contains the calculated values for all passed files

Item structure

  • comment_ratio = Comment to Code percentage

  • cyclomatic_complexity = Cyclomatic complexity according to McCabe

  • halstead_bugprop = Number of delivered bugs according to Halstead

  • halstead_timerequired = Time required to program according to Halstead

  • halstead_difficulty = Difficulty according to Halstead

  • halstead_volume = Volume according to Halstead

  • halstead_effort = Effort according to Halstead

  • lang = list of idendified programming languages

  • loc = Lines of code

  • maintainability_index = Maintainability index

  • operands_sum = Number of used operands

  • operands_uniq = Number of unique used operands

  • operators_sum = Number of used operators

  • operators_uniq = Number of unique used operators

Further reading

Bugs & Contribution

Feel free to create issues or pull requests

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

multimetric-1.0.4.tar.gz (7.1 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page