rubocop-performance 1.15.2 → 1.16.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ab8b6af1dd52db3d8f00efc6428d397474a9c06b9d950b2aa7afa29b2d7feb8e
4
- data.tar.gz: 80102c530b212f682d6e48d1eff740446821a37757b2a94726669f41fd6a6978
3
+ metadata.gz: 7b0361feae763e4c8cbea3bd0160a1e4b0646b2e3b3246fb8dd55a5f21a53acd
4
+ data.tar.gz: 152d09678555d309441fb809f60b07b69b04289b3949bf1eaca3e9b70b3afe13
5
5
  SHA512:
6
- metadata.gz: 36f622e84aec25aae177cbfee56b9c530c6843cbc547e960947d21ab46cc8df87774aa717b3daa75a41a823ef7c8836c7b6acd0c0f45415fc4b216a6901ef617
7
- data.tar.gz: c46677e2f07fbd77f24690218b377b308299a8558c664cf21e75009a011638da6aaece36e89ba2c2b42b003ba310233d20bcac6fed5d1ae7d1f5d3f48ada47e0
6
+ metadata.gz: 9f08bd2f25c0e0e537bf8fa5378e701d6b6b6794a45fe534229e73a0dd4bd623dd415965966655a802cc8e93a3776880d99c89245947aae090ba2c49f0bb183f
7
+ data.tar.gz: 34f697ee70070d32d17b3684712cec5628e71cbdb393722fec3bb0dbc541cf65af92a762907dbbb0c5e6c3023f8dd4738e06a131a5a28014749dac440e15bc92
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2012-22 Bozhidar Batsov
1
+ Copyright (c) 2012-23 Bozhidar Batsov
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
@@ -33,7 +33,7 @@ module RuboCop
33
33
  RETURNS_NEW_ARRAY_WHEN_NO_BLOCK = %i[zip product].to_set.freeze
34
34
 
35
35
  # These methods ALWAYS return a new array
36
- # after they're called it's safe to mutate the the resulting array
36
+ # after they're called it's safe to mutate the resulting array
37
37
  ALWAYS_RETURNS_NEW_ARRAY = %i[* + - collect compact drop
38
38
  drop_while flatten map reject
39
39
  reverse rotate select shuffle sort
@@ -8,9 +8,12 @@ module RuboCop
8
8
  # `detect` instead.
9
9
  #
10
10
  # @safety
11
- # This cop is unsafe because is has known compatibility issues with `ActiveRecord` and other
12
- # frameworks. `ActiveRecord` does not implement a `detect` method and `find` has its own
13
- # meaning. Correcting `ActiveRecord` methods with this cop should be considered unsafe.
11
+ # This cop is unsafe because is assumes the class implements the
12
+ # `Enumerable` interface, but can't reliably detect this. This creates
13
+ # known compatibility issues with `Hash`, `ActiveRecord` and other
14
+ # frameworks. `Hash` and `ActiveRecord` do not implement a `detect`
15
+ # method and `find` has its own meaning. Correcting `Hash` and
16
+ # `ActiveRecord` methods with this cop should be considered unsafe.
14
17
  #
15
18
  # @example
16
19
  # # bad
@@ -28,6 +28,7 @@ module RuboCop
28
28
  # hash[:a] = 1
29
29
  # hash[:b] = 2
30
30
  class RedundantMerge < Base
31
+ include Alignment
31
32
  extend AutoCorrector
32
33
 
33
34
  AREF_ASGN = '%<receiver>s[%<key>s] = %<value>s'
@@ -129,7 +130,7 @@ module RuboCop
129
130
  end
130
131
 
131
132
  def rewrite_with_modifier(node, parent, new_source)
132
- indent = ' ' * indent_width
133
+ indent = ' ' * configured_indentation_width
133
134
  padding = "\n#{indent + leading_spaces(node)}"
134
135
  new_source.gsub!(/\n/, padding)
135
136
 
@@ -144,10 +145,6 @@ module RuboCop
144
145
  node.source_range.source_line[/\A\s*/]
145
146
  end
146
147
 
147
- def indent_width
148
- @config.for_cop('Layout/IndentationWidth')['Width'] || 2
149
- end
150
-
151
148
  def max_key_value_pairs
152
149
  Integer(cop_config['MaxKeyValuePairs'] || 2)
153
150
  end
@@ -6,19 +6,19 @@ module RuboCop
6
6
  # Identifies unnecessary use of a regex where `String#include?` would suffice.
7
7
  #
8
8
  # @safety
9
- # This cop's offenses are not safe to autocorrect if a receiver is nil.
9
+ # This cop's offenses are not safe to autocorrect if a receiver is nil or a Symbol.
10
10
  #
11
11
  # @example
12
12
  # # bad
13
- # 'abc'.match?(/ab/)
14
- # /ab/.match?('abc')
15
- # 'abc' =~ /ab/
16
- # /ab/ =~ 'abc'
17
- # 'abc'.match(/ab/)
18
- # /ab/.match('abc')
13
+ # str.match?(/ab/)
14
+ # /ab/.match?(str)
15
+ # str =~ /ab/
16
+ # /ab/ =~ str
17
+ # str.match(/ab/)
18
+ # /ab/.match(str)
19
19
  #
20
20
  # # good
21
- # 'abc'.include?('ab')
21
+ # str.include?('ab')
22
22
  class StringInclude < Base
23
23
  extend AutoCorrector
24
24
 
@@ -27,7 +27,7 @@ module RuboCop
27
27
 
28
28
  def_node_matcher :redundant_regex?, <<~PATTERN
29
29
  {(send $!nil? {:match :=~ :!~ :match?} (regexp (str $#literal?) (regopt)))
30
- (send (regexp (str $#literal?) (regopt)) {:match :match?} $str)
30
+ (send (regexp (str $#literal?) (regopt)) {:match :match?} $_)
31
31
  (match-with-lvasgn (regexp (str $#literal?) (regopt)) $_)}
32
32
  PATTERN
33
33
 
@@ -4,7 +4,7 @@ module RuboCop
4
4
  module Performance
5
5
  # This module holds the RuboCop Performance version information.
6
6
  module Version
7
- STRING = '1.15.2'
7
+ STRING = '1.16.0'
8
8
 
9
9
  def self.document_version
10
10
  STRING.match('\d+\.\d+').to_s
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop-performance
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.15.2
4
+ version: 1.16.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bozhidar Batsov
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2022-12-25 00:00:00.000000000 Z
13
+ date: 2023-02-06 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rubocop
@@ -123,7 +123,7 @@ metadata:
123
123
  homepage_uri: https://docs.rubocop.org/rubocop-performance/
124
124
  changelog_uri: https://github.com/rubocop/rubocop-performance/blob/master/CHANGELOG.md
125
125
  source_code_uri: https://github.com/rubocop/rubocop-performance/
126
- documentation_uri: https://docs.rubocop.org/rubocop-performance/1.15/
126
+ documentation_uri: https://docs.rubocop.org/rubocop-performance/1.16/
127
127
  bug_tracker_uri: https://github.com/rubocop/rubocop-performance/issues
128
128
  rubygems_mfa_required: 'true'
129
129
  post_install_message:
@@ -141,7 +141,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
141
141
  - !ruby/object:Gem::Version
142
142
  version: '0'
143
143
  requirements: []
144
- rubygems_version: 3.4.0.dev
144
+ rubygems_version: 3.3.26
145
145
  signing_key:
146
146
  specification_version: 4
147
147
  summary: Automatic performance checking tool for Ruby code.