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

Minor refactors #2392

Merged
merged 2 commits into from
Sep 2, 2024
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
6 changes: 2 additions & 4 deletions sentry-ruby/lib/sentry/attachment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

def initialize(bytes: nil, filename: nil, content_type: nil, path: nil)
@bytes = bytes
@filename = infer_filename(filename, path)
@filename = filename || infer_filename(path)

Check warning on line 11 in sentry-ruby/lib/sentry/attachment.rb

View check run for this annotation

Codecov / codecov/patch

sentry-ruby/lib/sentry/attachment.rb#L11

Added line #L11 was not covered by tests
@path = path
@content_type = content_type
end
Expand All @@ -29,9 +29,7 @@

private

def infer_filename(filename, path)
return filename if filename

def infer_filename(path)
if path
File.basename(path)
else
Expand Down
7 changes: 3 additions & 4 deletions sentry-ruby/lib/sentry/profiler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,12 @@

frame_map = {}

frames = results[:frames].to_enum.with_index.map do |frame, idx|
frame_id, frame_data = frame

frames = results[:frames].map.with_index do |(frame_id, frame_data), idx|

Check warning on line 93 in sentry-ruby/lib/sentry/profiler.rb

View check run for this annotation

Codecov / codecov/patch

sentry-ruby/lib/sentry/profiler.rb#L93

Added line #L93 was not covered by tests
# need to map over stackprof frame ids to ours
frame_map[frame_id] = idx

file_path = frame_data[:file]
lineno = frame_data[:line]

Check warning on line 98 in sentry-ruby/lib/sentry/profiler.rb

View check run for this annotation

Codecov / codecov/patch

sentry-ruby/lib/sentry/profiler.rb#L98

Added line #L98 was not covered by tests
in_app = in_app?(file_path)
filename = compute_filename(file_path, in_app)
function, mod = split_module(frame_data[:name])
Expand All @@ -109,7 +108,7 @@
}

frame_hash[:module] = mod if mod
frame_hash[:lineno] = frame_data[:line] if frame_data[:line] && frame_data[:line] >= 0
frame_hash[:lineno] = lineno if lineno && lineno >= 0

Check warning on line 111 in sentry-ruby/lib/sentry/profiler.rb

View check run for this annotation

Codecov / codecov/patch

sentry-ruby/lib/sentry/profiler.rb#L111

Added line #L111 was not covered by tests

frame_hash
end
Expand Down
Loading