Back to the catalog

codehog

A friendly truffle pig that sniffs out design principle violations - Law of Demeter, SOLID, DRY, KISS, YAGNI and more.

Open source Open in the app JSON README (API)

About

A friendly truffle pig that sniffs out design principle violations - Law of Demeter, SOLID, DRY, KISS, YAGNI and more.

Details

Kind
Plugins
Topic
No topic detected
Publisher
ivannovosad
Origin
marketplace
Category
ferramentas
Stars
1
Last push
2026-04-12T20:59:27Z
Repository state
ativo
License
MIT
Added
2026-08-30 01:48:58
Updated
2026-08-30 01:48:58
Origin id
ivannovosad/codehog/codehog

README

<img width="336" height="250" alt="codehog_logo_small" src="https://github.com/user-attachments/assets/01bbf4e5-6261-4f18-b23b-7a2df999857c" />

# ๐Ÿฝ Code Hog - Your Friendly Code Smell Companion

A friendly truffle pig that sniffs out design principle violations in your codebase.

Code Hog is a [Claude Code](https://docs.anthropic.com/en/docs/claude-code) plugin that analyzes your source files against established software design principles and reports findings with actionable suggestions โ€” all in a constructive, encouraging tone.

## What It Checks

| Principle | What it catches |
|-----------|----------------|
| **Law of Demeter** | Excessive method chaining and deep property access |
| **Single Responsibility** | Classes juggling too many concerns |
| **Open/Closed** | Rigid if/else and switch statements on types |
| **Liskov Substitution** | Unsupported operation errors and runtime type-checking |
| **Interface Segregation** | Overly broad god interfaces |
| **Dependency Inversion** | Hardcoded concrete dependencies |
| **DRY** | Duplicate code blocks and magic numbers |
| **KISS** | Excessive nesting, complex booleans, too many parameters |
| **YAGNI** | Unused code and unreachable branches |
| **Tell, Don't Ask** | Querying state then making decisions externally |
| **Composition over Inheritance** | Deep inheritance hierarchies |

## Install

In Claude Code, run:

```
/plugin marketplace add anthropics/claude-plugins-community
/plugin install codehog@claude-community
```


## Usage

```
/codehog:codehog
```

To scan a specific directory:

```
/codehog:codehog app/models
```

Code Hog will scan your project, identify the language(s), and produce a report organized by principle with impact levels (High / Medium / Low) and concrete suggestions for each finding.

## Example Output

```
๐Ÿฝ Code Hog is happily rooting through your codebase...

## ๐Ÿฝ app/services/order_processor.rb

โœ… Nice work: Clean method naming and good use of service objects!

### ๐Ÿ’Ž Opportunity | Law of Demeter (line ~42)
Impact: High โ€” deep coupling makes this fragile when internals change

  order.customer.address.country.tax_rate

What's happening: This chain reaches through 4 objects โ€” any change
in the middle breaks this code.
Quick win: Add a delegated method like order.tax_rate or pass the
rate directly.

### ๐Ÿ’ก Suggestion | Single Responsibility (context)
Impact: Medium โ€” mixing concerns makes the class harder to test

What's happening: This service handles payment processing, inventory
updates, and email notifications โ€” three distinct responsibilities.
Quick win: Extract PaymentHandler and InventoryUpdater, keep this
class as the orchestrator.

### โœจ Polish | KISS (line ~87)
Impact: Low โ€” small change, nice readability boost

  if !order.nil? && !order.cancelled? && order.items.any? && order.payment_status != :failed

Quick win: Extract to a descriptive method like order.processable?

---

## Summary

๐Ÿ“Š What You're Doing Well
- Consistent service object pattern across the app
- Good test coverage in models
- Clear naming conventions

Files sniffed: 12 | Opportunities: 8
  ๐Ÿ’Ž High: 2 | ๐Ÿ’ก Medium: 4 | โœจ Low: 2

Recommended Starting Points:
1. app/services/order_processor.rb โ€” highest concentration of findings
2. app/models/user.rb โ€” SRP violation easy to fix
3. app/controllers/api/v1/products_controller.rb โ€” deep nesting

Cleanest Files: app/models/product.rb, app/services/auth_service.rb

๐Ÿ™‚ Solid foundation! A handful of improvements would take this from good to great.
```

## Language Support

Ruby, JavaScript, TypeScript, Python, Java, Go, Rust, C#, and more.

## License

[MIT](LICENSE)

More