Skip to main content

Tool for Radon-based cyclomatic complexity and maintainability reports in CI/CD pipelines

Project description

Radon CI

A Python script that uses Radon to compute Cyclomatic Complexity and Mantainability Index, and generates output files in OpenMetrics and CodeClimate format. Mainly intended to run in Gitlab CI pipelines.

Disclaimer: Source code is entirely AI-generated.

Installation

First, create a virtual environment, for example using venv:

python3.13 -m venv .venv
source .venv/bin/activate

Then install the package:

pip install .

Or in editable mode:

pip install -e .

Usage

To see the full list of program options, type:

radon-ci --help

Example usage:

(.venv) /path/to/radon-ci$ radon-ci --openmetrics-output metrics.txt --codeclimate-output codeclimate.json --halstead-output halstead.txt src
Code quality report
===================
Source directory    : /path/to/radon-ci/src
Python files        : 3
Code blocks         : 37
Average CC          : 3.08 (rank A)
CC threshold        : <= 10.00 [PASS]
Average MI          : 66.83 (rank A, good)
MI threshold        : >= 50.00 [PASS]
OpenMetrics file    : /path/to/radon-ci/metrics.txt
Code Climate file   : /path/to/radon-ci/codeclimate.json
Code Climate issues : 2
Halstead text file  : /path/to/radon-ci/halstead.txt
Overall status      : PASS

Halstead metrics totals
=======================
h1                 15.000000
h2                 89.000000
N1                 55.000000
N2                 105.000000
vocabulary         104.000000
length             160.000000
calculated_length  615.839053
volume             1050.094090
difficulty         8.787356
effort             8665.475894
time               481.415327
bugs               0.350031

Cyclomatic Complexity breakdown
===============================
src/radon_ci/__init__.py
src/radon_ci/__main__.py
src/radon_ci/cli.py
    F 555:0 main - C (13)
    F 445:0 build_codeclimate_issues - B (8)
    F 145:0 compute_metrics - B (7)
    F 518:0 print_summary - B (6)
    F 109:0 safe_float - A (5)
    F 303:0 block_letter_color - A (4)
    F 323:0 print_all_cc_blocks - A (4)
    F 390:0 severity_for_cc - A (4)
    F 399:0 severity_for_mi - A (4)
    F 40:0 supports_color - A (3)
    F 54:0 iter_python_files - A (3)
    F 60:0 block_letter - A (3)
    F 94:0 mi_rank - A (3)
    F 134:0 collect_blocks_by_file - A (3)
    F 251:0 build_halstead_text_output - A (3)
    F 271:0 mi_color_label - A (3)
    F 357:0 print_mi_breakdown - A (3)
    F 415:0 build_codeclimate_issue - A (3)
    F 48:0 colorize - A (2)
    F 72:0 block_display_name - A (2)
    F 121:0 empty_halstead_totals - A (2)
    F 125:0 halstead_report_to_dict - A (2)
    F 129:0 add_halstead_totals - A (2)
    F 210:0 build_openmetrics - A (2)
    F 267:0 status_label - A (2)
    F 279:0 format_score - A (2)
    F 283:0 relative_display_path - A (2)
    F 291:0 cc_score_color - A (2)
    F 297:0 mi_score_color - A (2)
    F 380:0 print_halstead_totals - A (2)
    F 410:0 fingerprint_for_issue - A (2)
    F 68:0 block_complexity - A (1)
    F 78:0 block_col_offset - A (1)
    F 82:0 build_block_record - A (1)
    F 102:0 build_file_mi_record - A (1)
    F 313:0 format_cc_rank_and_score - A (1)
    F 318:0 format_mi_rank_and_score - A (1)

Maintainability Index breakdown
===============================
src/radon_ci/__init__.py - A (100)
src/radon_ci/__main__.py - A (84.58)
src/radon_ci/cli.py - B (15.90)

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

radon_ci-0.1.0.tar.gz (13.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

radon_ci-0.1.0-py3-none-any.whl (12.5 kB view details)

Uploaded Python 3

File details

Details for the file radon_ci-0.1.0.tar.gz.

File metadata

  • Download URL: radon_ci-0.1.0.tar.gz
  • Upload date:
  • Size: 13.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.14

File hashes

Hashes for radon_ci-0.1.0.tar.gz
Algorithm Hash digest
SHA256 99a4c79bca5a448328105234dff7d96c5c78b1e594b8cea22906d8f8e572d030
MD5 73e9e6996811cd9277e0f15c00be38ab
BLAKE2b-256 ff2837f75a7e6f43fc05c74f5ef57f3e366aa8aea3a40420b163a3dee27607b8

See more details on using hashes here.

File details

Details for the file radon_ci-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: radon_ci-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 12.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.14

File hashes

Hashes for radon_ci-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e9063ec29a3ac46fa41bf637c63f5390ad4f7f51683b5c7bc976fc70ca0b4964
MD5 5691fe0a9c68e984cf7142278662748e
BLAKE2b-256 da1adfde543ceb694309f8bc51f5bae50325f3a202f27afbc2f9ed6d89fa198d

See more details on using hashes here.

Supported by

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