Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add rubocop performance extension #911

Merged
merged 2 commits into from
Nov 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
132 changes: 132 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require: rubocop-performance

AllCops:
Exclude:
- 'vendor/**/*'
Expand Down Expand Up @@ -66,3 +68,133 @@ Style/FrozenStringLiteralComment:
# If we do this, it will be in its own PR. It requires adding these magic comments
# throughout the project, in order to prepare for a future Ruby 3.x.
Enabled: false

#
# Performance cops are opt in, and `Enabled: true` is always required.
# Full list is here: https://github.com/rubocop-hq/rubocop-performance/tree/master/lib/rubocop/cop/performance
# For travis builds, Codacy will see and use these directives.
#
Performance/Caller:
Enabled: true
Exclude:
- spec/**/*

Performance/CaseWhenSplat:
Enabled: true
Exclude:
- spec/**/*

Performance/Casecmp:
Enabled: true
Exclude:
- spec/**/*

Performance/ChainArrayAllocation:
Enabled: true
Exclude:
- spec/**/*

Performance/CompareWithBlock:
Enabled: true
Exclude:
- spec/**/*

Performance/Count:
Enabled: true
Exclude:
- spec/**/*

Performance/Detect:
Enabled: true
Exclude:
- spec/**/*

Performance/DoubleStartEndWith:
Enabled: true
Exclude:
- spec/**/*

Performance/EndWith:
Enabled: true
Exclude:
- spec/**/*

Performance/FixedSize:
Enabled: true
Exclude:
- spec/**/*

Performance/FlatMap:
Enabled: true
Exclude:
- spec/**/*

Performance/InefficientHashSearch:
Enabled: true
Exclude:
- spec/**/*

Performance/OpenStruct:
Enabled: true
Exclude:
- spec/**/*

Performance/RangeInclude:
Enabled: true
Exclude:
- spec/**/*

Performance/RedundantBlockCall:
Enabled: true
Exclude:
- spec/**/*

Performance/RedundantMatch:
Enabled: true
Exclude:
- spec/**/*

Performance/RedundantMerge:
Enabled: true
Exclude:
- spec/**/*

Performance/RegexpMatch:
Enabled: true
Exclude:
- spec/**/*

Performance/ReverseEach:
Enabled: true
Exclude:
- spec/**/*

Performance/Size:
Enabled: true
Exclude:
- spec/**/*

Performance/StartWith:
Enabled: true
Exclude:
- spec/**/*

Performance/StringReplacement:
Enabled: true
Exclude:
- spec/**/*

Performance/TimesMap:
Enabled: true
Exclude:
- spec/**/*

Performance/UnfreezeString:
Enabled: true
Exclude:
- spec/**/*

Performance/UriDefaultParser:
Enabled: true
Exclude:
- spec/**/*
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ gem 'girl_friday', '>= 0.11.1'
gem 'redis'
gem 'resque', '< 2.0.0'
gem 'rubocop', :require => false
gem 'rubocop-performance', :require => false
gem 'sinatra'
gem 'webmock', :require => false
gemspec
5 changes: 4 additions & 1 deletion lib/rollbar/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,10 @@ def project_gems=(gems)
found = Gem::Specification.each.select { |spec| name === spec.name }
puts "[Rollbar] No gems found matching #{name.inspect}" if found.empty?
found
end.flatten.uniq.map(&:gem_dir)
end
@project_gem_paths.flatten!
@project_gem_paths.uniq!
@project_gem_paths.map!(&:gem_dir)
end

def before_process=(*handler)
Expand Down
5 changes: 3 additions & 2 deletions lib/rollbar/item/backtrace.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,11 @@ def trace_data(current_exception)
end

def map_frames(current_exception)
exception_backtrace(current_exception).map do |frame|
frames = exception_backtrace(current_exception).map do |frame|
Rollbar::Item::Frame.new(self, frame,
:configuration => configuration).to_h
end.reverse
end
frames.reverse!
end

# Returns the backtrace to be sent to our API. There are 3 options:
Expand Down