Skip to content

Commit

Permalink
sync/shared-config: tweak rubocop.
Browse files Browse the repository at this point in the history
- Use different source file from Homebrew/brew.
- Reject lines that don't make sense.
  • Loading branch information
MikeMcQuaid committed May 24, 2024
1 parent eb0759d commit bd3eb2e
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions .github/actions/sync/shared-config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
require "fileutils"
require "open3"
require "pathname"
require "yaml"

# This makes sense for a standalone script.
# rubocop:disable Style/TopLevelMethodDefinition
Expand All @@ -24,10 +25,19 @@ def git(*args)

ruby_version = ".ruby-version"
rubocop_yml = ".rubocop.yml"
rejected_rubocop_lines_regex = //

Check failure on line 28 in .github/actions/sync/shared-config.rb

View workflow job for this annotation

GitHub Actions / sync-shared-config (Homebrew/.github)

Lint/UselessAssignment: Useless assignment to variable - `rejected_rubocop_lines_regex`.

homebrew_ruby_version =
(homebrew_repository_path/"Library/Homebrew/vendor/portable-ruby-version").read.chomp.sub(/_\d+$/, "")
homebrew_rubocop_config = homebrew_repository_path/"Library/Homebrew/#{rubocop_yml}"
(homebrew_repository_path/"Library/Homebrew/vendor/portable-ruby-version").read
.chomp
.sub(/_\d+$/, "")
homebrew_rubocop_config_yaml = YAML.load_file(
homebrew_repository_path/"Library/#{rubocop_yml}",
permitted_classes: [Symbol, Regexp],
)
homebrew_rubocop_config = homebrew_rubocop_config_yaml.reject do |key, _|
key.match?(%r{\Arequire|inherit_from|inherit_mode|Cask/|Formula|Homebrew/|Performance/|RSpec|Sorbet/})
end.to_yaml

puts "Detecting changes…"
[
Expand All @@ -43,7 +53,7 @@ def git(*args)
when ruby_version
target_path.write("#{homebrew_ruby_version}\n")
when rubocop_yml
FileUtils.cp homebrew_rubocop_config, target_path
target_path.write("#{homebrew_rubocop_config}\n")
else
FileUtils.cp file, target_path
end
Expand Down

0 comments on commit bd3eb2e

Please sign in to comment.