Merge pull request #13006 from Homebrew/dependabot/bundler/Library/Homebrew/rubocop-rails-2.14.2
build(deps): bump rubocop-rails from 2.14.1 to 2.14.2 in /Library/Homebrew
This commit is contained in:
commit
ce91a1d7c1
@ -137,7 +137,7 @@ GEM
|
||||
rubocop-performance (1.13.3)
|
||||
rubocop (>= 1.7.0, < 2.0)
|
||||
rubocop-ast (>= 0.4.0)
|
||||
rubocop-rails (2.14.1)
|
||||
rubocop-rails (2.14.2)
|
||||
activesupport (>= 4.2.0)
|
||||
rack (>= 1.1)
|
||||
rubocop (>= 1.7.0, < 2.0)
|
||||
|
@ -1137,10 +1137,9 @@ class RuboCop::Cop::Rails::MigrationClassName < ::RuboCop::Cop::Base
|
||||
|
||||
private
|
||||
|
||||
def basename_without_timestamp_and_suffix; end
|
||||
def basename_without_timestamp_and_suffix(filepath); end
|
||||
def camelize(word); end
|
||||
def remove_gem_suffix(file_name); end
|
||||
def to_camelcase(word); end
|
||||
def to_snakecase(word); end
|
||||
end
|
||||
|
||||
RuboCop::Cop::Rails::MigrationClassName::MSG = T.let(T.unsafe(nil), String)
|
||||
@ -1856,6 +1855,12 @@ RuboCop::Cop::Rails::TimeZoneAssignment::RESTRICT_ON_SEND = T.let(T.unsafe(nil),
|
||||
class RuboCop::Cop::Rails::TransactionExitStatement < ::RuboCop::Cop::Base
|
||||
def exit_statements(param0); end
|
||||
def on_send(node); end
|
||||
|
||||
private
|
||||
|
||||
def in_rescue?(statement_node); end
|
||||
def nested_block?(statement_node); end
|
||||
def statement(statement_node); end
|
||||
end
|
||||
|
||||
RuboCop::Cop::Rails::TransactionExitStatement::MSG = T.let(T.unsafe(nil), String)
|
@ -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/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-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-sorbet-0.6.7/lib"
|
||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/ruby-macho-3.0.0/lib"
|
||||
|
@ -22,30 +22,30 @@ module RuboCop
|
||||
extend AutoCorrector
|
||||
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)
|
||||
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
|
||||
return if snake_class_name == basename
|
||||
class_identifier = node.identifier
|
||||
camelized_basename = camelize(basename)
|
||||
return if class_identifier.source.casecmp(camelized_basename).zero?
|
||||
|
||||
corrected_class_name = to_camelcase(basename)
|
||||
message = format(MSG, corrected_class_name: corrected_class_name)
|
||||
message = format(MSG, camelized_basename: camelized_basename)
|
||||
|
||||
add_offense(node.identifier, message: message) do |corrector|
|
||||
corrector.replace(node.identifier, corrected_class_name)
|
||||
add_offense(class_identifier, message: message) do |corrector|
|
||||
corrector.replace(class_identifier, camelized_basename)
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def basename_without_timestamp_and_suffix
|
||||
filepath = processed_source.file_path
|
||||
def basename_without_timestamp_and_suffix(filepath)
|
||||
basename = File.basename(filepath, '.rb')
|
||||
basename = remove_gem_suffix(basename)
|
||||
|
||||
basename.sub(/\A\d+_/, '')
|
||||
end
|
||||
|
||||
@ -54,17 +54,9 @@ module RuboCop
|
||||
file_name.sub(/\..+\z/, '')
|
||||
end
|
||||
|
||||
def to_camelcase(word)
|
||||
def camelize(word)
|
||||
word.split('_').map(&:capitalize).join
|
||||
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
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user