RuboCop BoochTek
BoochTek's shared RuboCop configuration for Ruby projects.
Installation
Add to your Gemfile:
group :development, :test do
gem "rubocop-boochtek", github: "boochtek/rubocop-boochtek"
endOr install directly:
gem install rubocop-boochtekUsage
Create a .rubocop.yml in your project root:
plugins:
- rubocop-boochtekThat's it! The gem automatically loads rubocop-rspec and rubocop-performance.
Overriding Settings
Override any settings in your project's .rubocop.yml:
plugins:
- rubocop-boochtek
Layout/LineLength:
Max: 160
AllCops:
NewCops: enableKey Style Decisions
private def (Inline Access Modifiers)
We prefer private def over a separate private section:
# Good
private def my_method
# ...
end
# Avoided
private
def my_method
# ...
endThis makes it easier to see at a glance which methods are private, and makes moving methods around simpler.
Semantic Block Delimiters
Use {} for blocks that return a value; use do/end otherwise:
# Good - returns a value
names = users.map { |u| u.name }
# Good - side effects only
users.each do |user|
send_email(user)
endDouble Quotes
We use double quotes by default for strings, as they require fewer changes when you later need interpolation.
Other Notable Preferences
- Line length: 120 characters
- No frozen string literal comments required
- No documentation required for classes/modules
-
failfor raising exceptions,raisefor re-raising -
%x[]for shell commands (not backticks) - Unicode allowed in comments and identifiers
Adding Custom Cops
Create cops in lib/rubocop/cop/boochtek/:
# lib/rubocop/cop/boochtek/my_custom_cop.rb
module RuboCop
module Cop
module Boochtek
class MyCustomCop < Base
MSG = "Custom message here"
def on_send(node)
# ...
end
end
end
end
endCustom cops are auto-loaded when the gem is required.
Development
git clone https://github.com/boochtek/rubocop-boochtek
cd rubocop-boochtek
bundle install
bundle exec rakeLicense
MIT License. See LICENSE for details.