diff --git a/.rubocop.yml b/.rubocop.yml index 004a921e4d..6dea6df645 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -142,6 +142,8 @@ Performance/StringIdentifierArgument: # new in 1.13 Enabled: true Performance/StringInclude: # new in 1.7 Enabled: true +Performance/Sum: # new in 1.8 + Enabled: true # Old cops diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 571a646edf..ce86c030a3 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -63,13 +63,6 @@ Minitest/EmptyLineBeforeAssertionMethods: - 'test/new_relic/agent_test.rb' - 'test/new_relic/cli/commands/deployments_test.rb' -# Offense count: 1 -# This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: OnlySumOrWithInitialValue. -Performance/Sum: - Exclude: - - 'lib/new_relic/agent/system_info.rb' - # Offense count: 72 # This cop supports unsafe autocorrection (--autocorrect-all). Performance/UnfreezeString: diff --git a/lib/new_relic/agent/system_info.rb b/lib/new_relic/agent/system_info.rb index 5080ac574a..fe63184dda 100644 --- a/lib/new_relic/agent/system_info.rb +++ b/lib/new_relic/agent/system_info.rb @@ -128,7 +128,7 @@ def self.parse_cpuinfo(cpuinfo) num_physical_packages = cores.keys.map(&:first).uniq.size num_physical_cores = cores.size - num_logical_processors = cores.values.reduce(0, :+) + num_logical_processors = cores.values.sum if num_physical_cores == 0 num_logical_processors = total_processors