Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion rubocop-airbnb/.rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
inherit_from:
- .rubocop_airbnb.yml
- ./config/default.yml

plugins:
- rubocop-airbnb

AllCops:
CacheRootDirectory: tmp/rubocop
Expand Down
8 changes: 5 additions & 3 deletions rubocop-airbnb/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ ways to do this:
First Create a new file `.rubocop_airbnb.yml` in the same directory as your `.rubocop.yml`
this file should contain
```
require:
plugins:
- rubocop-airbnb
```

Expand All @@ -50,10 +50,13 @@ you could potentially experience a bunch of warnings from `.rubocop_todo.yml` fo
Now you can run `rubocop` and it will automatically load the RuboCop Airbnb
cops together with the standard cops.

> [!NOTE]
> The plugin system is supported in RuboCop 1.72+. In earlier versions, use `require` instead of `plugins`.

### Command line

```bash
rubocop --require rubocop-airbnb
rubocop --plugin rubocop-airbnb
```

## The Cops
Expand All @@ -70,4 +73,3 @@ Airbnb/PhraseBundleKeys:
Exclude:
- spec/my_poorly_named_spec_file.rb
```

4 changes: 3 additions & 1 deletion rubocop-airbnb/config/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,16 @@ RSpec:
Include:
- _spec.rb
- "(?:^|/)spec/"
RSpec/FactoryBot:
FactoryBot:
Include:
- spec/factories/**/*.rb
- features/support/factories/**/*.rb

inherit_from:
- './rubocop-airbnb.yml'
- './rubocop-bundler.yml'
- './rubocop-capybara.yml'
- './rubocop-factory_bot.yml'
- './rubocop-gemspec.yml'
- './rubocop-layout.yml'
- './rubocop-lint.yml'
Expand Down
6 changes: 6 additions & 0 deletions rubocop-airbnb/config/rubocop-capybara.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
plugins:
- rubocop-capybara

Capybara/CurrentPathExpectation:
Description: Checks that no expectations are set on Capybara's `current_path`.
Enabled: false
10 changes: 10 additions & 0 deletions rubocop-airbnb/config/rubocop-factory_bot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
plugins:
- rubocop-factory_bot

FactoryBot/AttributeDefinedStatically:
Description: Always declare attribute values as blocks.
Enabled: false

FactoryBot/CreateList:
Description: Checks for create_list usage.
Enabled: true
3 changes: 1 addition & 2 deletions rubocop-airbnb/config/rubocop-performance.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require:
plugins:
- rubocop-performance

Performance/Caller:
Expand Down Expand Up @@ -122,4 +122,3 @@ Performance/UnfreezeString:

Performance/UriDefaultParser:
Enabled: false

2 changes: 1 addition & 1 deletion rubocop-airbnb/config/rubocop-rails.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require:
plugins:
- rubocop-rails

# before_action doesn't seem to exist, so this doesn't make sense.
Expand Down
40 changes: 16 additions & 24 deletions rubocop-airbnb/config/rubocop-rspec.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require:
plugins:
- rubocop-rspec

RSpec/AlignLeftLetBrace:
Expand Down Expand Up @@ -53,6 +53,10 @@ RSpec/DescribedClass:
Description: 'Use `described_class` for tested class / module'
Enabled: false

RSpec/Dialect:
Description: Enforces custom RSpec dialects.
Enabled: false

RSpec/EmptyExampleGroup:
Description: Checks if an example group does not include any tests.
Enabled: true
Expand Down Expand Up @@ -110,13 +114,6 @@ RSpec/ExpectOutput:
Description: Checks for opportunities to use `expect { ... }.to output`.
Enabled: false

RSpec/FilePath:
Description: 'Checks the file and folder naming of the spec file.'
Enabled: false
CustomTransform:
RuboCop: rubocop
RSpec: rspec

RSpec/Focus:
Description: Checks if examples are focused.
Enabled: false
Expand Down Expand Up @@ -293,6 +290,17 @@ RSpec/SingleArgumentMessageChain:
Description: Checks that chains of messages contain more than one element.
Enabled: true

RSpec/SpecFilePathFormat:
Description: Checks that spec file paths are consistent and well-formed.
Enabled: false
CustomTransform:
RuboCop: rubocop
RSpec: rspec

RSpec/SpecFilePathSuffix:
Description: Checks that spec file paths suffix are consistent and well-formed.
Enabled: false

RSpec/SubjectStub:
Description: Checks for stubbed test subjects.
Enabled: false
Expand All @@ -308,19 +316,3 @@ RSpec/VerifiedDoubles:
RSpec/VoidExpect:
Description: This cop checks void `expect()`.
Enabled: false

RSpec/Capybara/CurrentPathExpectation:
Description: Checks that no expectations are set on Capybara's `current_path`.
Enabled: false

RSpec/Capybara/FeatureMethods:
Description: Checks for consistent method usage in feature specs.
Enabled: false

RSpec/FactoryBot/AttributeDefinedStatically:
Description: Always declare attribute values as blocks.
Enabled: false

RSpec/FactoryBot/CreateList:
Description: Checks for create_list usage.
Enabled: true
8 changes: 3 additions & 5 deletions rubocop-airbnb/lib/rubocop-airbnb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
require 'rubocop-performance'
require 'rubocop-rails'

require 'rubocop/airbnb'
require 'rubocop/airbnb/inject'
require 'rubocop/airbnb/version'

RuboCop::Airbnb::Inject.defaults!
require_relative 'rubocop/airbnb'
require_relative 'rubocop/airbnb/plugin'
require_relative 'rubocop/airbnb/version'
20 changes: 0 additions & 20 deletions rubocop-airbnb/lib/rubocop/airbnb/inject.rb

This file was deleted.

31 changes: 31 additions & 0 deletions rubocop-airbnb/lib/rubocop/airbnb/plugin.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# frozen_string_literal: true

require 'lint_roller'

module RuboCop
module Airbnb
# A plugin that integrates RuboCop Airbnb with RuboCop's plugin system.
class Plugin < LintRoller::Plugin
def about
LintRoller::About.new(
name: 'rubocop-airbnb',
version: VERSION,
homepage: 'https://github.com/airbnb/ruby',
description: 'A plugin for RuboCop code style enforcing & linting tool.'
)
end

def supported?(context)
context.engine == :rubocop
end

def rules(_context)
LintRoller::Rules.new(
type: :path,
config_format: :rubocop,
value: Pathname.new(__dir__).join('../../../config/default.yml'),
)
end
end
end
end
13 changes: 9 additions & 4 deletions rubocop-airbnb/rubocop-airbnb.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,14 @@ Gem::Specification.new do |spec|
'Gemfile',
]

spec.add_dependency('rubocop', '~> 1.61')
spec.add_dependency('rubocop-performance', '~> 1.20')
spec.add_dependency('rubocop-rails', '~> 2.24')
spec.add_dependency('rubocop-rspec', '~> 2.26')
spec.metadata['default_lint_roller_plugin'] = 'RuboCop::Airbnb::Plugin'

spec.add_dependency('lint_roller', '~> 1.1')
spec.add_dependency('rubocop', '~> 1.72')
spec.add_dependency('rubocop-capybara', '~> 2.22')
spec.add_dependency('rubocop-factory_bot', '~> 2.27')
spec.add_dependency('rubocop-performance', '~> 1.24')
spec.add_dependency('rubocop-rails', '~> 2.30')
spec.add_dependency('rubocop-rspec', '~> 3.5')
spec.add_development_dependency('rspec', '~> 3.5')
end