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.3.0.tar.gz (17.6 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.3.0-py3-none-any.whl (15.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: radon_ci-0.3.0.tar.gz
  • Upload date:
  • Size: 17.6 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.3.0.tar.gz
Algorithm Hash digest
SHA256 4052547e782d8cf28b6cd5ad1a654ed36314b1e3ea8bac971eb92caa6e6fa6b9
MD5 cf23847f860eb535eaabd6e24dba2631
BLAKE2b-256 f9df2ec1648857ab5454ca3d89c64e479027d961de1a64ee44c333ec4d40863c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: radon_ci-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 15.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.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ad85a53c8ab6fd19cda2a1d539a05502b33a7b1843924e7db4e5d278beb30ba8
MD5 e3b7b281ccb46f82150fabe47a247ff2
BLAKE2b-256 ef0e3e95e8bccb5f33959e362ee32c6909dfc8ce611ecd64752296db63f680a3

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