From 99376a3cf16650bd7baaaf35178d7e1b62172ba4 Mon Sep 17 00:00:00 2001 From: Ben Fritsch Date: Tue, 9 Sep 2025 13:59:46 +0200 Subject: [PATCH] help RuboCop pick the correct config The problem is that RuboCop by default picked the inner most config file. This means that if we want to use RuboCop for Pliny itself with a .rubocop.yml config in the project root, we always need to append `-c .rubocop.yml`. If you don't do this you are greeted with a lot of errors. Which is especially annoying if you have RuboCop integrated in your editor. With this change it works out of the box. With a minimal trade-off by renaming the template. --- .github/workflows/lint.yml | 2 +- lib/pliny/commands/creator.rb | 1 + lib/template/{.rubocop.yml => .rubocop_template.yml} | 0 spec/commands/creator_spec.rb | 1 + 4 files changed, 3 insertions(+), 1 deletion(-) rename lib/template/{.rubocop.yml => .rubocop_template.yml} (100%) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index b8e9bc32..90cbe883 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -23,4 +23,4 @@ jobs: ruby-version: ${{ matrix.ruby-version }} bundler-cache: true - name: Run RuboCop - run: bundle exec rubocop -c .rubocop.yml + run: bundle exec rubocop diff --git a/lib/pliny/commands/creator.rb b/lib/pliny/commands/creator.rb index d2ef5f02..2b795659 100644 --- a/lib/pliny/commands/creator.rb +++ b/lib/pliny/commands/creator.rb @@ -26,6 +26,7 @@ def run! FileUtils.copy_entry template_dir, app_dir FileUtils.rm_rf("#{app_dir}/.git") + FileUtils.mv("#{app_dir}/.rubocop_template.yml", "#{app_dir}/.rubocop.yml") parse_erb_files display "Pliny app created. To start, run:" display "cd #{app_dir} && bin/setup" diff --git a/lib/template/.rubocop.yml b/lib/template/.rubocop_template.yml similarity index 100% rename from lib/template/.rubocop.yml rename to lib/template/.rubocop_template.yml diff --git a/spec/commands/creator_spec.rb b/spec/commands/creator_spec.rb index f89d04a7..b05020c8 100644 --- a/spec/commands/creator_spec.rb +++ b/spec/commands/creator_spec.rb @@ -21,6 +21,7 @@ @gen.run! assert File.exist?("./foobar") assert File.exist?("./foobar/Gemfile") + assert File.exist?("./foobar/.rubocop.yml") end it "deletes the .git from it" do