Skip to main content

A Pylint-style scoring system for Ruff linter output

Project description

Ruff Score 🎯

A Pylint-style scoring system for Ruff linter output. Get a numerical quality score (0-10) for your Python code based on Ruff's analysis.

Features

  • 🎯 Pylint-style scoring: Familiar 0-10 quality score system
  • 🔧 Ruff integration: Built on top of the fast Ruff linter
  • 📊 Detailed reports: Categorized issue breakdown
  • 🎨 Visual feedback: Color-coded quality indicators
  • 📁 File & directory support: Analyze single files or entire projects
  • ⚙️ Configurable: Use your existing Ruff configuration

Installation

pip install ruff-score

Quick Start

Command Line Usage

# Score a single file
ruff-score myfile.py

# Score a directory
ruff-score src/

# Use with custom Ruff config
ruff-score src/ pyproject.toml

Python API

from ruff_score import RuffScorer

scorer = RuffScorer()

# Score a file
result = scorer.score_file("myfile.py")
print(f"Score: {result['score']:.2f}/10.00")

# Score a directory
result = scorer.score_directory("src/")
scorer.print_report(result)

How It Works

Ruff Score uses the same scoring formula as Pylint:

Score = 10.0 - ((5*errors + warnings + refactor + convention) / statements * 10)

Rule Weights

Different Ruff rule categories have different weights:

  • Errors (E, F): Weight 5 (syntax errors, undefined names)
  • Security (S), Bugbear (B): Weight 2 (potential bugs, security issues)
  • Everything else: Weight 1 (style, conventions, etc.)

Score Interpretation

  • 9.0-10.0: 🎉 Excellent code quality
  • 7.0-8.9: ✅ Good code quality
  • 5.0-6.9: ⚠️ Needs improvement
  • 0.0-4.9: ❌ Poor code quality

Example Output

==================================================
RUFF QUALITY SCORE REPORT
==================================================
Target: src/
Score: 8.45/10.00
Statements analyzed: 1,247
Files analyzed: 23
Total issues: 12

Issues by category:
  Error: 0
  Warning: 3
  Convention: 8
  Refactor: 1

✅ Good code quality

Advanced Usage

Custom Rule Weights

from ruff_score import RuffScorer

scorer = RuffScorer(default_weight=2)
# Customize weights for specific rule categories
scorer.RULE_WEIGHTS['D'] = 0.5  # Lower weight for docstring issues

Integration with CI/CD

# Exit with non-zero code if score is below threshold
ruff-score src/ && echo "Quality check passed!" || echo "Quality check failed!"

Configuration

Ruff Score respects your existing Ruff configuration. Place your settings in:

  • pyproject.toml
  • ruff.toml
  • .ruff.toml

Example configuration:

[tool.ruff]
line-length = 88
target-version = "py38"

[tool.ruff.lint]
select = ["E", "F", "W", "C", "N", "D", "S", "B"]
ignore = ["E501", "D100"]

Requirements

  • Python 3.8+
  • Ruff 0.1.0+

License

MIT License - see LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Related Projects

  • Ruff - The fast Python linter
  • Pylint - The original Python code quality tool

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

ruff_score-0.1.1.tar.gz (36.1 kB view details)

Uploaded Source

Built Distribution

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

ruff_score-0.1.1-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file ruff_score-0.1.1.tar.gz.

File metadata

  • Download URL: ruff_score-0.1.1.tar.gz
  • Upload date:
  • Size: 36.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for ruff_score-0.1.1.tar.gz
Algorithm Hash digest
SHA256 89195fded67972bd3342ad7d4cc856d55b58c30b9630b22c23010ed5372841a0
MD5 55955716da82dde6d2a1040c05b4e8d7
BLAKE2b-256 87ddf6a99d950a58dfc6d128316b4189aae0e328bcddbe6e2aaa5a718299c601

See more details on using hashes here.

File details

Details for the file ruff_score-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: ruff_score-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 7.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for ruff_score-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6bb43db27cdc5ade1088ea630e9a464e6c366a2b67fb2236352163c92d0c4120
MD5 174e2baf833155c8922e3f8a4fa1bbb7
BLAKE2b-256 0ce4a7ed9e8ec77391cc3460aeddd04eb9adb9af0feba9750c6b1d11b1426683

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