Skip to content

Commit

Permalink
[WIP] Explore plugin configs
Browse files Browse the repository at this point in the history
- RuboCop config requires only the RuboCop plugins whose gemspec is loaded
- Each plugin has a corresponding file of defaults which are inherited
- Labels are attached automatically to PRs touching each config file

TBD:
- Should we have a minimal config? Should we keep the existing config as
  is, and instead add an "everything.yml" config?
- Should we test compatibility with _just_ RuboCop and no plugins?
- What cops to enable? Maybe disallowing "pending" shouldn't apply to
  plugins, so we don't break consumers?
  • Loading branch information
sambostock committed Feb 14, 2023
1 parent 53be4b4 commit 5d617fc
Show file tree
Hide file tree
Showing 11 changed files with 2,696 additions and 4 deletions.
9 changes: 8 additions & 1 deletion .github/labeler.yml
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
"config change": rubocop.yml
"config change": rubocop*.yml
"hq": rubocop.yml
"graphql": rubocop.graphql.yml
"minitest": rubocop.minitest.yml
"performance": rubocop.performance.yml
"rails": rubocop.rails.yml
"rake": rubocop.rake.yml
"rspec": rubocop.rspec.yml
9 changes: 9 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,12 @@ gem "diffy"
gem "minitest"
gem "pry-byebug"
gem "rake"

group :plugins do
gem "rubocop-graphql"
gem "rubocop-minitest"
gem "rubocop-performance"
gem "rubocop-rails"
gem "rubocop-rake"
gem "rubocop-rspec"
end
35 changes: 35 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,18 @@ PATH
GEM
remote: https://rubygems.org/
specs:
activesupport (7.0.4.2)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
tzinfo (~> 2.0)
ast (2.4.2)
byebug (11.1.3)
coderay (1.1.3)
concurrent-ruby (1.2.0)
diffy (3.4.2)
i18n (1.12.0)
concurrent-ruby (~> 1.0)
json (2.6.3)
method_source (1.0.0)
minitest (5.17.0)
Expand All @@ -23,6 +31,7 @@ GEM
pry-byebug (3.10.1)
byebug (~> 11.0)
pry (>= 0.13, < 0.15)
rack (3.0.4.1)
rainbow (3.1.1)
rake (13.0.6)
regexp_parser (2.6.2)
Expand All @@ -39,7 +48,27 @@ GEM
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.24.1)
parser (>= 3.1.1.0)
rubocop-capybara (2.17.0)
rubocop (~> 1.41)
rubocop-graphql (0.19.0)
rubocop (>= 0.87, < 2)
rubocop-minitest (0.27.0)
rubocop (>= 0.90, < 2.0)
rubocop-performance (1.16.0)
rubocop (>= 1.7.0, < 2.0)
rubocop-ast (>= 0.4.0)
rubocop-rails (2.17.4)
activesupport (>= 4.2.0)
rack (>= 1.1)
rubocop (>= 1.33.0, < 2.0)
rubocop-rake (0.6.0)
rubocop (~> 1.0)
rubocop-rspec (2.18.1)
rubocop (~> 1.33)
rubocop-capybara (~> 2.17)
ruby-progressbar (1.11.0)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unicode-display_width (2.4.2)

PLATFORMS
Expand All @@ -50,6 +79,12 @@ DEPENDENCIES
minitest
pry-byebug
rake
rubocop-graphql
rubocop-minitest
rubocop-performance
rubocop-rails
rubocop-rake
rubocop-rspec
rubocop-shopify!

BUNDLED WITH
Expand Down
Empty file added rubocop.graphql.yml
Empty file.
2 changes: 2 additions & 0 deletions rubocop.minitest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Minitest:
Enabled: true
Empty file added rubocop.performance.yml
Empty file.
Empty file added rubocop.rails.yml
Empty file.
Empty file added rubocop.rake.yml
Empty file.
Empty file added rubocop.rspec.yml
Empty file.
16 changes: 16 additions & 0 deletions rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,22 @@ inherit_mode:
- Exclude
- Include

<%
# Identify installed RuboCop plugins to configure
plugin_configs = {
"rubocop-graphql" => "rubocop.graphql.yml",
"rubocop-minitest" => "rubocop.minitest.yml",
"rubocop-performance" => "rubocop.performance.yml",
"rubocop-rails" => "rubocop.rails.yml",
"rubocop-rake" => "rubocop.graphql.yml",
"rubocop-rspec" => "rubocop.rspec.yml",
}.select { |plugin_name, _| Gem.loaded_specs.include?(plugin_name) }
%>

require: <%= plugin_configs.keys.to_json %>

inherit_from: <%= plugin_configs.values.to_json %>

AllCops:
StyleGuideBaseURL: https://shopify.github.io/ruby-style-guide/

Expand Down
Loading

0 comments on commit 5d617fc

Please sign in to comment.