Skip to main content

Python AI Slop Detector - Find over-engineering, hallucinations, and dead code

Project description

๐Ÿท Sloppylint

Detect AI-generated code anti-patterns in your Python codebase.

Catches AI-specific anti-patterns that traditional linters miss

PyPI Python 3.9+ License: MIT


โšก Quick Start

pip install sloppylint
sloppylint .

# Output:
# CRITICAL (2 issues)
# ============================================================
#   src/api.py:23  mutable_default_arg
#     Mutable default argument - use None instead
#     > def process(items=[]):
#
#   src/db.py:15  bare_except
#     Bare except catches everything including SystemExit
#     > except:
#
# SLOPPY INDEX
# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
# Information Utility (Noise)    : 24 pts
# Information Quality (Lies)     : 105 pts
# Style / Taste (Soul)           : 31 pts
# Structural Issues              : 45 pts
# โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
# TOTAL SLOP SCORE               : 205 pts
#
# Verdict: SLOPPY

๐Ÿค” Why Sloppylint Exists

Traditional linters catch style and syntax issues. But AI-generated code introduces new failure patterns they weren't designed to detect:

  • Hallucinated imports - packages and functions that don't exist
  • Cross-language leakage - .push(), .equals(), .length in Python
  • Placeholder code - pass, TODO, functions that do nothing
  • Confident wrongness - code that looks right but fails at runtime

Sloppylint targets these AI-specific patterns that escape Pylint, Flake8, and code review.


๐ŸŽฏ What It Catches

The Three Axes of AI Slop

Axis What It Detects Examples
๐Ÿ“ข Noise Debug artifacts, redundant comments print(), # increment x above x += 1
๐Ÿคฅ Lies Hallucinations, placeholders def process(): pass, mutable defaults
๐Ÿ’€ Soul Over-engineering, bad style God functions, deep nesting, hedging comments
๐Ÿ—๏ธ Structure Anti-patterns Bare except, star imports, single-method classes

๐Ÿ“ฅ What You Put In

# Scan a directory
sloppylint src/

# Scan specific files
sloppylint app.py utils.py

# Only high severity issues
sloppylint --severity high

# CI mode - exit 1 if issues found
sloppylint --ci --max-score 50

# Export JSON report
sloppylint --output report.json

๐Ÿ“ค What You Get Out

Output Description
๐ŸŽฏ Issues by Severity Critical, High, Medium, Low
๐Ÿ“Š Slop Score Points breakdown by axis
๐Ÿ“‹ Verdict CLEAN / ACCEPTABLE / SLOPPY / DISASTER
๐Ÿ“ JSON Report Machine-readable for CI/CD

๐Ÿ” Pattern Examples

Critical Severity

# ๐Ÿšจ mutable_default_arg - AI's favorite mistake
def process_items(items=[]):  # Bug: shared state between calls
    items.append(1)
    return items

# โœ… Fix: Use None and initialize inside
def process_items(items=None):
    if items is None:
        items = []
    items.append(1)
    return items
# ๐Ÿšจ bare_except - Catches SystemExit, KeyboardInterrupt
try:
    risky_operation()
except:  # Bug: swallows Ctrl+C!
    pass

# โœ… Fix: Catch specific exceptions
try:
    risky_operation()
except ValueError as e:
    logger.error(f"Invalid value: {e}")

High Severity

# ๐Ÿšจ pass_placeholder - AI gave up
def validate_email(email):
    pass  # TODO: implement

# ๐Ÿšจ hedging_comment - AI uncertainty
x = calculate()  # should work hopefully

๐Ÿ’ฐ The Value

๐Ÿ” Catch AI mistakes before they hit production

Why This Matters

Problem Impact Sloppylint Catches
Mutable defaults Shared state bugs โœ… Critical alert
Bare except Swallows Ctrl+C โœ… Critical alert
Placeholder functions Runtime failures โœ… High alert
Hallucinated imports ImportError in prod โœ… High alert
Wrong language patterns JS/Java/Ruby/Go/C#/PHP in Python โœ… High alert
Unused imports Code bloat โœ… Medium alert
Dead code Maintenance burden โœ… Medium alert
Copy-paste code Maintenance nightmare โœ… Medium alert

Research Says

  • 20% of AI package imports reference non-existent libraries โ€” sloppylint catches these
  • LLMs leak patterns from other languages they were trained on โ€” sloppylint catches 100+ of these
  • 66% of developers say AI code is "almost right" (the dangerous kind)

๐Ÿ› ๏ธ CLI Commands

sloppylint .                    # ๐Ÿ” Scan current directory
sloppylint src/ tests/          # ๐Ÿ“ Scan multiple directories
sloppylint --severity high      # โšก Only critical/high issues
sloppylint --lenient            # ๐ŸŽฏ Same as --severity high
sloppylint --strict             # ๐Ÿ”ฌ Report everything
sloppylint --ci                 # ๐Ÿšฆ Exit 1 if any issues
sloppylint --max-score 50       # ๐Ÿ“Š Exit 1 if score > 50
sloppylint --output report.json # ๐Ÿ“‹ Export JSON report
sloppylint --ignore "tests/*"   # ๐Ÿšซ Exclude patterns
sloppylint --disable magic_number # โญ๏ธ Skip specific checks
sloppylint --version            # ๐Ÿ“Œ Show version

โœ… Features

Feature Description Status
๐ŸŒ Multi-Language Detection Catches patterns from JS, Java, Ruby, Go, C#, PHP โœ… 100+ patterns
๐Ÿ” Hallucinated Imports Detect non-existent packages โœ… Done
๐Ÿ“ฆ Unused Imports AST-based detection โœ… Done
๐Ÿ’€ Dead Code Unused functions/classes โœ… Done
๐Ÿ”„ Duplicate Detection Cross-file copy-paste โœ… Done
๐ŸŽจ Rich Output Colors and tables (optional) โœ… Done
โš™๏ธ Config Support pyproject.toml configuration โœ… Done

Language Patterns Detected

LLMs are trained on code from many languages. When generating Python, they sometimes produce patterns from other languages:

Language Example Mistakes Python Fix
JavaScript .push(), .length, .forEach() .append(), len(), for loop
Java .equals(), .toString(), .isEmpty() ==, str(), not obj
Ruby .each, .nil?, .first, .last for loop, is None, [0], [-1]
Go fmt.Println(), nil print(), None
C# .Length, .Count, .ToLower() len(), len(), .lower()
PHP strlen(), array_push(), explode() len(), .append(), .split()

๐Ÿšซ What Sloppylint Is Not

Sloppylint does not replace:

  • Human code review
  • Traditional linters (Pylint, Flake8, Ruff)
  • Type checkers (mypy, pyright)
  • Security scanners (Bandit, Semgrep)

It complements them by catching patterns these tools missโ€”patterns uniquely common in AI-generated code.


๐Ÿ“ฆ Installation

# Install from PyPI
pip install sloppylint

# With colored output (recommended)
pip install sloppylint[rich]

# With all optional features
pip install sloppylint[all]

# Or install from source for development
git clone https://github.com/rsionnach/sloppylint.git
cd sloppylint
pip install -e ".[dev]"

โš™๏ธ Configuration

Configure via pyproject.toml:

[tool.sloppy]
ignore = ["tests/*", "migrations/*"]
disable = ["magic_number", "debug_print"]
severity = "medium"
max-score = 100
ci = false
format = "detailed"  # or "compact" or "json"

๐Ÿค Contributing

git clone https://github.com/rsionnach/sloppylint.git
cd sloppylint
pip install -e ".[dev]"
pytest tests/ -v  # 62 tests should pass

See AGENTS.md for coding conventions and pattern implementation guide.


๐Ÿ“„ License

MIT


๐Ÿ™ Acknowledgments

Inspiration

  • KarpeSlop - The original AI Slop Linter for TypeScript
  • Andrej Karpathy's commentary on AI-generated code quality

Research

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

sloppylint-0.1.4.tar.gz (41.1 kB view details)

Uploaded Source

Built Distribution

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

sloppylint-0.1.4-py3-none-any.whl (38.1 kB view details)

Uploaded Python 3

File details

Details for the file sloppylint-0.1.4.tar.gz.

File metadata

  • Download URL: sloppylint-0.1.4.tar.gz
  • Upload date:
  • Size: 41.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for sloppylint-0.1.4.tar.gz
Algorithm Hash digest
SHA256 3f447e24fa74405dbc2b96a50f3c316ce0210f6650db53d0a2d3361871e1aa5b
MD5 2d38364277952450de4a8ed838dca3d6
BLAKE2b-256 0f9f7f2a6633df48c08c0427fcec58a4866a5686c99775427f702eae1d23b9b8

See more details on using hashes here.

Provenance

The following attestation bundles were made for sloppylint-0.1.4.tar.gz:

Publisher: publish.yml on rsionnach/sloppylint

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sloppylint-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: sloppylint-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 38.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for sloppylint-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 27ade832445eba5c3425362de11e0ae02bc0fa8e6e9b47319f28e3e043d3e176
MD5 c159ea74cc22e85efaec0e176f50287c
BLAKE2b-256 4a1eff644f3f5238e78dbb5d4b58938433018c4c2c901097c704f76a3aef8250

See more details on using hashes here.

Provenance

The following attestation bundles were made for sloppylint-0.1.4-py3-none-any.whl:

Publisher: publish.yml on rsionnach/sloppylint

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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