diff --git a/.rubocop.yml b/.rubocop.yml index e4af88e2dbc..026dd222722 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -99,6 +99,10 @@ Metrics/ModuleLength: - 'spec/**/*.rb' Naming/InclusiveLanguage: + FlaggedTerms: + offence: + Suggestions: + - offense Exclude: - lib/rubocop/cop/naming/inclusive_language.rb diff --git a/docs/modules/ROOT/pages/cops_style.adoc b/docs/modules/ROOT/pages/cops_style.adoc index 3848a3fdea2..591a9292737 100644 --- a/docs/modules/ROOT/pages/cops_style.adoc +++ b/docs/modules/ROOT/pages/cops_style.adoc @@ -3330,7 +3330,7 @@ will not attempt to automatically add a binding, or add filename and line values. This cop works only when a string literal is given as a code string. -No offence is reported if a string variable is given as below: +No offense is reported if a string variable is given as below: === Examples diff --git a/lib/rubocop/cop/layout/hash_alignment.rb b/lib/rubocop/cop/layout/hash_alignment.rb index d94b5291fac..ff6c6b0daa9 100644 --- a/lib/rubocop/cop/layout/hash_alignment.rb +++ b/lib/rubocop/cop/layout/hash_alignment.rb @@ -213,7 +213,7 @@ def on_hash(node) check_pairs(node) end - attr_accessor :offences_by, :column_deltas + attr_accessor :offenses_by, :column_deltas private @@ -224,7 +224,7 @@ def autocorrect_incompatible_with_other_cops?(node) end def reset! - self.offences_by = {} + self.offenses_by = {} self.column_deltas = Hash.new { |hash, key| hash[key] = {} } end @@ -248,33 +248,33 @@ def check_pairs(node) end end - add_offences + add_offenses end - def add_offences - kwsplat_offences = offences_by.delete(KeywordSplatAlignment) - register_offences_with_format(kwsplat_offences, KeywordSplatAlignment) + def add_offenses + kwsplat_offenses = offenses_by.delete(KeywordSplatAlignment) + register_offenses_with_format(kwsplat_offenses, KeywordSplatAlignment) - format, offences = offences_by.min_by { |_, v| v.length } - register_offences_with_format(offences, format) + format, offenses = offenses_by.min_by { |_, v| v.length } + register_offenses_with_format(offenses, format) end - def register_offences_with_format(offences, format) - (offences || []).each do |offence| - add_offense(offence, message: MESSAGES[format]) do |corrector| - delta = column_deltas[alignment_for(offence).first.class][offence] + def register_offenses_with_format(offenses, format) + (offenses || []).each do |offense| + add_offense(offense, message: MESSAGES[format]) do |corrector| + delta = column_deltas[alignment_for(offense).first.class][offense] - correct_node(corrector, offence, delta) unless delta.nil? + correct_node(corrector, offense, delta) unless delta.nil? end end end def check_delta(delta, node:, alignment:) - offences_by[alignment.class] ||= [] + offenses_by[alignment.class] ||= [] return if good_alignment? delta column_deltas[alignment.class][node] = delta - offences_by[alignment.class].push(node) + offenses_by[alignment.class].push(node) end def ignore_hash_argument?(node) diff --git a/lib/rubocop/cop/layout/indentation_style.rb b/lib/rubocop/cop/layout/indentation_style.rb index 130c2da0db0..acf21a925fb 100644 --- a/lib/rubocop/cop/layout/indentation_style.rb +++ b/lib/rubocop/cop/layout/indentation_style.rb @@ -43,7 +43,7 @@ def on_new_investigation str_ranges = string_literal_ranges(processed_source.ast) processed_source.lines.each.with_index(1) do |line, lineno| - next unless (range = find_offence(line, lineno)) + next unless (range = find_offense(line, lineno)) next if in_string_literal?(str_ranges, range) add_offense(range) { |corrector| autocorrect(corrector, range) } @@ -60,7 +60,7 @@ def autocorrect(corrector, range) end end - def find_offence(line, lineno) + def find_offense(line, lineno) match = if style == :spaces line.match(/\A\s*\t+/) else diff --git a/lib/rubocop/cop/style/eval_with_location.rb b/lib/rubocop/cop/style/eval_with_location.rb index 47fd11336d6..2f9ff67762b 100644 --- a/lib/rubocop/cop/style/eval_with_location.rb +++ b/lib/rubocop/cop/style/eval_with_location.rb @@ -43,7 +43,7 @@ module Style # RUBY # # This cop works only when a string literal is given as a code string. - # No offence is reported if a string variable is given as below: + # No offense is reported if a string variable is given as below: # # @example # # not checked diff --git a/spec/rubocop/cli/options_spec.rb b/spec/rubocop/cli/options_spec.rb index f1ed8476c7f..bed23fbe71d 100644 --- a/spec/rubocop/cli/options_spec.rb +++ b/spec/rubocop/cli/options_spec.rb @@ -1806,7 +1806,7 @@ def f $stdin = STDIN end - it 'prints offence reports to stderr and corrected code to stdout if --auto-correct-all and --stderr are used' do + it 'prints offense reports to stderr and corrected code to stdout if --auto-correct-all and --stderr are used' do $stdin = StringIO.new('p $/') argv = ['--auto-correct-all', '--only=Style/SpecialGlobalVars', diff --git a/spec/rubocop/cop/lint/mixed_regexp_capture_types_spec.rb b/spec/rubocop/cop/lint/mixed_regexp_capture_types_spec.rb index 2b80d385d53..e19a9466bd4 100644 --- a/spec/rubocop/cop/lint/mixed_regexp_capture_types_spec.rb +++ b/spec/rubocop/cop/lint/mixed_regexp_capture_types_spec.rb @@ -37,38 +37,38 @@ # For example, `/(?#{var}*)` is interpreted as `/(?*)`. # So it does not offense when variables are used in regexp literals. context 'when containing a non-regexp literal' do - it 'does not register an offence when containing a lvar' do + it 'does not register an offense when containing a lvar' do expect_no_offenses(<<~'RUBY') var = '(\d+)' /(?#{var}*)/ RUBY end - it 'does not register an offence when containing a ivar' do + it 'does not register an offense when containing a ivar' do expect_no_offenses(<<~'RUBY') /(?#{@var}*)/ RUBY end - it 'does not register an offence when containing a cvar' do + it 'does not register an offense when containing a cvar' do expect_no_offenses(<<~'RUBY') /(?#{@@var}*)/ RUBY end - it 'does not register an offence when containing a gvar' do + it 'does not register an offense when containing a gvar' do expect_no_offenses(<<~'RUBY') /(?#{$var}*)/ RUBY end - it 'does not register an offence when containing a method' do + it 'does not register an offense when containing a method' do expect_no_offenses(<<~'RUBY') /(?#{do_something}*)/ RUBY end - it 'does not register an offence when containing a constant' do + it 'does not register an offense when containing a constant' do expect_no_offenses(<<~'RUBY') /(?#{CONST}*)/ RUBY diff --git a/spec/rubocop/cop/lint/out_of_range_regexp_ref_spec.rb b/spec/rubocop/cop/lint/out_of_range_regexp_ref_spec.rb index 8023862e57f..f075eeecef3 100644 --- a/spec/rubocop/cop/lint/out_of_range_regexp_ref_spec.rb +++ b/spec/rubocop/cop/lint/out_of_range_regexp_ref_spec.rb @@ -66,7 +66,7 @@ # RuboCop does not know a value of variables that it will contain in the regexp literal. # For example, `/(?#{var}*)` is interpreted as `/(?*)`. # So it does not offense when variables are used in regexp literals. - it 'does not register an offence regexp containing non literal' do + it 'does not register an offense regexp containing non literal' do expect_no_offenses(<<~'RUBY') var = '(\d+)' /(?#{var}*)/ =~ "12" diff --git a/spec/rubocop/cop/style/block_delimiters_spec.rb b/spec/rubocop/cop/style/block_delimiters_spec.rb index bc51589c65e..51b9efe5281 100644 --- a/spec/rubocop/cop/style/block_delimiters_spec.rb +++ b/spec/rubocop/cop/style/block_delimiters_spec.rb @@ -633,7 +633,7 @@ expect_no_offenses('each { |x| }') end - it 'registers an offence for a multi-line block with do-end' do + it 'registers an offense for a multi-line block with do-end' do expect_offense(<<~RUBY) each do |x| ^^ Prefer `{...}` over `do...end` for blocks. diff --git a/spec/rubocop/cop/style/format_string_token_spec.rb b/spec/rubocop/cop/style/format_string_token_spec.rb index be01da77205..99ce2c7ffa1 100644 --- a/spec/rubocop/cop/style/format_string_token_spec.rb +++ b/spec/rubocop/cop/style/format_string_token_spec.rb @@ -21,7 +21,7 @@ expect_no_offenses("format('%#{token}', foo)") end - it 'registers offence for dual unannotated' do + it 'registers offense for dual unannotated' do expect_offense(<<~RUBY) format('%#{token} %s', foo, bar) ^^ Prefer [...] diff --git a/spec/rubocop/result_cache_spec.rb b/spec/rubocop/result_cache_spec.rb index 263012a4d4e..474d5fb0123 100644 --- a/spec/rubocop/result_cache_spec.rb +++ b/spec/rubocop/result_cache_spec.rb @@ -53,7 +53,7 @@ def abs(path) # Fixes https://github.com/rubocop/rubocop/issues/6274 context 'when offenses are saved' do - context 'an offence with status corrected' do + context 'an offense with status corrected' do let(:offense) do RuboCop::Cop::Offense.new( :warning, location, 'unused var', 'Lint/UselessAssignment', :corrected @@ -66,7 +66,7 @@ def abs(path) end end - context 'an offence with status corrected_with_todo' do + context 'an offense with status corrected_with_todo' do let(:offense) do RuboCop::Cop::Offense.new( :warning, location, 'unused var', 'Lint/UselessAssignment', :corrected_with_todo @@ -79,7 +79,7 @@ def abs(path) end end - context 'an offence with status uncorrected' do + context 'an offense with status uncorrected' do let(:offense) do RuboCop::Cop::Offense.new( :warning, location, 'unused var', 'Lint/UselessAssignment', :uncorrected @@ -92,7 +92,7 @@ def abs(path) end end - context 'an offence with status unsupported' do + context 'an offense with status unsupported' do let(:offense) do RuboCop::Cop::Offense.new( :warning, location, 'unused var', 'Lint/UselessAssignment', :unsupported @@ -105,7 +105,7 @@ def abs(path) end end - context 'an offence with status new_status' do + context 'an offense with status new_status' do let(:offense) do RuboCop::Cop::Offense.new( :warning, location, 'unused var', 'Lint/UselessAssignment', :new_status