Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

metrics produces metrics for C, C++, Javascript, and Python programs

Project Description

metrics

The original idea of metrics was a platform that can be extended with many different metrics. At the time I will focus only on SLOC and McCabe complexity metrics but keep its extensibility. metrics is build in a way to support many, many languages supported languages. Currently we test support for C, C++, JavaScript, and Python.

The SLOC metric counts the lines but excludes empty lines and comments. This is sometimes referred to as the source lines of code (SLOC). In literature this is often also referred as physical lines of code. I simplified it to something which to my understanding is the common denominator for the metric packages I looked into (CCCC, SLOCCount, PyMetrics, Eclipse-Metrics, Ohcount).

Another thing I wanted to mention is that I borrowed the sample programming language files for the test cases from Ohcount and Firefox.

Sample use

Get an overview on a package (number of files, used languages, and metrics):

$ metrics **/*
Metrics Summary:
Files                       Language        SLOC Comment McCabe
----- ------------------------------ ----------- ------- ------
    6                              C          14       3      0
    3                            C++        1114     236    108
    1                            INI           5       0      0
    2                           Java          27       8      1
    3                     JavaScript        1453      54    169
    1                       markdown           7       0      0
   18                         Python        1038     425    238
   11                      Text only           0       0      0
----- ------------------------------ ----------- ------- ------
   45                          Total        3658     726    516

Note how you can use glob file pattern or a list of files…

Usage help:

$ metrics --help
Options:
  --version             show program's version number and exit
  -h, --help            show this help message and exit
  -f IN_FILE_LIST, --files=IN_FILE_LIST
                        File containing list of path names to modules for
                        analysis.
  -i INCLUDE_METRICS_STR, --include=INCLUDE_METRICS_STR
                        list of metrics to include in run. This is a comma
                        separated list of metric module names with no
                        whitespace. Optionally, you can specify the class name
                        of the metric by following the module name with a
                        colon (:) and the metric class name. (Default metrics
                        are 'mccabe:McCabeMetric,sloc:SLOCMetric'. Default
                        metric class name for metric module 'wxYz' is
                        'WxYzMetric' when only module name given -- note
                        capitalized metric class name.)
  -l LIB_NAME, --library=LIB_NAME
                        user-defined name applied to collection of modules
                        (Default is '')
  -q, --quiet           suppress normal summary output to stdout. (Default is
                        False)
  --format=OUTPUT_FORMAT_STR
                        Choose an output format for a parser to read. Valid
                        choices: xml, csv

Get a detailed report:

$ metrics -q --format=csv metrics/metrics.py
filename,mccabe,ratio_comment_to_code,language,comments,sloc
metrics/metrics.py,24,0.39,Python,55,140

Same detailed report but output to csv file:

$ metrics -q --format=csv metrics/metrics.py > output.csv

License

Copyright (c) 2017 Fink Labs GmbH and others. metrics is released under the MIT License (see MIT_LICENSE).

Release History

Release History

This version
History Node

0.2.8

History Node

0.2.7

History Node

0.2.6

History Node

0.2.5

History Node

0.2.4

History Node

0.2.3

History Node

0.2.2

History Node

0.2.1

History Node

0.2.0

History Node

0.1a3

History Node

0.1a2

Download Files

Download Files

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

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
metrics-0.2.8.tar.gz (13.0 kB) Copy SHA256 Checksum SHA256 Source Oct 21, 2017

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting