Docquet
A standardized RuboCop configuration gem that automatically detects available RuboCop plugins and generates appropriate configurations with CLI tools for easy setup and maintenance.
Features
- Automatic Plugin Detection: Automatically detects installed RuboCop plugins and includes their configurations
- CLI Tools: Easy-to-use commands for initialization and maintenance
- Comprehensive Coverage: Supports all major RuboCop plugins out of the box
- Documentation Links: Generated configurations include links to official documentation
- Smart Detection: Uses gem metadata to automatically detect installed RuboCop plugins
-
Incremental Setup: Generates
.rubocop_todo.ymlfor gradual adoption
Installation
Add it to your Gemfile:
group :development do
gem "docquet", require: false
endThen run:
bundle installOr install it as a standalone gem:
gem install docquetUsage
Install RuboCop Configuration
Run the installation command in your project root:
docquet install-configThis command will:
- Generate
.rubocop.ymlwith configurations for detected plugins - Create an initial
.rubocop_todo.ymlwith existing violations - Display next steps for gradual adoption
To overwrite existing files:
docquet install-config --forceUpdate TODO File
When you've fixed some violations and want to regenerate the TODO file:
docquet regenerate-todoThis command will:
- Regenerate
.rubocop_todo.ymlwith current violations - Show whether the TODO file changed
- Provide feedback on progress
Supported RuboCop Plugins
The gem automatically detects and configures the following plugins when installed:
Core RuboCop
- Bundler: Bundler-related rules
- Gemspec: Gemspec file rules
- Layout: Code formatting and layout rules
- Lint: Rules for catching potential bugs
- Metrics: Code complexity and size metrics
- Naming: Naming convention rules
- Security: Security-related rules
- Style: General code style rules
Plugin Extensions (Auto-detected)
- rubocop-capybara: Capybara testing framework rules
- rubocop-i18n: Internationalization rules (GetText, Rails I18n)
- rubocop-migration: Database migration rules (for Rails applications)
- rubocop-performance: Performance optimization rules
- rubocop-rake: Rake task rules
- rubocop-rspec: RSpec testing framework rules (including Capybara integration)
- rubocop-sequel: Sequel ORM rules
- rubocop-thread_safety: Thread safety rules
Generated Configuration Structure
The generated .rubocop.yml file includes:
AllCops:
DisplayCopNames: true
DisplayStyleGuide: true
EnabledByDefault: true
Exclude:
- bin/**/*
- vendor/**/*
ExtraDetails: true
NewCops: enable
TargetRubyVersion: 3.2 # Detected from .ruby-version or current Ruby
UseCache: true
plugins:
- rubocop-performance # Auto-detected plugins
- rubocop-rspec
# ... other detected plugins
inherit_gem:
docquet:
- config/cops/style.yml # Core style rules
- config/cops/layout.yml # Core layout rules
- config/cops/performance.yml # Performance rules (if plugin detected)
- config/cops/rspec.yml # RSpec rules (if plugin detected)
# ... other detected plugins
inherit_from: .rubocop_todo.ymlEach configuration file includes:
- Department-specific rules
- Links to official RuboCop documentation
- Carefully curated cop configurations
- Optimized settings for practical use
The configuration uses EnabledByDefault: true for strict code quality enforcement with TODO file for gradual adoption.
Configuration Philosophy
This configuration aims to:
- Enforce Consistency: Standardize code style across projects
- Promote Best Practices: Enable rules that catch common issues
- Provide Documentation: Include links to understand each rule
- Enable Gradual Adoption: Use TODO files for incremental improvements
- Stay Current: Automatically adapt to installed plugin versions
Development
Setup
bundle installRunning Tests
bundle exec rspecRunning RuboCop
bundle exec rubocopTesting CLI Commands
# Test installation command
./exe/docquet install-config
# Test TODO regeneration
./exe/docquet regenerate-todoDocumentation Links
Core RuboCop
Plugin Extensions
Contributing
- Fork the repository
- Create a feature branch
- Make your changes with tests
- Run the test suite:
bundle exec rspec - Run RuboCop:
bundle exec rubocop - Submit a pull request
License
This gem is available as open source under the terms of the MIT License.