[Rubocop] Performance Cop Offenses (#1209)

This commit is contained in:
Hunter Braun 2018-10-04 20:07:56 -05:00 committed by Daniel Colson
parent cbe242c942
commit 95bd3c6076
3 changed files with 4 additions and 17 deletions

View File

@ -1,6 +1,7 @@
inherit_from:
- https://raw.githubusercontent.com/thoughtbot/guides/master/style/ruby/.rubocop.yml
AllCops:
TargetRubyVersion: 2.3
Exclude:
- 'gemfiles/*'
- 'tmp/**/*'
@ -80,20 +81,6 @@ Naming/MemoizedInstanceVariableName:
Exclude:
- 'spec/support/macros/define_constant.rb'
# Offense count: 1
# Cop supports --auto-correct.
Performance/RegexpMatch:
Exclude:
- 'lib/factory_bot/aliases.rb'
# Offense count: 3
# Cop supports --auto-correct.
# Configuration parameters: AutoCorrect.
Performance/TimesMap:
Exclude:
- 'lib/factory_bot/strategy_syntax_method_registrar.rb'
- 'spec/acceptance/initialize_with_spec.rb'
# Offense count: 3
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, ProceduralMethods, FunctionalMethods, IgnoredMethods.

View File

@ -29,7 +29,7 @@ module FactoryBot
raise ArgumentError, "count missing for #{strategy_name}_list"
end
amount.times.map { send(strategy_name, name, *traits_and_overrides, &block) }
Array.new(amount) { send(strategy_name, name, *traits_and_overrides, &block) }
end
end
@ -37,7 +37,7 @@ module FactoryBot
strategy_name = @strategy_name
define_syntax_method("#{strategy_name}_pair") do |name, *traits_and_overrides, &block|
2.times.map { send(strategy_name, name, *traits_and_overrides, &block) }
Array.new(2) { send(strategy_name, name, *traits_and_overrides, &block) }
end
end

View File

@ -59,7 +59,7 @@ describe "initialize_with non-ORM-backed objects" do
end
FactoryBot.define do
sequence(:random_data) { 5.times.map { Kernel.rand(200) } }
sequence(:random_data) { Array.new(5) { Kernel.rand(200) } }
factory :report_generator do
transient do