Skip to content

aqylsoft/godepvis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

godepvis

Go code analyzer that finds code smells and roasts them with AI.

What is this?

godepvis is a static analysis tool for Go that detects common code smells, anti-patterns, and potential bugs. It then uses AI (Claude, GPT, or local Ollama models) to generate humorous "roasts" of your code problems.

Key features:

  • Detects 26 types of code issues
  • Supports multiple LLM providers (Anthropic Claude, OpenAI GPT, Ollama)
  • Works offline with Ollama
  • Adjustable roast intensity (gentle, normal, savage)
  • Multi-language roasts (English, Russian)
  • MCP integration for Claude Code

Installation

Prerequisites: Go 1.21 or later

go install github.com/aqylsoft/godepvis/cmd/godepvis@latest

Verify installation:

godepvis --help

Quick Start

Preview issues (free, no API key)

godepvis --dry .

Full roast with Ollama (free, local)

# Install Ollama
curl -fsSL https://ollama.com/install.sh | sh

# Pull a model and start
ollama pull llama3.2
ollama serve

# Run godepvis
godepvis .

Full roast with Claude or GPT

# Set your API key
export ANTHROPIC_API_KEY=your-key-here
# or
export OPENAI_API_KEY=your-key-here

# Run godepvis
godepvis .

CLI Flags

Flag Description Example
--dry Preview issues without LLM roasting godepvis --dry .
--savage No mercy mode - maximum roast intensity godepvis --savage .
--gentle Be nicer - reduced roast intensity godepvis --gentle .
--lang Roast language (en, ru) godepvis --lang ru .
--max Maximum issues to report godepvis --max 10 .
--file Analyze a single file godepvis --file main.go
--provider Force specific LLM provider godepvis --provider ollama .
--mcp Run as MCP server godepvis --mcp

What Issues Does It Find?

godepvis detects 26 types of code smells:

Code Structure

Emoji Type Description
πŸ“ huge_function Function exceeds 50 lines
🐘 huge_main main() exceeds 80 lines
πŸͺ† deep_nesting Nesting depth greater than 4
πŸ›οΈ god_struct Struct with more than 15 fields
πŸ“œ god_interface Interface with more than 5 methods
πŸ“‹ too_many_params Function with more than 7 parameters
🎬 init_function init() function in library code
🌍 global_var Global mutable variable
🫣 naked_return Return without explicit values in long functions

Error Handling

Emoji Type Description
πŸ™ˆ ignored_error Error silently discarded with _
πŸ’£ panic_in_lib panic() call in library code

Security

Emoji Type Description
πŸ”‘ hardcoded_secret Hardcoded password, token, or API key
πŸ’‰ sql_concat SQL query built with string concatenation
🐚 exec_command exec.Command with variable argument
⏳ http_no_timeout http.Client without Timeout
πŸ”“ tls_insecure TLS InsecureSkipVerify enabled

Go-specific Bugs

Emoji Type Description
πŸ” defer_in_loop defer statement inside a loop
⏰ time_equal time.Time compared with == instead of .Equal()
πŸ‘» range_pointer Pointer to range loop variable
🎭 context_background context.Background() when ctx parameter available

Code Quality

Emoji Type Description
πŸ“ todo_comment TODO/FIXME comment left in code
πŸ’Ύ select_star SELECT * in SQL query
πŸ”’ magic_number Unexplained numeric literal
πŸ§ͺ no_tests Package has no test files
🐌 string_concat_loop String concatenation in loop (use strings.Builder)

Examples

Basic scan

$ godepvis --dry .
πŸ” Scanning for sins...
πŸ“‹ Found 5 sins across 12 files

--- DRY RUN ---
πŸ™ˆ cmd/main.go:42 β€” error silently discarded with _
πŸ“ internal/parser/parser.go:15 β€” func Parse is 78 lines long
πŸͺ† internal/handler/handler.go:33 β€” func Handle has nesting depth of 6
πŸ”‘ config/config.go:8 β€” hardcoded credential in source code
πŸ§ͺ internal/util/util.go:1 β€” entire package has zero test files

Full roast with output

$ godepvis .
πŸ” Scanning for sins...
πŸ“‹ Found 3 sins across 8 files
πŸ”₯ Roasting 3 sins with anthropic...

  cmd/main.go  (2 sins)
  πŸ™ˆ line 42   [ignored_error]
         "Oh, you're just going to ignore that error? Bold strategy,
          Cotton. Let's see if it pays off when your app crashes at 3 AM."

  πŸ“ line 15   [huge_function]
         "This function is so long it needs its own zip code.
          Ever heard of single responsibility? Neither has this code."

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  πŸ’€ ROAST COMPLETE
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  Files analyzed : 8
  Sins found     : 3

  Code Quality   : 94/100  ACCEPTABLE (suspicious)

  Top offender   : cmd/main.go (2 sins)
  Most common    : πŸ™ˆ ignored_error (1x)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Claude Code Integration (MCP)

godepvis can run as an MCP (Model Context Protocol) server for integration with Claude Code.

Setup

  1. Add to your Claude Code configuration (~/.config/claude-code/claude_desktop_config.json):
{
  "mcpServers": {
    "godepvis": {
      "command": "godepvis",
      "args": ["--mcp"]
    }
  }
}
  1. Restart Claude Code

  2. Use the tool in Claude Code:

    • Ask Claude to analyze your Go code
    • Request specific sin type checks
    • Get code improvement suggestions

MCP Tools

Tool Description
analyze_code Analyze Go code for common issues and code smells
list_sin_types List all detectable issue types with descriptions

FAQ

Q: Why is it called godepvis?

A: It started as a Go dependency visualizer (go-dep-vis), but evolved into a code analyzer with attitude.

Q: Is it free?

A: The analyzer itself is free. You only pay for LLM API usage if using Claude or GPT. Ollama is completely free and runs locally.

Q: What LLMs are supported?

A: Anthropic Claude (claude-3-sonnet), OpenAI GPT (gpt-4o), and any Ollama model (default: llama3.2).

Q: How do I ignore certain sins?

A: Currently there's no ignore mechanism. All detected issues are reported. This is intentional - the tool is meant to be provocative.

Q: Does it work on Windows?

A: Yes, but you'll need to ensure Go is installed and in your PATH. Ollama also supports Windows.

Q: Can I use it in CI/CD?

A: Yes! Use --dry mode for CI pipelines. Exit code is 0 even when sins are found (it's a roasting tool, not a linter).

License

MIT

About

Go static analyzer for code smells with MCP integration for AI assistants

Topics

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages