brew vendor-gems: commit updates.

This commit is contained in:
BrewTestBot 2022-03-18 18:06:02 +00:00
parent 65c385d8b4
commit 38402aeb52
No known key found for this signature in database
GPG Key ID: 82D7D104050B0F0F
125 changed files with 41 additions and 32 deletions

View File

@ -86,7 +86,7 @@ $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/ruby-progressbar-1.11
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/unicode-display_width-2.1.0/lib" $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/unicode-display_width-2.1.0/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-1.26.0/lib" $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-1.26.0/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-performance-1.13.3/lib" $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-performance-1.13.3/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-rails-2.14.1/lib" $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-rails-2.14.2/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-rspec-2.9.0/lib" $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-rspec-2.9.0/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-sorbet-0.6.7/lib" $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-sorbet-0.6.7/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/ruby-macho-3.0.0/lib" $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/ruby-macho-3.0.0/lib"

View File

@ -22,30 +22,30 @@ module RuboCop
extend AutoCorrector extend AutoCorrector
include MigrationsHelper include MigrationsHelper
MSG = 'Replace with `%<corrected_class_name>s` that matches the file name.' MSG = 'Replace with `%<camelized_basename>s` that matches the file name.'
def on_class(node) def on_class(node)
return if in_migration?(node) return unless migration_class?(node)
snake_class_name = to_snakecase(node.identifier.source) basename = basename_without_timestamp_and_suffix(processed_source.file_path)
basename = basename_without_timestamp_and_suffix class_identifier = node.identifier
return if snake_class_name == basename camelized_basename = camelize(basename)
return if class_identifier.source.casecmp(camelized_basename).zero?
corrected_class_name = to_camelcase(basename) message = format(MSG, camelized_basename: camelized_basename)
message = format(MSG, corrected_class_name: corrected_class_name)
add_offense(node.identifier, message: message) do |corrector| add_offense(class_identifier, message: message) do |corrector|
corrector.replace(node.identifier, corrected_class_name) corrector.replace(class_identifier, camelized_basename)
end end
end end
private private
def basename_without_timestamp_and_suffix def basename_without_timestamp_and_suffix(filepath)
filepath = processed_source.file_path
basename = File.basename(filepath, '.rb') basename = File.basename(filepath, '.rb')
basename = remove_gem_suffix(basename) basename = remove_gem_suffix(basename)
basename.sub(/\A\d+_/, '') basename.sub(/\A\d+_/, '')
end end
@ -54,17 +54,9 @@ module RuboCop
file_name.sub(/\..+\z/, '') file_name.sub(/\..+\z/, '')
end end
def to_camelcase(word) def camelize(word)
word.split('_').map(&:capitalize).join word.split('_').map(&:capitalize).join
end end
def to_snakecase(word)
word
.gsub(/([A-Z\d]+)([A-Z][a-z])/, '\1_\2')
.gsub(/([a-z\d])([A-Z])/, '\1_\2')
.tr('-', '_')
.downcase
end
end end
end end
end end

Some files were not shown because too many files have changed in this diff Show More