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 details)

Uploaded Source

File details

Details for the file multimetric-1.0.4.tar.gz.

File metadata

  • Download URL: multimetric-1.0.4.tar.gz
  • Upload date:
  • Size: 7.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.1.0 requests-toolbelt/0.9.1 tqdm/4.41.0 CPython/3.7.5

File hashes

Hashes for multimetric-1.0.4.tar.gz
Algorithm Hash digest
SHA256 19b66da3f450c142a86f274b7cc4a5599d586bfe39e666dddd79f2674e48bff6
MD5 6b4980fadf29e19defcf654f7ded426e
BLAKE2b-256 1d204c700c02c70b6f498ad253b34a398d651044340172ed0ab92d9c39e54646

See more details on using hashes here.

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