diff --git a/lib/rubocop/cop/security/compound_hash.rb b/lib/rubocop/cop/security/compound_hash.rb index d08932f6160..b9ab0656b94 100644 --- a/lib/rubocop/cop/security/compound_hash.rb +++ b/lib/rubocop/cop/security/compound_hash.rb @@ -30,8 +30,8 @@ module Security class CompoundHash < Base COMBINATOR_IN_HASH_MSG = 'Use `[...].hash` instead of combining hash values manually.' MONUPLE_HASH_MSG = - 'Delegate hash directly without wrapping in an array when only using a single value' - REDUNDANT_HASH_MSG = 'Calling .hash on elements of a hashed array is redundant' + 'Delegate hash directly without wrapping in an array when only using a single value.' + REDUNDANT_HASH_MSG = 'Calling .hash on elements of a hashed array is redundant.' # @!method hash_method_definition?(node) def_node_matcher :hash_method_definition?, <<~PATTERN diff --git a/lib/rubocop/cop/style/conditional_assignment.rb b/lib/rubocop/cop/style/conditional_assignment.rb index ebb17ab62f7..7afdadf6ad6 100644 --- a/lib/rubocop/cop/style/conditional_assignment.rb +++ b/lib/rubocop/cop/style/conditional_assignment.rb @@ -214,7 +214,7 @@ class ConditionalAssignment < Base extend AutoCorrector MSG = 'Use the return of the conditional for variable assignment and comparison.' - ASSIGN_TO_CONDITION_MSG = 'Assign variables inside of conditionals' + ASSIGN_TO_CONDITION_MSG = 'Assign variables inside of conditionals.' VARIABLE_ASSIGNMENT_TYPES = %i[casgn cvasgn gvasgn ivasgn lvasgn].freeze ASSIGNMENT_TYPES = VARIABLE_ASSIGNMENT_TYPES + %i[and_asgn or_asgn op_asgn masgn].freeze LINE_LENGTH = 'Layout/LineLength' diff --git a/spec/rubocop/cop/alignment_corrector_spec.rb b/spec/rubocop/cop/alignment_corrector_spec.rb index c752ea9116b..a1de990133c 100644 --- a/spec/rubocop/cop/alignment_corrector_spec.rb +++ b/spec/rubocop/cop/alignment_corrector_spec.rb @@ -10,7 +10,7 @@ expect_offense(<<~RUBY) # >> 2 42 - ^^ Indent this node + ^^ Indent this node. RUBY expect_correction(<<~RUBY, loop: false) @@ -25,7 +25,7 @@ expect_offense(<<~RUBY) # << 3 42 - ^^ Indent this node + ^^ Indent this node. RUBY expect_correction(<<~RUBY, loop: false) @@ -44,7 +44,7 @@ expect_offense(<<~RUBY) # >> #{column_delta} begin - ^^^^^ Indent this node + ^^^^^ Indent this node. #{start_heredoc} a b @@ -80,7 +80,7 @@ expect_offense(<<~RUBY) # >> 2 begin - ^^^^^ Indent this node + ^^^^^ Indent this node. <> 2 begin - ^^^^^ Indent this node + ^^^^^ Indent this node. dstr = 'a b diff --git a/spec/rubocop/cop/security/compound_hash_spec.rb b/spec/rubocop/cop/security/compound_hash_spec.rb index d9856303ffd..94482f859eb 100644 --- a/spec/rubocop/cop/security/compound_hash_spec.rb +++ b/spec/rubocop/cop/security/compound_hash_spec.rb @@ -50,7 +50,7 @@ def object.hash expect_offense(<<~RUBY) def hash [1].hash - ^^^^^^^^ Delegate hash directly without wrapping in an array when only using a single value + ^^^^^^^^ Delegate hash directly without wrapping in an array when only using a single value. end RUBY end @@ -58,7 +58,7 @@ def hash it 'registers an offense if .hash is called on any elements of a hashed array' do expect_offense(<<~RUBY) [1, 2.hash, 3].hash - ^^^^^^ Calling .hash on elements of a hashed array is redundant + ^^^^^^ Calling .hash on elements of a hashed array is redundant. RUBY end diff --git a/spec/rubocop/cop/style/conditional_assignment_assign_in_condition_spec.rb b/spec/rubocop/cop/style/conditional_assignment_assign_in_condition_spec.rb index 3903c012a7e..ecc8b67cb05 100644 --- a/spec/rubocop/cop/style/conditional_assignment_assign_in_condition_spec.rb +++ b/spec/rubocop/cop/style/conditional_assignment_assign_in_condition_spec.rb @@ -5,7 +5,7 @@ it 'registers an offense assigning any variable type to ternary' do expect_offense(<<~RUBY, variable: variable) %{variable} = foo? ? 1 : 2 - ^{variable}^^^^^^^^^^^^^^^ Assign variables inside of conditionals + ^{variable}^^^^^^^^^^^^^^^ Assign variables inside of conditionals. RUBY expect_correction(<<~RUBY) @@ -16,7 +16,7 @@ it 'registers an offense assigning any variable type to if else' do expect_offense(<<~RUBY, variable: variable) %{variable} = if foo - ^{variable}^^^^^^^^^ Assign variables inside of conditionals + ^{variable}^^^^^^^^^ Assign variables inside of conditionals. 1 else 2 @@ -35,7 +35,7 @@ it 'registers an offense assigning any variable type to if elsif else' do expect_offense(<<~RUBY, variable: variable) %{variable} = if foo - ^{variable}^^^^^^^^^ Assign variables inside of conditionals + ^{variable}^^^^^^^^^ Assign variables inside of conditionals. 1 elsif baz 2 @@ -58,7 +58,7 @@ it 'registers an offense assigning any variable type to if else with multiple assignment' do expect_offense(<<~RUBY, variable: variable) %{variable}, %{variable} = if foo - ^{variable}^^^{variable}^^^^^^^^^ Assign variables inside of conditionals + ^{variable}^^^{variable}^^^^^^^^^ Assign variables inside of conditionals. something else something_else @@ -85,7 +85,7 @@ it 'registers an offense assigning any variable type to unless else' do expect_offense(<<~RUBY, variable: variable) %{variable} = unless foo - ^{variable}^^^^^^^^^^^^^ Assign variables inside of conditionals + ^{variable}^^^^^^^^^^^^^ Assign variables inside of conditionals. 1 else 2 @@ -104,7 +104,7 @@ it 'registers an offense for assigning any variable type to case when' do expect_offense(<<~RUBY, variable: variable) %{variable} = case foo - ^{variable}^^^^^^^^^^^ Assign variables inside of conditionals + ^{variable}^^^^^^^^^^^ Assign variables inside of conditionals. when "a" 1 when "b" @@ -130,7 +130,7 @@ it 'registers an offense for assigning any variable type to case in' do expect_offense(<<~RUBY, variable: variable) %{variable} = case foo - ^{variable}^^^^^^^^^^^ Assign variables inside of conditionals + ^{variable}^^^^^^^^^^^ Assign variables inside of conditionals. in "a" 1 in "b" @@ -168,7 +168,7 @@ it 'registers an offense for any assignment to ternary' do expect_offense(<<~RUBY, assignment: assignment) bar %{assignment} (foo? ? 1 : 2) - ^^^^^{assignment}^^^^^^^^^^^^^^^ Assign variables inside of conditionals + ^^^^^{assignment}^^^^^^^^^^^^^^^ Assign variables inside of conditionals. RUBY expect_correction(<<~RUBY) @@ -179,7 +179,7 @@ it 'registers an offense any assignment to if else' do expect_offense(<<~RUBY, assignment: assignment) bar %{assignment} if foo - ^^^^^{assignment}^^^^^^^ Assign variables inside of conditionals + ^^^^^{assignment}^^^^^^^ Assign variables inside of conditionals. 1 else 2 @@ -206,7 +206,7 @@ it 'registers an offense for any assignment to unless else' do expect_offense(<<~RUBY, assignment: assignment) bar %{assignment} unless foo - ^^^^^{assignment}^^^^^^^^^^^ Assign variables inside of conditionals + ^^^^^{assignment}^^^^^^^^^^^ Assign variables inside of conditionals. 1 else 2 @@ -225,7 +225,7 @@ it 'registers an offense any assignment to case when' do expect_offense(<<~RUBY, assignment: assignment) bar %{assignment} case foo - ^^^^^{assignment}^^^^^^^^^ Assign variables inside of conditionals + ^^^^^{assignment}^^^^^^^^^ Assign variables inside of conditionals. when "a" 1 else @@ -258,7 +258,7 @@ it 'assigning any variable type to a multiline if else' do expect_offense(<<~RUBY, variable: variable) %{variable} = if foo - ^{variable}^^^^^^^^^ Assign variables inside of conditionals + ^{variable}^^^^^^^^^ Assign variables inside of conditionals. something 1 else @@ -281,7 +281,7 @@ it 'assigning any variable type to an if else with multiline in one branch' do expect_offense(<<~RUBY, variable: variable) %{variable} = if foo - ^{variable}^^^^^^^^^ Assign variables inside of conditionals + ^{variable}^^^^^^^^^ Assign variables inside of conditionals. 1 else something_else @@ -302,7 +302,7 @@ it 'assigning any variable type to a multiline if elsif else' do expect_offense(<<~RUBY, variable: variable) %{variable} = if foo - ^{variable}^^^^^^^^^ Assign variables inside of conditionals + ^{variable}^^^^^^^^^ Assign variables inside of conditionals. something 1 elsif bar @@ -337,7 +337,7 @@ it 'assigning any variable type to a multiline unless else' do expect_offense(<<~RUBY, variable: variable) %{variable} = unless foo - ^{variable}^^^^^^^^^^^^^ Assign variables inside of conditionals + ^{variable}^^^^^^^^^^^^^ Assign variables inside of conditionals. something 1 else @@ -360,7 +360,7 @@ it 'assigning any variable type to a multiline case when' do expect_offense(<<~RUBY, variable: variable) %{variable} = case foo - ^{variable}^^^^^^^^^^^ Assign variables inside of conditionals + ^{variable}^^^^^^^^^^^ Assign variables inside of conditionals. when "a" something 1 @@ -455,7 +455,7 @@ it 'any assignment to a multiline if else' do expect_offense(<<~RUBY, assignment: assignment) bar %{assignment} if foo - ^^^^^{assignment}^^^^^^^ Assign variables inside of conditionals + ^^^^^{assignment}^^^^^^^ Assign variables inside of conditionals. something 1 else @@ -478,7 +478,7 @@ it 'any assignment to a multiline unless else' do expect_offense(<<~RUBY, assignment: assignment) bar %{assignment} unless foo - ^^^^^{assignment}^^^^^^^^^^^ Assign variables inside of conditionals + ^^^^^{assignment}^^^^^^^^^^^ Assign variables inside of conditionals. something 1 else @@ -501,7 +501,7 @@ it 'any assignment to a multiline case when' do expect_offense(<<~RUBY, assignment: assignment) bar %{assignment} case foo - ^^^^^{assignment}^^^^^^^^^ Assign variables inside of conditionals + ^^^^^{assignment}^^^^^^^^^ Assign variables inside of conditionals. when "a" something 1 @@ -567,7 +567,7 @@ it 'corrects assignment to an if else condition' do expect_offense(<<~RUBY) bar = if foo - ^^^^^^^^^^^^ Assign variables inside of conditionals + ^^^^^^^^^^^^ Assign variables inside of conditionals. 1 else 2 @@ -586,7 +586,7 @@ it 'corrects assignment to an if elsif else condition' do expect_offense(<<~RUBY) bar = if foo - ^^^^^^^^^^^^ Assign variables inside of conditionals + ^^^^^^^^^^^^ Assign variables inside of conditionals. 1 elsif foobar 2 @@ -609,7 +609,7 @@ it 'corrects assignment to an if elsif else with multiple elsifs' do expect_offense(<<~RUBY) bar = if foo - ^^^^^^^^^^^^ Assign variables inside of conditionals + ^^^^^^^^^^^^ Assign variables inside of conditionals. 1 elsif foobar 2 @@ -636,7 +636,7 @@ it 'corrects assignment to an unless else condition' do expect_offense(<<~RUBY) bar = unless foo - ^^^^^^^^^^^^^^^^ Assign variables inside of conditionals + ^^^^^^^^^^^^^^^^ Assign variables inside of conditionals. 1 else 2 @@ -655,7 +655,7 @@ it 'corrects assignment to a case when else condition' do expect_offense(<<~RUBY) bar = case foo - ^^^^^^^^^^^^^^ Assign variables inside of conditionals + ^^^^^^^^^^^^^^ Assign variables inside of conditionals. when foobar 1 else @@ -676,7 +676,7 @@ it 'corrects assignment to a case when else with multiple whens' do expect_offense(<<~RUBY) bar = case foo - ^^^^^^^^^^^^^^ Assign variables inside of conditionals + ^^^^^^^^^^^^^^ Assign variables inside of conditionals. when foobar 1 when baz @@ -701,7 +701,7 @@ it 'corrects assignment to a ternary operator' do expect_offense(<<~RUBY) bar = foo? ? 1 : 2 - ^^^^^^^^^^^^^^^^^^ Assign variables inside of conditionals + ^^^^^^^^^^^^^^^^^^ Assign variables inside of conditionals. RUBY expect_correction(<<~RUBY) @@ -793,7 +793,7 @@ it 'registers an offense for assignment using a method that ends with an equal sign' do expect_offense(<<~RUBY) self.attributes = foo? ? 1 : 2 - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Assign variables inside of conditionals + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Assign variables inside of conditionals. RUBY expect_correction(<<~RUBY) @@ -804,7 +804,7 @@ it 'registers an offense for assignment using []=' do expect_offense(<<~RUBY) foo[:a] = if bar? - ^^^^^^^^^^^^^^^^^ Assign variables inside of conditionals + ^^^^^^^^^^^^^^^^^ Assign variables inside of conditionals. 1 else 2 @@ -823,7 +823,7 @@ it 'registers an offense for assignment to an if then else' do expect_offense(<<~RUBY) bar = if foo then 1 - ^^^^^^^^^^^^^^^^^^^ Assign variables inside of conditionals + ^^^^^^^^^^^^^^^^^^^ Assign variables inside of conditionals. else 2 end RUBY @@ -838,7 +838,7 @@ it 'registers an offense for an assignment that uses if branch bodies including a block' do expect_offense(<<~RUBY) result = if condition - ^^^^^^^^^^^^^^^^^^^^^ Assign variables inside of conditionals + ^^^^^^^^^^^^^^^^^^^^^ Assign variables inside of conditionals. foo do end else @@ -861,7 +861,7 @@ it 'registers an offense for assignment to case when then else' do expect_offense(<<~RUBY) baz = case foo - ^^^^^^^^^^^^^^ Assign variables inside of conditionals + ^^^^^^^^^^^^^^ Assign variables inside of conditionals. when bar then 1 else 2 end @@ -878,7 +878,7 @@ it 'registers an offense when empty `case` condition' do expect_offense(<<~RUBY) var = case - ^^^^^^^^^^ Assign variables inside of conditionals + ^^^^^^^^^^ Assign variables inside of conditionals. when foo bar else @@ -907,7 +907,7 @@ it 'corrects assignment to a namespaced constant' do expect_offense(<<~RUBY) FOO::BAR = if baz? - ^^^^^^^^^^^^^^^^^^ Assign variables inside of conditionals + ^^^^^^^^^^^^^^^^^^ Assign variables inside of conditionals. 1 else 2 @@ -926,7 +926,7 @@ it 'corrects assignment when without `else` branch' do expect_offense(<<~RUBY) var = if foo - ^^^^^^^^^^^^ Assign variables inside of conditionals + ^^^^^^^^^^^^ Assign variables inside of conditionals. bar elsif baz qux @@ -1024,7 +1024,7 @@ it 'corrects assignment to a multiline if else condition' do expect_offense(<<~RUBY) bar = if foo - ^^^^^^^^^^^^ Assign variables inside of conditionals + ^^^^^^^^^^^^ Assign variables inside of conditionals. something 1 else @@ -1047,7 +1047,7 @@ it 'corrects assignment to a multiline if elsif else condition' do expect_offense(<<~RUBY) bar = if foo - ^^^^^^^^^^^^ Assign variables inside of conditionals + ^^^^^^^^^^^^ Assign variables inside of conditionals. something 1 elsif foobar @@ -1076,7 +1076,7 @@ it 'corrects assignment to an if elsif else with multiple elsifs' do expect_offense(<<~RUBY) bar = if foo - ^^^^^^^^^^^^ Assign variables inside of conditionals + ^^^^^^^^^^^^ Assign variables inside of conditionals. something 1 elsif foobar @@ -1111,7 +1111,7 @@ it 'corrects assignment to an unless else condition' do expect_offense(<<~RUBY) bar = unless foo - ^^^^^^^^^^^^^^^^ Assign variables inside of conditionals + ^^^^^^^^^^^^^^^^ Assign variables inside of conditionals. something 1 else @@ -1134,7 +1134,7 @@ it 'corrects assignment to a case when else condition' do expect_offense(<<~RUBY) bar = case foo - ^^^^^^^^^^^^^^ Assign variables inside of conditionals + ^^^^^^^^^^^^^^ Assign variables inside of conditionals. when foobar something 1 @@ -1159,7 +1159,7 @@ it 'corrects assignment to a case when else with multiple whens' do expect_offense(<<~RUBY) bar = case foo - ^^^^^^^^^^^^^^ Assign variables inside of conditionals + ^^^^^^^^^^^^^^ Assign variables inside of conditionals. when foobar something 1 diff --git a/spec/support/cops/alignment_directive.rb b/spec/support/cops/alignment_directive.rb index 12d7b1d361a..64713d31cf3 100644 --- a/spec/support/cops/alignment_directive.rb +++ b/spec/support/cops/alignment_directive.rb @@ -10,7 +10,7 @@ module Test class AlignmentDirective < RuboCop::Cop::Base extend AutoCorrector - MSG = 'Indent this node' + MSG = 'Indent this node.' def on_new_investigation processed_source.ast_with_comments.each do |node, comments|