π RailsCodeAuditor
Rails Code Auditor is a Ruby gem that automatically audits your Ruby on Rails applications for security, performance, code quality, and licensing issues.
It integrates popular auditing tools and wraps the results in visually rich HTML and PDF reports. It also leverages LLMs (Ollama with LLaMA 3) to provide intelligent improvement suggestions.
β¨ Features (Automated)
β Automatically runs code quality tools:
- Security Audit using Brakeman
- Dependency Vulnerability Scan via Bundler Audit
- Code Style Check using RuboCop
- Rails Best Practices Analysis via rails_best_practices
- Code Duplication Detection using Flay
- Code Complexity Score using Flog
- License Compliance via License Finder
- Code Smell Detection with Reek
- Code Quality Visualization using RubyCritic
- Test Coverage Analysis using SimpleCov
- Performance Improvements Suggestions using Fasterer
π Report Generation
- Automatically generates HTML and PDF reports for each tool
- Graphical charts using Gruff.
- Beautiful PDF report generation using Prawn and Prawn::Table.
- PDF reports use Puppeteer via the
grover
gem (if available). - Automated Report Merging into a single PDF file
- Organizes all output under the
report/
directory
π§ AI-Powered Code Review
- Integrates with Ollama using the LLaMA 3 model
- Summarizes audit findings using LLMs
- Provides human-like suggestions for improving code structure and test coverage
- Analyzes both source code and generated reports
π‘ Fully Automatic
- One command to run all audits, generate reports, and get AI recommendations β no manual steps required
π¦ Installation
Add this to your application's Gemfile
:
gem 'rails_code_auditor'
Then run:
bundle install
π Usage
Run the full audit and generate reports:
bundle exec rails_code_auditor
Enable AI code review with Ollama:
bundle exec rails_code_auditor --use-llm
Run with custom endpoint & model
rails_code_auditor --use-llm --llm-endpoint http://localhost:11434/api/generate --llm-model deepseek-coder
Added JSON response
rails_code_auditor --format json --output rails_code_auditor_report.json
Note: By default endpoint: http://localhost:11434/api/generate, model: 'llama3'
π§ LLM Integration with Ollama
Install Ollama (https://ollama.com/)
Start the LLaMA 3 model locally:
ollama run llama3
Run the gem with --use-llm to get AI-generated insights.
π§ͺ SimpleCov Setup
Ensure simplecov is added to your Gemfile:
gem 'simplecov', require: false
π§° Puppeteer Setup (Optional)
Install Puppeteer using Yarn or npm:
yarn add puppeteer
PDF report generation will be skipped if Puppeteer isn't installed β a warning will be shown, but HTML reports will still be generated.
π Output Structure
report/
βββ pdf/
β βββ rubycritic.pdf
β βββ rails_best_practices.pdf
β βββ rubocop.pdf (if available)
βββ rubycritic/
β βββ index.html
βββ rails_best_practices.html
βββ rubocop.html
βββ coverage/
βββ index.html
π§ Configuration
You can customize what tools to enable, file paths, and output formats using an initializer or environment flags (coming soon)
π Contributing
Pull requests are welcome! Please fork the repo and open a PR. For major changes, open an issue first to discuss your proposal.
π License
MIT License Β© 2025 sivamanikandan
π Coming Soon
- Report dashboard view in browser
- GitHub Actions integration
- Custom LLM model support
---
Let me know if you want:
- Badge support (`Gem`, `License`, `CI`, etc.)
- Project logo or screenshot inclusion
- Interactive web-based report viewing via browser
- A `bin/rails_code_auditor` launcher script
I can generate all of these if needed.