Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package rubygem-rubocop for openSUSE:Factory 
checked in at 2021-06-01 10:39:58
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/rubygem-rubocop (Old)
 and      /work/SRC/openSUSE:Factory/.rubygem-rubocop.new.1898 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "rubygem-rubocop"

Tue Jun  1 10:39:58 2021 rev:25 rq:896521 version:1.15.0

Changes:
--------
--- /work/SRC/openSUSE:Factory/rubygem-rubocop/rubygem-rubocop.changes  
2021-05-16 23:40:59.177861180 +0200
+++ 
/work/SRC/openSUSE:Factory/.rubygem-rubocop.new.1898/rubygem-rubocop.changes    
    2021-06-01 10:41:34.789233713 +0200
@@ -1,0 +2,29 @@
+Tue Jun  1 03:40:48 UTC 2021 - Manuel Schnitzer <[email protected]>
+
+- updated to version 1.15.0
+
+  ### New features
+
+  * [#9734](https://github.com/rubocop/rubocop/pull/9734): Add 
`Style/TopLevelMethodDefinition` cop. ([@tejasbubane][])
+  * [#9780](https://github.com/rubocop/rubocop/issues/9780): Support summary 
report for `JUnitFormatter`. ([@koic][])
+  * [#9798](https://github.com/rubocop/rubocop/pull/9798): Make 
`Layout/ArgumentAlignment` aware of kwargs. ([@koic][])
+
+  ### Bug fixes
+
+  * [#9749](https://github.com/rubocop/rubocop/issues/9749): Fix 
autocorrection for `Layout/LineLength` to not move the first argument of an 
unparenthesized `send` node to the next line, which changes behaviour. 
([@dvandersluis][])
+  * [#9799](https://github.com/rubocop/rubocop/issues/9799): Fix invalid line 
splitting by `Layout/LineLength` for `send` nodes with heredoc arguments. 
([@dvandersluis][])
+  * [#9773](https://github.com/rubocop/rubocop/issues/9773): Fix 
`Style/EmptyLiteral` to not register offenses for `String.new` when 
`Style/FrozenStringLiteral` is enabled. ([@dvandersluis][])
+  * [#9771](https://github.com/rubocop/rubocop/issues/9771): Change 
`AllowDSLWriters` to true by default for `Style/TrivialAccessors`. ([@koic][])
+  * [#9777](https://github.com/rubocop/rubocop/pull/9777): Fix an incorrect 
auto-correct for `Style/RedundantBegin` when using multi-line `if` in `begin` 
block. ([@koic][])
+  * [#9791](https://github.com/rubocop/rubocop/pull/9791): Fix a false 
negative for `Layout/IndentationWidth` when using `ensure` in `do` ... `end` 
block. ([@koic][])
+  * [#9766](https://github.com/rubocop/rubocop/pull/9766): Fix a clobbering 
error for `Style/ClassAndModuleChildren` cop with compact style. 
([@tejasbubane][])
+  * [#9767](https://github.com/rubocop/rubocop/issues/9767): Fix 
`Style/ClassAndModuleChildren` cop to preserve comments. ([@tejasbubane][])
+  * [#9792](https://github.com/rubocop/rubocop/issues/9792): Fix false 
positive for `Lint/Void` cop with ranges. ([@tejasbubane][])
+
+  ### Changes
+
+  * [#9770](https://github.com/rubocop/rubocop/issues/9770): Update 
`Lint/EmptyBlock` to handle procs the same way as lambdas. ([@dvandersluis][])
+  * [#9776](https://github.com/rubocop/rubocop/pull/9776): Update 
`Style/NilLambda` to handle procs as well. ([@dvandersluis][])
+  * [#9744](https://github.com/rubocop/rubocop/pull/9744): The parallel flag 
will now be automatically ignored when combined with `--cache false`. 
Previously, an error was raised and execution stopped. ([@rrosenblum][])
+
+-------------------------------------------------------------------

Old:
----
  rubocop-1.14.0.gem

New:
----
  rubocop-1.15.0.gem

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ rubygem-rubocop.spec ++++++
--- /var/tmp/diff_new_pack.F7EXhk/_old  2021-06-01 10:41:35.265234523 +0200
+++ /var/tmp/diff_new_pack.F7EXhk/_new  2021-06-01 10:41:35.265234523 +0200
@@ -16,28 +16,29 @@
 #
 
 
-%define mod_name rubocop
-%define mod_full_name %{mod_name}-%{version}
 #
 # This file was generated with a gem2rpm.yml and not just plain gem2rpm.
 # All sections marked as MANUAL, license headers, summaries and descriptions
 # can be maintained in that file. Please consult this file before editing any
 # of those fields
 #
+
 Name:           rubygem-rubocop
-Version:        1.14.0
+Version:        1.15.0
 Release:        0
-Summary:        Automatic Ruby code style checking tool
-License:        MIT
-Group:          Development/Languages/Ruby
-URL:            https://github.com/rubocop/rubocop
-Source:         https://rubygems.org/gems/%{mod_full_name}.gem
-Source1:        gem2rpm.yml
+%define mod_name rubocop
+%define mod_full_name %{mod_name}-%{version}
+BuildRoot:      %{_tmppath}/%{name}-%{version}-build
 BuildRequires:  %{ruby >= 2.5.0}
 BuildRequires:  %{rubygem gem2rpm}
 BuildRequires:  ruby-macros >= 5
 BuildRequires:  update-alternatives
-# FIXME: use proper Requires(pre/post/preun/...)
+URL:            https://github.com/rubocop/rubocop
+Source:         https://rubygems.org/gems/%{mod_full_name}.gem
+Source1:        gem2rpm.yml
+Summary:        Automatic Ruby code style checking tool
+License:        MIT
+Group:          Development/Languages/Ruby
 PreReq:         update-alternatives
 
 %description

++++++ rubocop-1.14.0.gem -> rubocop-1.15.0.gem ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/README.md new/README.md
--- old/README.md       2021-05-05 09:54:15.000000000 +0200
+++ new/README.md       2021-05-17 09:16:51.000000000 +0200
@@ -29,6 +29,8 @@
 
[![OpenCollective](https://opencollective.com/rubocop/sponsors/badge.svg)](#open-collective-sponsors)
 
[![Tidelift](https://tidelift.com/badges/package/rubygems/rubocop)](https://tidelift.com/subscription/pkg/rubygems-rubocop?utm_source=rubygems-rubocop&utm_medium=referral&utm_campaign=readme)
 
+Working on RuboCop is often fun, but it also requires a great deal of time and 
energy.
+
 **Please consider [financially supporting its ongoing development](#funding).**
 
 ## Installation
@@ -52,7 +54,7 @@
 in your `Gemfile`:
 
 ```rb
-gem 'rubocop', '~> 1.14', require: false
+gem 'rubocop', '~> 1.15', require: false
 ```
 
 See [our versioning policy](https://docs.rubocop.org/rubocop/versioning.html) 
for further details.
Binary files old/checksums.yaml.gz and new/checksums.yaml.gz differ
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/config/default.yml new/config/default.yml
--- old/config/default.yml      2021-05-05 09:54:15.000000000 +0200
+++ new/config/default.yml      2021-05-17 09:16:51.000000000 +0200
@@ -1612,7 +1612,7 @@
   Description: 'This cop checks for blocks without a body.'
   Enabled: pending
   VersionAdded: '1.1'
-  VersionChanged: '1.3'
+  VersionChanged: '1.15'
   AllowComments: true
   AllowEmptyLambdas: true
 
@@ -3480,6 +3480,7 @@
 
 Style/HashConversion:
   Description: 'Avoid Hash[] in favor of ary.to_h or literal hashes.'
+  StyleGuide: '#avoid-hash-constructor'
   Enabled: pending
   VersionAdded: '1.10'
   VersionChanged: '1.11'
@@ -3998,6 +3999,7 @@
   Description: 'Prefer `-> {}` to `-> { nil }`.'
   Enabled: pending
   VersionAdded: '1.3'
+  VersionChanged: '1.15'
 
 Style/NonNilCheck:
   Description: 'Checks for redundant nil checks.'
@@ -4651,6 +4653,12 @@
     - require_parentheses_when_complex
   AllowSafeAssignment: true
 
+Style/TopLevelMethodDefinition:
+  Description: 'This cop looks for top-level method definitions.'
+  StyleGuide: '#top-level-methods'
+  Enabled: false
+  VersionAdded: '1.15'
+
 Style/TrailingBodyOnClass:
   Description: 'Class body goes below class statement.'
   Enabled: true
@@ -4737,7 +4745,7 @@
   StyleGuide: '#attr_family'
   Enabled: true
   VersionAdded: '0.9'
-  VersionChanged: '0.77'
+  VersionChanged: '1.15'
   # When set to `false` the cop will suggest the use of accessor methods
   # in situations like:
   #
@@ -4756,7 +4764,7 @@
   # on_exception :restart
   #
   # Commonly used in DSLs
-  AllowDSLWriters: false
+  AllowDSLWriters: true
   IgnoreClassMethods: false
   AllowedMethods:
     - to_ary
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/lib/rubocop/cop/internal_affairs/example_description.rb 
new/lib/rubocop/cop/internal_affairs/example_description.rb
--- old/lib/rubocop/cop/internal_affairs/example_description.rb 2021-05-05 
09:54:15.000000000 +0200
+++ new/lib/rubocop/cop/internal_affairs/example_description.rb 2021-05-17 
09:16:51.000000000 +0200
@@ -41,7 +41,7 @@
 
         EXPECT_NO_OFFENSES_INCORRECT_DESCRIPTIONS = [
           /^(adds|registers|reports|finds) (an? )?offense/,
-          /^flags\b/
+          /^(flags|handles|works)\b/
         ].freeze
 
         EXPECT_OFFENSE_INCORRECT_DESCRIPTIONS = [
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/rubocop/cop/layout/argument_alignment.rb 
new/lib/rubocop/cop/layout/argument_alignment.rb
--- old/lib/rubocop/cop/layout/argument_alignment.rb    2021-05-05 
09:54:15.000000000 +0200
+++ new/lib/rubocop/cop/layout/argument_alignment.rb    2021-05-17 
09:16:51.000000000 +0200
@@ -10,33 +10,39 @@
       #   # good
       #
       #   foo :bar,
-      #       :baz
+      #       :baz,
+      #       key: value
       #
       #   foo(
       #     :bar,
-      #     :baz
+      #     :baz,
+      #     key: value
       #   )
       #
       #   # bad
       #
       #   foo :bar,
-      #     :baz
+      #     :baz,
+      #     key: value
       #
       #   foo(
       #     :bar,
-      #       :baz
+      #       :baz,
+      #       key: value
       #   )
       #
       # @example EnforcedStyle: with_fixed_indentation
       #   # good
       #
       #   foo :bar,
-      #     :baz
+      #     :baz,
+      #     key: value
       #
       #   # bad
       #
       #   foo :bar,
-      #       :baz
+      #       :baz,
+      #       key: value
       class ArgumentAlignment < Base
         include Alignment
         extend AutoCorrector
@@ -47,14 +53,25 @@
           'following the first line of a multi-line method call.'
 
         def on_send(node)
-          return if node.arguments.size < 2 || node.send_type? && 
node.method?(:[]=)
+          first_arg = node.first_argument
+          return if !multiple_arguments?(node, first_arg) || node.send_type? 
&& node.method?(:[]=)
 
-          check_alignment(node.arguments, base_column(node, node.arguments))
+          if first_arg.hash_type?
+            check_alignment(first_arg.pairs, base_column(node, 
first_arg.pairs.first))
+          else
+            check_alignment(node.arguments, base_column(node, first_arg))
+          end
         end
         alias on_csend on_send
 
         private
 
+        def multiple_arguments?(node, first_argument)
+          return true if node.arguments.size >= 2
+
+          first_argument&.hash_type? && first_argument.pairs.count >= 2
+        end
+
         def autocorrect(corrector, node)
           AlignmentCorrector.correct(corrector, processed_source, node, 
column_delta)
         end
@@ -67,14 +84,14 @@
           cop_config['EnforcedStyle'] == 'with_fixed_indentation'
         end
 
-        def base_column(node, args)
-          if fixed_indentation?
+        def base_column(node, first_argument)
+          if fixed_indentation? || first_argument.nil?
             lineno = target_method_lineno(node)
             line = node.source_range.source_buffer.source_line(lineno)
             indentation_of_line = /\S.*/.match(line).begin(0)
             indentation_of_line + configured_indentation_width
           else
-            display_column(args.first.source_range)
+            display_column(first_argument.source_range)
           end
         end
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/lib/rubocop/cop/layout/first_hash_element_indentation.rb 
new/lib/rubocop/cop/layout/first_hash_element_indentation.rb
--- old/lib/rubocop/cop/layout/first_hash_element_indentation.rb        
2021-05-05 09:54:15.000000000 +0200
+++ new/lib/rubocop/cop/layout/first_hash_element_indentation.rb        
2021-05-17 09:16:51.000000000 +0200
@@ -91,6 +91,8 @@
         end
 
         def on_send(node)
+          return if enforce_first_argument_with_fixed_indentation?
+
           each_argument_node(node, :hash) do |hash_node, left_parenthesis|
             check(hash_node, left_parenthesis)
           end
@@ -182,6 +184,16 @@
             'where the left brace is.'
           end
         end
+
+        def enforce_first_argument_with_fixed_indentation?
+          return false unless argument_alignment_config['Enabled']
+
+          argument_alignment_config['EnforcedStyle'] == 
'with_fixed_indentation'
+        end
+
+        def argument_alignment_config
+          config.for_cop('Layout/ArgumentAlignment')
+        end
       end
     end
   end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/rubocop/cop/layout/hash_alignment.rb 
new/lib/rubocop/cop/layout/hash_alignment.rb
--- old/lib/rubocop/cop/layout/hash_alignment.rb        2021-05-05 
09:54:15.000000000 +0200
+++ new/lib/rubocop/cop/layout/hash_alignment.rb        2021-05-17 
09:16:51.000000000 +0200
@@ -200,14 +200,12 @@
         alias on_super on_send
         alias on_yield on_send
 
-        def on_hash(node) # rubocop:todo Metrics/CyclomaticComplexity
-          return if ignored_node?(node)
-          return if node.pairs.empty? || node.single_line?
-
-          return unless alignment_for_hash_rockets
-                        .any? { |a| a.checkable_layout?(node) } &&
-                        alignment_for_colons
-                        .any? { |a| a.checkable_layout?(node) }
+        def on_hash(node)
+          return if enforce_first_argument_with_fixed_indentation? || 
ignored_node?(node) ||
+                    node.pairs.empty? || node.single_line?
+
+          proc = ->(a) { a.checkable_layout?(node) }
+          return unless alignment_for_hash_rockets.any?(proc) && 
alignment_for_colons.any?(proc)
 
           check_pairs(node)
         end
@@ -353,6 +351,16 @@
         def good_alignment?(column_deltas)
           column_deltas.values.all?(&:zero?)
         end
+
+        def enforce_first_argument_with_fixed_indentation?
+          return false unless argument_alignment_config['Enabled']
+
+          argument_alignment_config['EnforcedStyle'] == 
'with_fixed_indentation'
+        end
+
+        def argument_alignment_config
+          config.for_cop('Layout/ArgumentAlignment')
+        end
       end
     end
   end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/rubocop/cop/layout/indentation_width.rb 
new/lib/rubocop/cop/layout/indentation_width.rb
--- old/lib/rubocop/cop/layout/indentation_width.rb     2021-05-05 
09:54:15.000000000 +0200
+++ new/lib/rubocop/cop/layout/indentation_width.rb     2021-05-17 
09:16:51.000000000 +0200
@@ -313,9 +313,12 @@
             check_rescue?(body_node)
           elsif body_node.ensure_type?
             block_body, = *body_node
-            return unless block_body
 
-            check_rescue?(block_body) if block_body.rescue_type?
+            if block_body&.rescue_type?
+              check_rescue?(block_body)
+            else
+              !block_body.nil?
+            end
           else
             true
           end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/rubocop/cop/lint/deprecated_class_methods.rb 
new/lib/rubocop/cop/lint/deprecated_class_methods.rb
--- old/lib/rubocop/cop/lint/deprecated_class_methods.rb        2021-05-05 
09:54:15.000000000 +0200
+++ new/lib/rubocop/cop/lint/deprecated_class_methods.rb        2021-05-17 
09:16:51.000000000 +0200
@@ -12,6 +12,8 @@
       #   File.exists?(some_path)
       #   Dir.exists?(some_path)
       #   iterator?
+      #   Socket.gethostbyname(host)
+      #   Socket.gethostbyaddr(host)
       #
       # @example
       #
@@ -20,6 +22,8 @@
       #   File.exist?(some_path)
       #   Dir.exist?(some_path)
       #   block_given?
+      #   Addrinfo.getaddrinfo(nodename, service)
+      #   Addrinfo.tcp(host, port).getnameinfo
       class DeprecatedClassMethods < Base
         extend AutoCorrector
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/rubocop/cop/lint/empty_block.rb 
new/lib/rubocop/cop/lint/empty_block.rb
--- old/lib/rubocop/cop/lint/empty_block.rb     2021-05-05 09:54:15.000000000 
+0200
+++ new/lib/rubocop/cop/lint/empty_block.rb     2021-05-17 09:16:51.000000000 
+0200
@@ -7,7 +7,11 @@
       # Such empty blocks are typically an oversight or we should provide a 
comment
       # be clearer what we're aiming for.
       #
-      # Empty lambdas are ignored by default.
+      # Empty lambdas and procs are ignored by default.
+      #
+      # NOTE: For backwards compatibility, the configuration that 
allows/disallows
+      # empty lambdas and procs is called `AllowEmptyLambdas`, even though it 
also
+      # applies to procs.
       #
       # @example
       #   # bad
@@ -40,6 +44,10 @@
       #   end
       #   (callable || placeholder).call
       #
+      #   proc { }
+      #
+      #   Proc.new { }
+      #
       # @example AllowEmptyLambdas: false
       #   # bad
       #   allow(subject).to receive(:callable).and_return(-> {})
@@ -48,12 +56,16 @@
       #   end
       #   (callable || placeholder).call
       #
+      #   proc { }
+      #
+      #   Proc.new { }
+      #
       class EmptyBlock < Base
         MSG = 'Empty block detected.'
 
         def on_block(node)
           return if node.body
-          return if allow_empty_lambdas? && node.lambda?
+          return if allow_empty_lambdas? && lambda_or_proc?(node)
           return if cop_config['AllowComments'] && allow_comment?(node)
 
           add_offense(node)
@@ -76,6 +88,10 @@
           regexp_pattern = "# rubocop : (disable|todo) ([^,],)* 
(all|#{cop_name})"
           Regexp.new(regexp_pattern.gsub(' ', '\s*')).match?(comment)
         end
+
+        def lambda_or_proc?(node)
+          node.lambda? || node.proc?
+        end
       end
     end
   end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/rubocop/cop/lint/void.rb 
new/lib/rubocop/cop/lint/void.rb
--- old/lib/rubocop/cop/lint/void.rb    2021-05-05 09:54:15.000000000 +0200
+++ new/lib/rubocop/cop/lint/void.rb    2021-05-17 09:16:51.000000000 +0200
@@ -104,7 +104,7 @@
         end
 
         def check_literal(node)
-          return if !node.literal? || node.xstr_type?
+          return if !node.literal? || node.xstr_type? || node.range_type?
 
           add_offense(node, message: format(LIT_MSG, lit: node.source))
         end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/rubocop/cop/mixin/check_line_breakable.rb 
new/lib/rubocop/cop/mixin/check_line_breakable.rb
--- old/lib/rubocop/cop/mixin/check_line_breakable.rb   2021-05-05 
09:54:15.000000000 +0200
+++ new/lib/rubocop/cop/mixin/check_line_breakable.rb   2021-05-17 
09:16:51.000000000 +0200
@@ -70,18 +70,34 @@
       def extract_first_element_over_column_limit(node, elements, max)
         line = node.first_line
 
-        # If the first argument is a hash pair but the method is not 
parenthesized,
-        # the argument cannot be moved to another line because it cause a 
syntax error.
-        elements.shift if node.send_type? && !node.parenthesized? && 
elements.first.pair_type?
+        # If a `send` node is not parenthesized, don't move the first element, 
because it
+        # can result in changed behavior or a syntax error.
+        elements = elements.drop(1) if node.send_type? && !node.parenthesized?
 
         i = 0
         i += 1 while within_column_limit?(elements[i], max, line)
+        i = shift_elements_for_heredoc_arg(node, elements, i)
+
+        return if i.nil?
         return elements.first if i.zero?
 
         elements[i - 1]
       end
 
       # @api private
+      # If a send node contains a heredoc argument, splitting cannot happen
+      # after the heredoc or else it will cause a syntax error.
+      def shift_elements_for_heredoc_arg(node, elements, index)
+        return index unless node.send_type?
+
+        heredoc_index = elements.index { |arg| (arg.str_type? || 
arg.dstr_type?) && arg.heredoc? }
+        return index unless heredoc_index
+        return nil if heredoc_index.zero?
+
+        heredoc_index >= index ? index : heredoc_index + 1
+      end
+
+      # @api private
       def within_column_limit?(element, max, line)
         element && element.loc.column <= max && element.loc.line == line
       end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/rubocop/cop/mixin/frozen_string_literal.rb 
new/lib/rubocop/cop/mixin/frozen_string_literal.rb
--- old/lib/rubocop/cop/mixin/frozen_string_literal.rb  2021-05-05 
09:54:15.000000000 +0200
+++ new/lib/rubocop/cop/mixin/frozen_string_literal.rb  2021-05-17 
09:16:51.000000000 +0200
@@ -35,6 +35,12 @@
         leading_comment_lines.any? { |line| 
MagicComment.parse(line).frozen_string_literal? }
       end
 
+      def frozen_string_literals_disabled?
+        leading_comment_lines.any? do |line|
+          MagicComment.parse(line).frozen_string_literal == false
+        end
+      end
+
       def frozen_string_literal_specified?
         leading_comment_lines.any? do |line|
           MagicComment.parse(line).frozen_string_literal_specified?
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/rubocop/cop/style/class_and_module_children.rb 
new/lib/rubocop/cop/style/class_and_module_children.rb
--- old/lib/rubocop/cop/style/class_and_module_children.rb      2021-05-05 
09:54:15.000000000 +0200
+++ new/lib/rubocop/cop/style/class_and_module_children.rb      2021-05-17 
09:16:51.000000000 +0200
@@ -87,9 +87,18 @@
         end
 
         def compact_node(corrector, node)
-          replacement = "#{node.body.type} #{compact_identifier_name(node)}"
           range = range_between(node.loc.keyword.begin_pos, 
node.body.loc.name.end_pos)
-          corrector.replace(range, replacement)
+          corrector.replace(range, compact_replacement(node))
+        end
+
+        def compact_replacement(node)
+          replacement = "#{node.body.type} #{compact_identifier_name(node)}"
+
+          body_comments = processed_source.ast_with_comments[node.body]
+          unless body_comments.empty?
+            replacement = 
body_comments.map(&:text).push(replacement).join("\n")
+          end
+          replacement
         end
 
         def compact_identifier_name(node)
@@ -132,6 +141,9 @@
         end
 
         def check_compact_style(node, body)
+          parent = node.parent
+          return if parent&.class_type? || parent&.module_type?
+
           return unless needs_compacting?(body)
 
           add_offense(node.loc.name, message: COMPACT_MSG) do |corrector|
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/rubocop/cop/style/empty_literal.rb 
new/lib/rubocop/cop/style/empty_literal.rb
--- old/lib/rubocop/cop/style/empty_literal.rb  2021-05-05 09:54:15.000000000 
+0200
+++ new/lib/rubocop/cop/style/empty_literal.rb  2021-05-17 09:16:51.000000000 
+0200
@@ -62,7 +62,7 @@
             ARR_MSG
           elsif offense_hash_node?(node)
             HASH_MSG
-          elsif str_node(node) && !frozen_string_literals_enabled?
+          elsif str_node(node) && !frozen_strings?
             format(STR_MSG, prefer: preferred_string_literal)
           end
         end
@@ -125,6 +125,13 @@
             end
           end
         end
+
+        def frozen_strings?
+          return true if frozen_string_literals_enabled?
+
+          frozen_string_cop_enabled = 
config.for_cop('Style/FrozenStringLiteral')['Enabled']
+          frozen_string_cop_enabled && !frozen_string_literals_disabled?
+        end
       end
     end
   end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/rubocop/cop/style/nil_lambda.rb 
new/lib/rubocop/cop/style/nil_lambda.rb
--- old/lib/rubocop/cop/style/nil_lambda.rb     2021-05-05 09:54:15.000000000 
+0200
+++ new/lib/rubocop/cop/style/nil_lambda.rb     2021-05-17 09:16:51.000000000 
+0200
@@ -3,8 +3,8 @@
 module RuboCop
   module Cop
     module Style
-      # This cop checks for lambdas that always return nil, which can be 
replaced
-      # with an empty lambda instead.
+      # This cop checks for lambdas and procs that always return nil,
+      # which can be replaced with an empty lambda or proc instead.
       #
       # @example
       #   # bad
@@ -14,6 +14,12 @@
       #     next nil
       #   end
       #
+      #   proc { nil }
+      #
+      #   Proc.new do
+      #     break nil
+      #   end
+      #
       #   # good
       #   -> {}
       #
@@ -22,11 +28,15 @@
       #
       #   -> (x) { nil if x }
       #
+      #   proc {}
+      #
+      #   Proc.new { nil if x }
+      #
       class NilLambda < Base
         extend AutoCorrector
         include RangeHelp
 
-        MSG = 'Use an empty lambda instead of always returning nil.'
+        MSG = 'Use an empty %<type>s instead of always returning nil.'
 
         # @!method nil_return?(node)
         def_node_matcher :nil_return?, <<~PATTERN
@@ -34,19 +44,26 @@
         PATTERN
 
         def on_block(node)
-          return unless node.lambda?
+          return unless node.lambda? || node.proc?
           return unless nil_return?(node.body)
 
-          add_offense(node) do |corrector|
-            range = if node.single_line?
-                      range_with_surrounding_space(range: 
node.body.loc.expression)
-                    else
-                      range_by_whole_lines(node.body.loc.expression, 
include_final_newline: true)
-                    end
-
-            corrector.remove(range)
+          message = format(MSG, type: node.lambda? ? 'lambda' : 'proc')
+          add_offense(node, message: message) do |corrector|
+            autocorrect(corrector, node)
           end
         end
+
+        private
+
+        def autocorrect(corrector, node)
+          range = if node.single_line?
+                    range_with_surrounding_space(range: 
node.body.loc.expression)
+                  else
+                    range_by_whole_lines(node.body.loc.expression, 
include_final_newline: true)
+                  end
+
+          corrector.remove(range)
+        end
       end
     end
   end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/rubocop/cop/style/redundant_begin.rb 
new/lib/rubocop/cop/style/redundant_begin.rb
--- old/lib/rubocop/cop/style/redundant_begin.rb        2021-05-05 
09:54:15.000000000 +0200
+++ new/lib/rubocop/cop/style/redundant_begin.rb        2021-05-17 
09:16:51.000000000 +0200
@@ -110,7 +110,7 @@
           first_child = node.children.first
 
           source = first_child.source
-          source = "(#{source})" if first_child.if_type?
+          source = "(#{source})" if first_child.if_type? && 
first_child.modifier_form?
 
           corrector.replace(offense_range, source)
           corrector.remove(range_between(offense_range.end_pos, 
first_child.source_range.end_pos))
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/rubocop/cop/style/top_level_method_definition.rb 
new/lib/rubocop/cop/style/top_level_method_definition.rb
--- old/lib/rubocop/cop/style/top_level_method_definition.rb    1970-01-01 
01:00:00.000000000 +0100
+++ new/lib/rubocop/cop/style/top_level_method_definition.rb    2021-05-17 
09:16:51.000000000 +0200
@@ -0,0 +1,75 @@
+# frozen_string_literal: true
+
+module RuboCop
+  module Cop
+    module Style
+      # Newcomers to ruby applications may write top-level methods,
+      # when ideally they should be organized in appropriate classes or 
modules.
+      # This cop looks for definitions of top-level methods and warns about 
them.
+      #
+      # However for ruby scripts it is perfectly fine to use top-level methods.
+      # Hence this cop is disabled by default.
+      #
+      # @example
+      #   # bad
+      #   def some_method
+      #   end
+      #
+      #   # bad
+      #   def self.some_method
+      #   end
+      #
+      #   # bad
+      #   define_method(:foo) { puts 1 }
+      #
+      #   # good
+      #   module Foo
+      #     def some_method
+      #     end
+      #   end
+      #
+      #   # good
+      #   class Foo
+      #     def self.some_method
+      #     end
+      #   end
+      #
+      #   # good
+      #   Struct.new do
+      #     def some_method
+      #     end
+      #   end
+      #
+      #   # good
+      #   class Foo
+      #     define_method(:foo) { puts 1 }
+      #   end
+      class TopLevelMethodDefinition < Base
+        MSG = 'Do not define methods at the top-level.'
+
+        RESTRICT_ON_SEND = %i[define_method].freeze
+
+        def on_def(node)
+          return unless node.root?
+
+          add_offense(node)
+        end
+        alias on_defs on_def
+        alias on_send on_def
+
+        def on_block(node)
+          return unless define_method_block?(node) && node.root?
+
+          add_offense(node)
+        end
+
+        private
+
+        # @!method define_method_block?(node)
+        def_node_matcher :define_method_block?, <<~PATTERN
+          (block (send _ {:define_method} _) ...)
+        PATTERN
+      end
+    end
+  end
+end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/rubocop/cop/style/trivial_accessors.rb 
new/lib/rubocop/cop/style/trivial_accessors.rb
--- old/lib/rubocop/cop/style/trivial_accessors.rb      2021-05-05 
09:54:15.000000000 +0200
+++ new/lib/rubocop/cop/style/trivial_accessors.rb      2021-05-17 
09:16:51.000000000 +0200
@@ -27,6 +27,71 @@
       #   class << self
       #     attr_reader :baz
       #   end
+      #
+      # @example ExactNameMatch: true (default)
+      #   # good
+      #   def name
+      #     @other_name
+      #   end
+      #
+      # @example ExactNameMatch: false
+      #   # bad
+      #   def name
+      #     @other_name
+      #   end
+      #
+      # @example AllowPredicates: true (default)
+      #   # good
+      #   def foo?
+      #     @foo
+      #   end
+      #
+      # @example AllowPredicates: false
+      #   # bad
+      #   def foo?
+      #     @foo
+      #   end
+      #
+      #   # good
+      #   attr_reader :foo
+      #
+      # @example AllowDSLWriters: true (default)
+      #   # good
+      #   def on_exception(action)
+      #     @on_exception=action
+      #   end
+      #
+      # @example AllowDSLWriters: false
+      #   # bad
+      #   def on_exception(action)
+      #     @on_exception=action
+      #   end
+      #
+      #   # good
+      #   attr_writer :on_exception
+      #
+      # @example IgnoreClassMethods: false (default)
+      #   # bad
+      #   def self.foo
+      #     @foo
+      #   end
+      #
+      #   # good
+      #   class << self
+      #     attr_reader :foo
+      #   end
+      #
+      # @example IgnoreClassMethods: true
+      #   # good
+      #   def self.foo
+      #     @foo
+      #   end
+      #
+      # @example AllowedMethods: ['allowed_method']
+      #   # good
+      #   def allowed_method
+      #     @foo
+      #   end
       class TrivialAccessors < Base
         include AllowedMethods
         extend AutoCorrector
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/rubocop/formatter/junit_formatter.rb 
new/lib/rubocop/formatter/junit_formatter.rb
--- old/lib/rubocop/formatter/junit_formatter.rb        2021-05-05 
09:54:15.000000000 +0200
+++ new/lib/rubocop/formatter/junit_formatter.rb        2021-05-17 
09:16:51.000000000 +0200
@@ -22,9 +22,13 @@
         testsuites = REXML::Element.new('testsuites', @document)
         testsuite = REXML::Element.new('testsuite', testsuites)
         @testsuite = testsuite.tap { |element| element.add_attributes('name' 
=> 'rubocop') }
+
+        reset_count
       end
 
       def file_finished(file, offenses)
+        @inspected_file_count += 1
+
         # TODO: Returns all cops with the same behavior as
         # the original rubocop-junit-formatter.
         # 
https://github.com/mikian/rubocop-junit-formatter/blob/v0.1.4/lib/rubocop/formatter/junit_formatter.rb#L9
@@ -32,15 +36,11 @@
         # In the future, it would be preferable to return only enabled cops.
         Cop::Registry.all.each do |cop|
           target_offenses = offenses_for_cop(offenses, cop)
+          @offense_count += target_offenses.count
 
           next unless relevant_for_output?(options, target_offenses)
 
-          REXML::Element.new('testcase', @testsuite).tap do |testcase|
-            testcase.attributes['classname'] = classname_attribute_value(file)
-            testcase.attributes['name'] = cop.cop_name
-
-            add_failure_to(testcase, target_offenses, cop.cop_name)
-          end
+          add_testcase_element_to_testsuite_element(file, target_offenses, cop)
         end
       end
 
@@ -52,16 +52,31 @@
         all_offenses.select { |offense| offense.cop_name == cop.cop_name }
       end
 
+      def add_testcase_element_to_testsuite_element(file, target_offenses, cop)
+        REXML::Element.new('testcase', @testsuite).tap do |testcase|
+          testcase.attributes['classname'] = classname_attribute_value(file)
+          testcase.attributes['name'] = cop.cop_name
+
+          add_failure_to(testcase, target_offenses, cop.cop_name)
+        end
+      end
+
       def classname_attribute_value(file)
         file.gsub(/\.rb\Z/, '').gsub("#{Dir.pwd}/", '').tr('/', '.')
       end
 
       def finished(_inspected_files)
+        @testsuite.add_attributes('tests' => @inspected_file_count, 'failures' 
=> @offense_count)
         @document.write(output, 2)
       end
 
       private
 
+      def reset_count
+        @inspected_file_count = 0
+        @offense_count = 0
+      end
+
       def add_failure_to(testcase, offenses, cop_name)
         # One failure per offense. Zero failures is a passing test case,
         # for most surefire/nUnit parsers.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/rubocop/options.rb new/lib/rubocop/options.rb
--- old/lib/rubocop/options.rb  2021-05-05 09:54:15.000000000 +0200
+++ new/lib/rubocop/options.rb  2021-05-17 09:16:51.000000000 +0200
@@ -297,7 +297,7 @@
       validate_auto_gen_config
       validate_auto_correct
       validate_display_only_failed
-      validate_parallel
+      disable_parallel_when_invalid_option_combo
 
       return if incompatible_options.size <= 1
 
@@ -334,33 +334,27 @@
             format('--disable-uncorrectable can only be used together with 
--auto-correct.')
     end
 
-    def validate_parallel
+    def disable_parallel_when_invalid_option_combo
       return unless @options.key?(:parallel)
 
-      if @options[:cache] == 'false'
-        raise OptionArgumentError, '-P/--parallel uses caching to speed up ' \
-                                   'execution, so combining with --cache ' \
-                                   'false is not allowed.'
+      invalid_options = [
+        { name: :auto_gen_config, value: true, flag: '--auto-gen-config' },
+        { name: :fail_fast, value: true, flag: '-F/--fail-fast.' },
+        { name: :auto_correct, value: true, flag: '--auto-correct.' },
+        { name: :cache, value: 'false', flag: '--cache false' }
+      ]
+
+      invalid_flags = invalid_options.each_with_object([]) do |option, flags|
+        # `>` rather than `>=` because `@options` will also contain `parallel: 
true`
+        flags << option[:flag] if @options > { option[:name] => option[:value] 
}
       end
 
-      disable_parallel_when_invalid_combo
-    end
-
-    def disable_parallel_when_invalid_combo
-      combos = {
-        auto_gen_config: '--auto-gen-config',
-        fail_fast: '-F/--fail-fast.',
-        auto_correct: '--auto-correct.'
-      }
-
-      invalid_combos = combos.select { |key, _flag| @options.key?(key) }
-
-      return if invalid_combos.empty?
+      return if invalid_flags.empty?
 
       @options.delete(:parallel)
 
       puts '-P/--parallel is being ignored because ' \
-           "it is not compatible with #{invalid_combos.values.join(', ')}"
+           "it is not compatible with #{invalid_flags.join(', ')}"
     end
 
     def only_includes_redundant_disable?
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/rubocop/version.rb new/lib/rubocop/version.rb
--- old/lib/rubocop/version.rb  2021-05-05 09:54:15.000000000 +0200
+++ new/lib/rubocop/version.rb  2021-05-17 09:16:51.000000000 +0200
@@ -3,7 +3,7 @@
 module RuboCop
   # This module holds the RuboCop version information.
   module Version
-    STRING = '1.14.0'
+    STRING = '1.15.0'
 
     MSG = '%<version>s (using Parser %<parser_version>s, '\
           'rubocop-ast %<rubocop_ast_version>s, ' \
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/rubocop.rb new/lib/rubocop.rb
--- old/lib/rubocop.rb  2021-05-05 09:54:15.000000000 +0200
+++ new/lib/rubocop.rb  2021-05-17 09:16:51.000000000 +0200
@@ -598,6 +598,7 @@
 require_relative 'rubocop/cop/style/symbol_literal'
 require_relative 'rubocop/cop/style/symbol_proc'
 require_relative 'rubocop/cop/style/ternary_parentheses'
+require_relative 'rubocop/cop/style/top_level_method_definition'
 require_relative 'rubocop/cop/style/trailing_body_on_class'
 require_relative 'rubocop/cop/style/trailing_body_on_method_definition'
 require_relative 'rubocop/cop/style/trailing_body_on_module'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/metadata new/metadata
--- old/metadata        2021-05-05 09:54:15.000000000 +0200
+++ new/metadata        2021-05-17 09:16:51.000000000 +0200
@@ -1,7 +1,7 @@
 --- !ruby/object:Gem::Specification
 name: rubocop
 version: !ruby/object:Gem::Version
-  version: 1.14.0
+  version: 1.15.0
 platform: ruby
 authors:
 - Bozhidar Batsov
@@ -10,7 +10,7 @@
 autorequire: 
 bindir: exe
 cert_chain: []
-date: 2021-05-05 00:00:00.000000000 Z
+date: 2021-05-17 00:00:00.000000000 Z
 dependencies:
 - !ruby/object:Gem::Dependency
   name: parallel
@@ -786,6 +786,7 @@
 - lib/rubocop/cop/style/symbol_literal.rb
 - lib/rubocop/cop/style/symbol_proc.rb
 - lib/rubocop/cop/style/ternary_parentheses.rb
+- lib/rubocop/cop/style/top_level_method_definition.rb
 - lib/rubocop/cop/style/trailing_body_on_class.rb
 - lib/rubocop/cop/style/trailing_body_on_method_definition.rb
 - lib/rubocop/cop/style/trailing_body_on_module.rb
@@ -875,7 +876,7 @@
   homepage_uri: https://rubocop.org/
   changelog_uri: https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md
   source_code_uri: https://github.com/rubocop/rubocop/
-  documentation_uri: https://docs.rubocop.org/rubocop/1.14/
+  documentation_uri: https://docs.rubocop.org/rubocop/1.15/
   bug_tracker_uri: https://github.com/rubocop/rubocop/issues
 post_install_message: 
 rdoc_options: []

Reply via email to