From 5a220f0615d875e066ffe653b3ab1a162f61b320 Mon Sep 17 00:00:00 2001 From: ydah <13041216+ydah@users.noreply.github.com> Date: Tue, 14 Jun 2022 10:18:40 +0900 Subject: [PATCH] Fix some typos - "assignement" -> "assignment" - "indicies" -> "indices" - "RedndantSelf" -> "RedundantSelf" - "correcly" -> "correctly" - "arugment" -> "argument" - "undersoce"-> "underscore" - "regesters" -> "registers" - "whtn" -> "when" - "ergister" -> "register" - "redendant" -> "redundant" - "officense" -> "offense" - "exitted" -> "exited" --- docs/modules/ROOT/pages/cops_rails.adoc | 2 +- lib/rubocop/cop/rails/time_zone_assignment.rb | 4 ++-- lib/rubocop/cop/rails/transaction_exit_statement.rb | 2 +- .../cop/rails/unique_validation_without_index.rb | 4 ++-- lib/rubocop/rails/schema_loader/schema.rb | 10 +++++----- spec/rubocop/cli/autocorrect_spec.rb | 2 +- .../cop/rails/active_record_callbacks_order_spec.rb | 6 +++--- spec/rubocop/cop/rails/blank_spec.rb | 2 +- spec/rubocop/cop/rails/dynamic_find_by_spec.rb | 2 +- .../cop/rails/eager_evaluation_log_message_spec.rb | 2 +- spec/rubocop/cop/rails/find_by_spec.rb | 2 +- spec/rubocop/cop/rails/output_safety_spec.rb | 2 +- .../rails/redundant_receiver_in_with_options_spec.rb | 2 +- .../cop/rails/transaction_exit_statement_spec.rb | 2 +- spec/rubocop/rails/schema_loader_spec.rb | 12 ++++++------ 15 files changed, 28 insertions(+), 28 deletions(-) diff --git a/docs/modules/ROOT/pages/cops_rails.adoc b/docs/modules/ROOT/pages/cops_rails.adoc index 5dd1127463..2bf9c0179f 100644 --- a/docs/modules/ROOT/pages/cops_rails.adoc +++ b/docs/modules/ROOT/pages/cops_rails.adoc @@ -5456,7 +5456,7 @@ end This cop checks for the use of exit statements (namely `return`, `break` and `throw`) in transactions. This is due to the eventual unexpected behavior when using ActiveRecord >= 7, where transactions -exitted using these statements are being rollbacked rather than +exited using these statements are being rollbacked rather than committed (pre ActiveRecord 7 behavior). As alternatives, it would be more intuitive to explicitly raise an diff --git a/lib/rubocop/cop/rails/time_zone_assignment.rb b/lib/rubocop/cop/rails/time_zone_assignment.rb index d23b686736..0cc54b5b9f 100644 --- a/lib/rubocop/cop/rails/time_zone_assignment.rb +++ b/lib/rubocop/cop/rails/time_zone_assignment.rb @@ -22,12 +22,12 @@ class TimeZoneAssignment < Base MSG = 'Use `Time.use_zone` with block instead of `Time.zone=`.' RESTRICT_ON_SEND = %i[zone=].freeze - def_node_matcher :time_zone_assignement?, <<~PATTERN + def_node_matcher :time_zone_assignment?, <<~PATTERN (send (const nil? :Time) :zone= ...) PATTERN def on_send(node) - return unless time_zone_assignement?(node) + return unless time_zone_assignment?(node) add_offense(node) end diff --git a/lib/rubocop/cop/rails/transaction_exit_statement.rb b/lib/rubocop/cop/rails/transaction_exit_statement.rb index 9150b362ea..d21241e6b3 100644 --- a/lib/rubocop/cop/rails/transaction_exit_statement.rb +++ b/lib/rubocop/cop/rails/transaction_exit_statement.rb @@ -6,7 +6,7 @@ module Rails # Checks for the use of exit statements (namely `return`, # `break` and `throw`) in transactions. This is due to the eventual # unexpected behavior when using ActiveRecord >= 7, where transactions - # exitted using these statements are being rollbacked rather than + # exited using these statements are being rollbacked rather than # committed (pre ActiveRecord 7 behavior). # # As alternatives, it would be more intuitive to explicitly raise an diff --git a/lib/rubocop/cop/rails/unique_validation_without_index.rb b/lib/rubocop/cop/rails/unique_validation_without_index.rb index aed1112b02..f2aa63db34 100644 --- a/lib/rubocop/cop/rails/unique_validation_without_index.rb +++ b/lib/rubocop/cop/rails/unique_validation_without_index.rb @@ -56,9 +56,9 @@ def find_schema_information(node) def with_index?(klass, table, names) # Compatibility for Rails 4.2. - add_indicies = schema.add_indicies_by(table_name: table_name(klass)) + add_indices = schema.add_indices_by(table_name: table_name(klass)) - (table.indices + add_indicies).any? do |index| + (table.indices + add_indices).any? do |index| index.unique && (index.columns.to_set == names || include_column_names_in_expression_index?(index, names)) diff --git a/lib/rubocop/rails/schema_loader/schema.rb b/lib/rubocop/rails/schema_loader/schema.rb index e4d13f82b6..60a7721366 100644 --- a/lib/rubocop/rails/schema_loader/schema.rb +++ b/lib/rubocop/rails/schema_loader/schema.rb @@ -5,11 +5,11 @@ module Rails module SchemaLoader # Represent db/schema.rb class Schema - attr_reader :tables, :add_indicies + attr_reader :tables, :add_indices def initialize(ast) @tables = [] - @add_indicies = [] + @add_indices = [] build!(ast) end @@ -20,8 +20,8 @@ def table_by(name:) end end - def add_indicies_by(table_name:) - add_indicies.select do |add_index| + def add_indices_by(table_name:) + add_indices.select do |add_index| add_index.table_name == table_name end end @@ -39,7 +39,7 @@ def build!(ast) # Compatibility for Rails 4.2. each_add_index(ast) do |add_index_def| - @add_indicies << AddIndex.new(add_index_def) + @add_indices << AddIndex.new(add_index_def) end end diff --git a/spec/rubocop/cli/autocorrect_spec.rb b/spec/rubocop/cli/autocorrect_spec.rb index 833a700a4b..63e46cd947 100644 --- a/spec/rubocop/cli/autocorrect_spec.rb +++ b/spec/rubocop/cli/autocorrect_spec.rb @@ -9,7 +9,7 @@ RuboCop::ConfigLoader.default_configuration.for_all_cops['SuggestExtensions'] = false end - it 'corrects `Rails/SafeNavigation` with `Style/RedndantSelf`' do + it 'corrects `Rails/SafeNavigation` with `Style/RedundantSelf`' do create_file('.rubocop.yml', <<~YAML) Rails/SafeNavigation: ConvertTry: true diff --git a/spec/rubocop/cop/rails/active_record_callbacks_order_spec.rb b/spec/rubocop/cop/rails/active_record_callbacks_order_spec.rb index af47a6ca88..a6088ad6dc 100644 --- a/spec/rubocop/cop/rails/active_record_callbacks_order_spec.rb +++ b/spec/rubocop/cop/rails/active_record_callbacks_order_spec.rb @@ -35,7 +35,7 @@ def some_method RUBY end - it 'correcly autocorrects when there is a preceding comment for callback method' do + it 'correctly autocorrects when there is a preceding comment for callback method' do new_source = autocorrect_source(<<~RUBY) class User < ApplicationRecord # This is a @@ -63,7 +63,7 @@ class User < ApplicationRecord RUBY end - it 'correcly autocorrects when there is an inline comment for callback method' do + it 'correctly autocorrects when there is an inline comment for callback method' do new_source = autocorrect_source(<<~RUBY) class User < ApplicationRecord after_commit :after_commit_callback # after_commit inline comment @@ -79,7 +79,7 @@ class User < ApplicationRecord RUBY end - it 'correcly autocorrects when there are multiple callbacks of the same type' do + it 'correctly autocorrects when there are multiple callbacks of the same type' do new_source = autocorrect_source(<<~RUBY) class User < ApplicationRecord after_commit :after_commit_callback1 diff --git a/spec/rubocop/cop/rails/blank_spec.rb b/spec/rubocop/cop/rails/blank_spec.rb index 68dcc9872a..cd4b0134ad 100644 --- a/spec/rubocop/cop/rails/blank_spec.rb +++ b/spec/rubocop/cop/rails/blank_spec.rb @@ -41,7 +41,7 @@ end # Bug: https://github.com/rubocop/rubocop/issues/4814 - it 'does not break when LHS of `or` is a send node with an arugment' do + it 'does not break when LHS of `or` is a send node with an argument' do expect_no_offenses('x(1) || something') end diff --git a/spec/rubocop/cop/rails/dynamic_find_by_spec.rb b/spec/rubocop/cop/rails/dynamic_find_by_spec.rb index 1ee5e72d8a..d03bae17dd 100644 --- a/spec/rubocop/cop/rails/dynamic_find_by_spec.rb +++ b/spec/rubocop/cop/rails/dynamic_find_by_spec.rb @@ -91,7 +91,7 @@ end end - context 'with column includes undersoce' do + context 'with column includes underscore' do it 'registers an offense and corrects' do expect_offense(<<~RUBY) User.find_by_first_name(name) diff --git a/spec/rubocop/cop/rails/eager_evaluation_log_message_spec.rb b/spec/rubocop/cop/rails/eager_evaluation_log_message_spec.rb index 3904f6e857..b422d500be 100644 --- a/spec/rubocop/cop/rails/eager_evaluation_log_message_spec.rb +++ b/spec/rubocop/cop/rails/eager_evaluation_log_message_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Rails::EagerEvaluationLogMessage, :config do - it 'regesters an offense when passing an interpolated string to Rails.logger.debug' do + it 'registers an offense when passing an interpolated string to Rails.logger.debug' do expect_offense(<<~'RUBY') Rails.logger.debug "The time is #{Time.now}" ^^^^^^^^^^^^^^^^^^^^^^^^^ Pass a block to `Rails.logger.debug`. diff --git a/spec/rubocop/cop/rails/find_by_spec.rb b/spec/rubocop/cop/rails/find_by_spec.rb index 2de01ce55d..ec6f9ff25c 100644 --- a/spec/rubocop/cop/rails/find_by_spec.rb +++ b/spec/rubocop/cop/rails/find_by_spec.rb @@ -29,7 +29,7 @@ expect_no_offenses('User.find_by(id: x)') end - it 'does not register an offense whtn `take` is not used immediately after `where`' do + it 'does not register an offense when `take` is not used immediately after `where`' do expect_no_offenses(<<~RUBY) Model.where(foo: :bar).order(:baz).take RUBY diff --git a/spec/rubocop/cop/rails/output_safety_spec.rb b/spec/rubocop/cop/rails/output_safety_spec.rb index d56c85c0e1..98cae59b88 100644 --- a/spec/rubocop/cop/rails/output_safety_spec.rb +++ b/spec/rubocop/cop/rails/output_safety_spec.rb @@ -110,7 +110,7 @@ expect_no_offenses('raw(one, two)') end - it 'does not ergister an offense for comments' do + it 'does not register an offense for comments' do expect_no_offenses(<<~RUBY) # foo.html_safe # raw foo diff --git a/spec/rubocop/cop/rails/redundant_receiver_in_with_options_spec.rb b/spec/rubocop/cop/rails/redundant_receiver_in_with_options_spec.rb index c1b9f1864f..dd6495b562 100644 --- a/spec/rubocop/cop/rails/redundant_receiver_in_with_options_spec.rb +++ b/spec/rubocop/cop/rails/redundant_receiver_in_with_options_spec.rb @@ -44,7 +44,7 @@ class Account < ApplicationRecord end it 'registers an offense and corrects when including multiple ' \ - 'redendant receivers in single line' do + 'redundant receivers in single line' do expect_offense(<<~RUBY) with_options options: false do |merger| merger.invoke(merger.something) diff --git a/spec/rubocop/cop/rails/transaction_exit_statement_spec.rb b/spec/rubocop/cop/rails/transaction_exit_statement_spec.rb index b8e2b0f5f5..b53b7f5705 100644 --- a/spec/rubocop/cop/rails/transaction_exit_statement_spec.rb +++ b/spec/rubocop/cop/rails/transaction_exit_statement_spec.rb @@ -95,7 +95,7 @@ RUBY end - it 'registers an officense when `return` is used outside of a `rescue`' do + it 'registers an offense when `return` is used outside of a `rescue`' do expect_offense(<<~RUBY) ApplicationRecord.transaction do return if user.active? diff --git a/spec/rubocop/rails/schema_loader_spec.rb b/spec/rubocop/rails/schema_loader_spec.rb index 846e9e0175..1d4b4db250 100644 --- a/spec/rubocop/rails/schema_loader_spec.rb +++ b/spec/rubocop/rails/schema_loader_spec.rb @@ -99,12 +99,12 @@ RUBY it 'has an `add_index` for users table' do - add_indicies = loaded_schema.add_indicies_by(table_name: 'users') - expect(add_indicies.size).to eq 2 - expect(add_indicies.first.name).to eq 'index_users_on_account' - expect(add_indicies.first.table_name).to eq 'users' - expect(add_indicies.first.columns).to eq ['account'] - expect(add_indicies.first.unique).to be true + add_indices = loaded_schema.add_indices_by(table_name: 'users') + expect(add_indices.size).to eq 2 + expect(add_indices.first.name).to eq 'index_users_on_account' + expect(add_indices.first.table_name).to eq 'users' + expect(add_indices.first.columns).to eq ['account'] + expect(add_indices.first.unique).to be true end end end