rubocop 1.50.2 → 1.51.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +3 -3
  3. data/config/default.yml +18 -3
  4. data/lib/rubocop/config.rb +4 -0
  5. data/lib/rubocop/config_obsoletion.rb +2 -2
  6. data/lib/rubocop/cop/base.rb +4 -0
  7. data/lib/rubocop/cop/correctors/alignment_corrector.rb +1 -1
  8. data/lib/rubocop/cop/gemspec/development_dependencies.rb +1 -1
  9. data/lib/rubocop/cop/internal_affairs/node_matcher_directive.rb +2 -2
  10. data/lib/rubocop/cop/layout/heredoc_argument_closing_parenthesis.rb +2 -2
  11. data/lib/rubocop/cop/layout/space_inside_block_braces.rb +2 -0
  12. data/lib/rubocop/cop/lint/ambiguous_block_association.rb +12 -1
  13. data/lib/rubocop/cop/lint/erb_new_arguments.rb +2 -2
  14. data/lib/rubocop/cop/lint/incompatible_io_select_with_fiber_scheduler.rb +5 -2
  15. data/lib/rubocop/cop/lint/lambda_without_literal_block.rb +1 -1
  16. data/lib/rubocop/cop/lint/numbered_parameter_assignment.rb +2 -2
  17. data/lib/rubocop/cop/lint/out_of_range_regexp_ref.rb +2 -2
  18. data/lib/rubocop/cop/lint/redundant_string_coercion.rb +1 -1
  19. data/lib/rubocop/cop/lint/top_level_return_with_argument.rb +23 -9
  20. data/lib/rubocop/cop/lint/useless_assignment.rb +56 -1
  21. data/lib/rubocop/cop/lint/void.rb +62 -6
  22. data/lib/rubocop/cop/mixin/comments_help.rb +6 -2
  23. data/lib/rubocop/cop/mixin/space_after_punctuation.rb +1 -1
  24. data/lib/rubocop/cop/naming/constant_name.rb +1 -1
  25. data/lib/rubocop/cop/naming/memoized_instance_variable_name.rb +22 -7
  26. data/lib/rubocop/cop/naming/rescued_exceptions_variable_name.rb +11 -3
  27. data/lib/rubocop/cop/style/attr.rb +11 -1
  28. data/lib/rubocop/cop/style/collection_compact.rb +10 -6
  29. data/lib/rubocop/cop/style/colon_method_call.rb +2 -2
  30. data/lib/rubocop/cop/style/combinable_loops.rb +26 -6
  31. data/lib/rubocop/cop/style/conditional_assignment.rb +2 -2
  32. data/lib/rubocop/cop/style/copyright.rb +5 -2
  33. data/lib/rubocop/cop/style/documentation.rb +1 -1
  34. data/lib/rubocop/cop/style/eval_with_location.rb +1 -1
  35. data/lib/rubocop/cop/style/exact_regexp_match.rb +62 -0
  36. data/lib/rubocop/cop/style/guard_clause.rb +2 -0
  37. data/lib/rubocop/cop/style/hash_except.rb +19 -8
  38. data/lib/rubocop/cop/style/if_inside_else.rb +6 -0
  39. data/lib/rubocop/cop/style/if_unless_modifier.rb +3 -0
  40. data/lib/rubocop/cop/style/invertible_unless_condition.rb +9 -5
  41. data/lib/rubocop/cop/style/percent_literal_delimiters.rb +1 -1
  42. data/lib/rubocop/cop/style/redundant_line_continuation.rb +5 -1
  43. data/lib/rubocop/cop/style/regexp_literal.rb +11 -2
  44. data/lib/rubocop/cop/style/require_order.rb +9 -4
  45. data/lib/rubocop/cop/style/semicolon.rb +12 -1
  46. data/lib/rubocop/cop/style/special_global_vars.rb +2 -2
  47. data/lib/rubocop/cop/team.rb +1 -1
  48. data/lib/rubocop/cop/variable_force/assignment.rb +4 -0
  49. data/lib/rubocop/cop/variable_force/variable_table.rb +2 -2
  50. data/lib/rubocop/result_cache.rb +1 -1
  51. data/lib/rubocop/rspec/cop_helper.rb +1 -1
  52. data/lib/rubocop/target_ruby.rb +3 -2
  53. data/lib/rubocop/version.rb +3 -3
  54. data/lib/rubocop.rb +1 -0
  55. metadata +5 -4
@@ -113,14 +113,14 @@ module RuboCop
113
113
  def accessible_variables
114
114
  scope_stack.reverse_each.with_object([]) do |scope, variables|
115
115
  variables.concat(scope.variables.values)
116
- break variables unless scope.node.block_type?
116
+ break variables unless scope.node.block_type? || scope.node.numblock_type?
117
117
  end
118
118
  end
119
119
 
120
120
  private
121
121
 
122
122
  def mark_variable_as_captured_by_block_if_so(variable)
123
- return unless current_scope.node.block_type?
123
+ return unless current_scope.node.block_type? || current_scope.node.numblock_type?
124
124
  return if variable.scope == current_scope
125
125
 
126
126
  variable.capture_with_block!
@@ -83,7 +83,7 @@ module RuboCop
83
83
  config_store.for_pwd.for_all_cops['AllowSymlinksInCacheRootDirectory']
84
84
  end
85
85
 
86
- attr :path
86
+ attr_reader :path
87
87
 
88
88
  def initialize(file, team, options, config_store, cache_root = nil)
89
89
  cache_root ||= File.join(options[:cache_root], 'rubocop_cache') if options[:cache_root]
@@ -6,7 +6,7 @@ require 'tempfile'
6
6
  module CopHelper
7
7
  extend RSpec::SharedContext
8
8
 
9
- let(:ruby_version) { 2.6 }
9
+ let(:ruby_version) { RuboCop::TargetRuby::DEFAULT_VERSION }
10
10
  let(:rails_version) { false }
11
11
 
12
12
  def inspect_source(source, file = nil)
@@ -5,7 +5,7 @@ module RuboCop
5
5
  # @api private
6
6
  class TargetRuby
7
7
  KNOWN_RUBIES = [2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 3.0, 3.1, 3.2, 3.3].freeze
8
- DEFAULT_VERSION = 2.6
8
+ DEFAULT_VERSION = 2.7
9
9
 
10
10
  OBSOLETE_RUBIES = {
11
11
  1.9 => '0.41',
@@ -14,7 +14,8 @@ module RuboCop
14
14
  2.2 => '0.68',
15
15
  2.3 => '0.81',
16
16
  2.4 => '1.12',
17
- 2.5 => '1.28'
17
+ 2.5 => '1.28',
18
+ 2.6 => '1.50'
18
19
  }.freeze
19
20
  private_constant :KNOWN_RUBIES, :OBSOLETE_RUBIES
20
21
 
@@ -3,7 +3,7 @@
3
3
  module RuboCop
4
4
  # This module holds the RuboCop version information.
5
5
  module Version
6
- STRING = '1.50.2'
6
+ STRING = '1.51.0'
7
7
 
8
8
  MSG = '%<version>s (using Parser %<parser_version>s, ' \
9
9
  'rubocop-ast %<rubocop_ast_version>s, ' \
@@ -43,7 +43,7 @@ module RuboCop
43
43
  env.config_store.unvalidated.for_pwd.loaded_features.sort
44
44
  end
45
45
 
46
- features.map do |loaded_feature|
46
+ features.filter_map do |loaded_feature|
47
47
  next unless (match = loaded_feature.match(/rubocop-(?<feature>.*)/))
48
48
 
49
49
  # Get the expected name of the folder containing the extension code.
@@ -61,7 +61,7 @@ module RuboCop
61
61
  next unless (feature_version = feature_version(feature))
62
62
 
63
63
  " - #{loaded_feature} #{feature_version}"
64
- end.compact
64
+ end
65
65
  end
66
66
 
67
67
  # Returns feature version in one of two ways:
data/lib/rubocop.rb CHANGED
@@ -507,6 +507,7 @@ require_relative 'rubocop/cop/style/end_block'
507
507
  require_relative 'rubocop/cop/style/env_home'
508
508
  require_relative 'rubocop/cop/style/eval_with_location'
509
509
  require_relative 'rubocop/cop/style/even_odd'
510
+ require_relative 'rubocop/cop/style/exact_regexp_match'
510
511
  require_relative 'rubocop/cop/style/expand_path_arguments'
511
512
  require_relative 'rubocop/cop/style/explicit_block_argument'
512
513
  require_relative 'rubocop/cop/style/exponential_notation'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.50.2
4
+ version: 1.51.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bozhidar Batsov
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2023-04-17 00:00:00.000000000 Z
13
+ date: 2023-05-13 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: json
@@ -710,6 +710,7 @@ files:
710
710
  - lib/rubocop/cop/style/env_home.rb
711
711
  - lib/rubocop/cop/style/eval_with_location.rb
712
712
  - lib/rubocop/cop/style/even_odd.rb
713
+ - lib/rubocop/cop/style/exact_regexp_match.rb
713
714
  - lib/rubocop/cop/style/expand_path_arguments.rb
714
715
  - lib/rubocop/cop/style/explicit_block_argument.rb
715
716
  - lib/rubocop/cop/style/exponential_notation.rb
@@ -991,7 +992,7 @@ metadata:
991
992
  homepage_uri: https://rubocop.org/
992
993
  changelog_uri: https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md
993
994
  source_code_uri: https://github.com/rubocop/rubocop/
994
- documentation_uri: https://docs.rubocop.org/rubocop/1.50/
995
+ documentation_uri: https://docs.rubocop.org/rubocop/1.51/
995
996
  bug_tracker_uri: https://github.com/rubocop/rubocop/issues
996
997
  rubygems_mfa_required: 'true'
997
998
  post_install_message:
@@ -1002,7 +1003,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
1002
1003
  requirements:
1003
1004
  - - ">="
1004
1005
  - !ruby/object:Gem::Version
1005
- version: 2.6.0
1006
+ version: 2.7.0
1006
1007
  required_rubygems_version: !ruby/object:Gem::Requirement
1007
1008
  requirements:
1008
1009
  - - ">="