diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index d6f6bd063ad..5ca58b54d45 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -664,19 +664,6 @@ Style/RescueStandardError: Style/SafeNavigation: Enabled: false -# This cop supports safe auto-correction (--auto-correct). -Style/SelfAssignment: - Exclude: - - 'lib/puppet/pops/evaluator/access_operator.rb' - - 'lib/puppet/pops/evaluator/collectors/fixed_set_collector.rb' - - 'lib/puppet/pops/evaluator/epp_evaluator.rb' - - 'lib/puppet/pops/parser/epp_parser.rb' - - 'lib/puppet/pops/parser/parser_support.rb' - - 'lib/puppet/pops/time/timestamp.rb' - - 'lib/puppet/pops/types/recursion_guard.rb' - - 'lib/puppet/property/ordered_list.rb' - - 'lib/puppet/util/autoload.rb' - # This cop supports safe auto-correction (--auto-correct). # Configuration parameters: AllowAsExpressionSeparator. Style/Semicolon: diff --git a/lib/puppet/pops/evaluator/access_operator.rb b/lib/puppet/pops/evaluator/access_operator.rb index eb09455666a..26f56a46464 100644 --- a/lib/puppet/pops/evaluator/access_operator.rb +++ b/lib/puppet/pops/evaluator/access_operator.rb @@ -67,7 +67,7 @@ def access_String(o, scope, keys) k2 = k2 < 0 ? o.length - k1 + k2 + 1 : k2 # abs length (negative k2 is length from pos to end count) # if k1 is outside, adjust to first position, and adjust length if k1 < 0 - k2 = k2 + k1 + k2 += k1 k1 = 0 end o[k1, k2] @@ -116,7 +116,7 @@ def access_Array(o, scope, keys) k2 = k2 < 0 ? o.length - k1 + k2 + 1 : k2 # abs length (negative k2 is length from pos to end count) # if k1 is outside, adjust to first position, and adjust length if k1 < 0 - k2 = k2 + k1 + k2 += k1 k1 = 0 end # Help ruby always return empty array when asking for a sub array diff --git a/lib/puppet/pops/evaluator/collectors/fixed_set_collector.rb b/lib/puppet/pops/evaluator/collectors/fixed_set_collector.rb index 1a3f8131152..184a9fae70b 100644 --- a/lib/puppet/pops/evaluator/collectors/fixed_set_collector.rb +++ b/lib/puppet/pops/evaluator/collectors/fixed_set_collector.rb @@ -25,7 +25,7 @@ def collect resolved << ref end - @resources = @resources - resolved + @resources -= resolved @scope.compiler.delete_collection(self) if @resources.empty? diff --git a/lib/puppet/pops/evaluator/epp_evaluator.rb b/lib/puppet/pops/evaluator/epp_evaluator.rb index 5b0d5b28f89..c69c64daa1b 100644 --- a/lib/puppet/pops/evaluator/epp_evaluator.rb +++ b/lib/puppet/pops/evaluator/epp_evaluator.rb @@ -31,7 +31,7 @@ def self.epp(scope, file, env_name, template_args = nil) unless Puppet::FileSystem.exist?(file) unless file =~ /\.epp$/ - file = file + ".epp" + file += ".epp" end end diff --git a/lib/puppet/pops/parser/epp_parser.rb b/lib/puppet/pops/parser/epp_parser.rb index 804f34c5e09..65342921d01 100644 --- a/lib/puppet/pops/parser/epp_parser.rb +++ b/lib/puppet/pops/parser/epp_parser.rb @@ -14,7 +14,7 @@ def initvars def parse_file(file) unless FileTest.exist?(file) unless file =~ /\.epp$/ - file = file + ".epp" + file += ".epp" end end @lexer.file = file diff --git a/lib/puppet/pops/parser/parser_support.rb b/lib/puppet/pops/parser/parser_support.rb index 4dbf04f7948..40ad98cfa52 100644 --- a/lib/puppet/pops/parser/parser_support.rb +++ b/lib/puppet/pops/parser/parser_support.rb @@ -77,7 +77,7 @@ def error(semantic, message) def parse_file(file) unless Puppet::FileSystem.exist?(file) unless file =~ /\.pp$/ - file = file + ".pp" + file += ".pp" end end @lexer.file = file diff --git a/lib/puppet/pops/time/timestamp.rb b/lib/puppet/pops/time/timestamp.rb index 1b6feb4b0bf..c8f506bf4c6 100644 --- a/lib/puppet/pops/time/timestamp.rb +++ b/lib/puppet/pops/time/timestamp.rb @@ -107,7 +107,7 @@ def self.parse(str, format = :default, timezone = nil) fraction = parsed[:sec_fraction] # Convert msec rational found in _strptime hash to usec - fraction = fraction * 1_000_000 unless fraction.nil? + fraction *= 1_000_000 unless fraction.nil? # Create the Time instance and adjust for timezone parsed_time = ::Time.utc(parsed[:year], parsed[:mon], parsed[:mday], parsed[:hour], parsed[:min], parsed[:sec], fraction) diff --git a/lib/puppet/pops/types/recursion_guard.rb b/lib/puppet/pops/types/recursion_guard.rb index 10be5603076..d1e8671274e 100644 --- a/lib/puppet/pops/types/recursion_guard.rb +++ b/lib/puppet/pops/types/recursion_guard.rb @@ -46,7 +46,7 @@ def recursive_that?(instance) def with_this(instance) if (@state & SELF_RECURSION_IN_THIS) == 0 tc = this_count - @state = @state | SELF_RECURSION_IN_THIS if this_put(instance) + @state |= SELF_RECURSION_IN_THIS if this_put(instance) if tc < this_count # recursive state detected result = yield(@state) @@ -66,7 +66,7 @@ def with_this(instance) def with_that(instance) if (@state & SELF_RECURSION_IN_THAT) == 0 tc = that_count - @state = @state | SELF_RECURSION_IN_THAT if that_put(instance) + @state |= SELF_RECURSION_IN_THAT if that_put(instance) if tc < that_count # recursive state detected result = yield(@state) @@ -85,7 +85,7 @@ def with_that(instance) # @return [Integer] the resulting state def add_this(instance) if (@state & SELF_RECURSION_IN_THIS) == 0 - @state = @state | SELF_RECURSION_IN_THIS if this_put(instance) + @state |= SELF_RECURSION_IN_THIS if this_put(instance) end @state end @@ -95,7 +95,7 @@ def add_this(instance) # @return [Integer] the resulting state def add_that(instance) if (@state & SELF_RECURSION_IN_THAT) == 0 - @state = @state | SELF_RECURSION_IN_THAT if that_put(instance) + @state |= SELF_RECURSION_IN_THAT if that_put(instance) end @state end diff --git a/lib/puppet/property/ordered_list.rb b/lib/puppet/property/ordered_list.rb index 2cfa49d8ef3..96f94e45a79 100644 --- a/lib/puppet/property/ordered_list.rb +++ b/lib/puppet/property/ordered_list.rb @@ -17,7 +17,7 @@ def add_should_with_current(should, current) # tricky trick # Preserve all the current items in the list # but move them to the back of the line - should = should + (current - should) + should += (current - should) end should end diff --git a/lib/puppet/util/autoload.rb b/lib/puppet/util/autoload.rb index fb86b5fb609..ce2c9b0ae3b 100644 --- a/lib/puppet/util/autoload.rb +++ b/lib/puppet/util/autoload.rb @@ -111,7 +111,7 @@ def reload_changed(env) # returns nil if no file is found # @api private def get_file(name, env) - name = name + '.rb' unless name =~ /\.rb$/ + name += '.rb' unless name =~ /\.rb$/ path = search_directories(env).find { |dir| Puppet::FileSystem.exist?(File.join(dir, name)) } path and File.join(path, name) end