Module: Rails::Tc::Rubocop
- Defined in:
- lib/rails/tc/rubocop.rb
Defined Under Namespace
Classes: InvalidConfigError
Constant Summary collapse
- ACCESSOR_GROUPING_PATH =
"Style/AccessorGrouping"
Class Method Summary collapse
Class Method Details
.patch_configuration ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/rails/tc/rubocop.rb', line 10 def self.patch_configuration rubocop_path = Rails.root.join(".rubocop.yml").to_s return unless File.exist?(rubocop_path) config = YAML.safe_load(File.read(rubocop_path)) raise InvalidConfigError.new("Invalid rubocop config") unless config.is_a?(Hash) modified = false if config.fetch(ACCESSOR_GROUPING_PATH, {}).fetch("Enabled", true) config[ACCESSOR_GROUPING_PATH] = { "Enabled" => false } modified = true end if modified File.open(rubocop_path, "w") { |f| f.write YAML.dump(config) } puts "Rubocop configuration patched" else puts "Rubocop configuration unchanged" end rescue puts "Unable to patch Rubocop configuration" end |