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.2.0.tar.gz (15.8 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.2.0-py3-none-any.whl (13.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: radon_ci-0.2.0.tar.gz
  • Upload date:
  • Size: 15.8 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.2.0.tar.gz
Algorithm Hash digest
SHA256 ab2cd649213f5a4df3ac9f14bd4e9025b90a176acc862e223eed907fc8757b99
MD5 c25305a15bb6e523263acc353f554554
BLAKE2b-256 4b49c4295c346d585edae92419b5205c24febec2d6de6ff8d5ed0eb86e74f347

See more details on using hashes here.

File details

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

File metadata

  • Download URL: radon_ci-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 13.8 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.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d89f71cfd36d5ab45421411e3f314e44b71b4a49c43474ff8610634daeef6bbd
MD5 00e8d74963ab6eb39ed427a3887a5379
BLAKE2b-256 f86a8d9c9e36b06f44f6c7c393a540442d44d370259beec4d0e41da94a987f0b

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