Calculate code metrics in various languages
Project description
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
- Difficulty according to Halstead
- Effort according to Halstead
- Fan-Out
- Lines of code
- Maintainability index
- Metric according to pylint
- Metric according to TIOBE
- Number of delivered bugs according to Halstead
- Time required to program according to Halstead
- Volume according to Halstead
This tool was heavily inspired by metrics
Installation
PyPi
simply run
pip3 install multimetric
From source
- git clone this repository
- cd to <clone folder>
- Install the needed requirements by running pip3 install -r requirements.txt
- run python3 setup.py build
Usage
usage: multimetric [-h] [--warn_compiler WARN_COMPILER] [--warn_duplication WARN_DUPLICATION] [--warn_functional WARN_FUNCTIONAL] [--warn_standard WARN_STANDARD] [--warn_security WARN_SECURITY] [--coverage COVERAGE] [--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 --warn_compiler WARN_COMPILER File(s) holding information about compiler warnings --warn_duplication WARN_DUPLICATION File(s) holding information about code duplications --warn_functional WARN_FUNCTIONAL File(s) holding information about static code analysis findings --warn_standard WARN_STANDARD File(s) holding information about language standard violations --warn_security WARN_SECURITY File(s) File(s) holding information about found security issue --coverage COVERAGE File(s) with compiler warningsFile(s) holding information about testing coverage --bugpredict {old,new} Method how to calculate the bug prediction --maintindex {sei,classic,microsoft} Method how to calculate the maintainability index Currently you could import files of the following types for --warn_* or --coverage Following information can be read <file> = full path to file <content> = either a string <severity> = optional severity Note: you could also add a single line, then <content> has to be a number reflecting to total number of findings File formats csv: CSV file of following line format <file>,<content>,<severity> json: JSON file <file>: { "content": <content>, "severity": <severity> }
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
- stats contains the statistically calculated values over all files passed see Statistical additions
Item structure
item | description | ran ge | recommen dation |
---|---|---|---|
comment_ratio | Comment to Code percentage | 0.. 100 | > 30.0 |
cyclomatic_co mplexity | Cyclomatic complexity according to McCabe | 0.. (in f) | < 10 |
fanout_extern al | Number imports from out of tree modules | 0.. (in f) | |
fanout_intern al | Number imports from same source tree modules | 0.. (in f) | |
halstead_bugp rop | Number of delivered bugs according to Halstead | 0.. (in f) | < 0.05 |
halstead_diff iculty | Difficulty according to Halstead | 0.. (in f) | |
halstead_effo rt | Effort according to Halstead | 0.. (in f) | |
halstead_time required | Time required to program according to Halstead | 0.. (in f) | |
halstead_volu me | Volume according to Halstead | 0.. (in f) | |
lang | list of identified programming languages | lis t | |
loc | Lines of code | 1.. (in f) | |
maintainabili ty_index | Maintainability index | 0.. 100 | > 80.0 |
operands_sum | Number of used operands | 1.. (in f) | |
operands_uniq | Number of unique used operands | 1.. (in f) | |
operators_sum | Number of used operators | 1.. (in f) | |
operators_uni q | Number of unique used operators | 1.. (in f) | |
pylint | General quality score according to pylint | 0.. 100 | > 80.0 |
tiobe_compile r | Compiler warnings score according to TIOBE | 0.. 100 | > 90.0 |
tiobe_complex ity | Complexity according to TIOBE | 0.. 100 | > 80.0 |
tiobe_coverag e | Coverage according to TIOBE | 0.. 100 | > 80.0 |
tiobe_duplica tion | Code duplications score according to TIOBE | 0.. 100 | > 80.0 |
tiobe_fanout | Fan-Out score according to TIOBE | 0.. 100 | > 80.0 |
tiobe_functio nal | Functional defect score according to TIOBE | 0.. 100 | > 90.0 |
tiobe_securit y | Security score according to TIOBE | 0.. 100 | > 90.0 |
tiobe_standar d | Language standard score according to TIOBE | 0.. 100 | > 80.0 |
tiobe | General quality score according to TIOBE | 0.. 100 | > 80.0 |
Statistics
The item stats contains in addition to the above mentioned the following items, which by themselves contain all the items mentioned at Item structure
- max = the maximum value of all items of the metric
- mean = statistical mean over all items of the metric
- median = statistical median over all items of the metric
- min = the minimum value of all items of the metric
- sd = standard deviation over all items of the metric
Further reading
Bugs & Contribution
Feel free to create issues or pull requests
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Filename, size | File type | Python version | Upload date | Hashes |
---|---|---|---|---|
Filename, size multimetric-1.2.0.tar.gz (17.7 kB) | File type Source | Python version None | Upload date | Hashes View |