Skip to content

Commit a543f0a

Browse files
committed
Enable rubocop-performance plugin
1 parent 295cfec commit a543f0a

File tree

6 files changed

+10
-6
lines changed

6 files changed

+10
-6
lines changed

.rubocop.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
plugins:
2+
- rubocop-performance
3+
14
AllCops:
25
TargetRubyVersion: '3.2'
36
NewCops: enable

lib/minfraud/components/email.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def clean_email_address(address)
9999
end
100100

101101
if domain == 'gmail.com'
102-
local_part.gsub!('.', '')
102+
local_part.delete!('.')
103103
end
104104

105105
domain_parts = domain.split('.')

lib/minfraud/components/report/transaction.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def validate
103103
end
104104

105105
def empty_uuid?(value)
106-
stripped_value = value.to_s.gsub('-', '')
106+
stripped_value = value.to_s.delete('-')
107107
stripped_value == '0' * 32
108108
end
109109
end

lib/minfraud/components/shopping_cart.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class ShoppingCart < Base
1717
# to an item's field, or as a Minfraud:::Components::ShoppingCartItem
1818
# object.
1919
def initialize(params = [])
20-
@items = params.map(&method(:resolve))
20+
@items = params.map { |param| resolve(param) }
2121
end
2222

2323
# A JSON representation of Minfraud::Components::ShoppingCart items.

lib/minfraud/validates.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def validate_md5(field, value)
2727
def validate_uuid(field, value)
2828
return if !value
2929

30-
stripped_value = value.to_s.gsub('-', '')
30+
stripped_value = value.to_s.delete('-')
3131

3232
# Define a regex pattern for a valid UUID without dashes
3333
uuid_regex = /\A[0-9a-f]{32}\z/i
@@ -78,7 +78,7 @@ def validate_credit_card_token(field, value)
7878
raise InvalidInputError, "The #{field} value is not valid. It must contain only non-space printable ASCII characters."
7979
end
8080

81-
if /\A[0-9]{1,19}\z/.match(s)
81+
if /\A[0-9]{1,19}\z/.match?(s)
8282
raise InvalidInputError, "The #{field} value is not valid. If it is all digits, it must be longer than 19 characters."
8383
end
8484
end
@@ -147,7 +147,7 @@ def validate_nonnegative_integer(field, value)
147147
def validate_email(field, value)
148148
return if !value
149149

150-
if /.@./.match(value)
150+
if /.@./.match?(value)
151151
validate_string(field, 255, value)
152152
return
153153
end

minfraud.gemspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ Gem::Specification.new do |spec|
3131
spec.add_development_dependency 'rake', '~> 13.0'
3232
spec.add_development_dependency 'rspec', '~> 3.0'
3333
spec.add_development_dependency 'rubocop', '~> 1.23'
34+
spec.add_development_dependency 'rubocop-performance'
3435
spec.add_development_dependency 'webmock', '~> 3.14'
3536
spec.metadata = {
3637
'rubygems_mfa_required' => 'true'

0 commit comments

Comments
 (0)