-
Notifications
You must be signed in to change notification settings - Fork 375
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
[NO-TICKET] Profiling: Minor cleanup to error messages #3979
Conversation
In Ruby 3.4, the printing of arrays is being slightly tweaked, and so our tests started failing. Regardless of that change sticking or being reverted (it does seem like it could cause a bit of annoyance across the ecosystem), I've decided to simplify a bit our code to provide our own printing rather than rely on the Ruby defaults, and thus work everywhere. Also I decided to remove the specs for `HttpTransport#config_without_api_key` since it's only used internally for error printing (which did not use to be the case!).
@@ -139,7 +139,7 @@ def do_export( | |||
end | |||
|
|||
def config_without_api_key | |||
[exporter_configuration[0..1]].to_h | |||
"#{exporter_configuration[0]}: #{exporter_configuration[1]}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
⚪ Code Quality Violation
"#{exporter_configuration[0]}: #{exporter_configuration[1]}" | |
"#{exporter_configuration.first}: #{exporter_configuration[1]}" |
Improve readability with first (...read more)
This rule encourages the use of first
and last
methods over array indexing to access the first and last elements of an array, respectively. The primary reason behind this rule is to improve code readability. Using first
and last
makes it immediately clear that you are accessing the first or last element of the array, which might not be immediately obvious with array indexing, especially for developers who are new to Ruby.
The use of these methods also helps to make your code more idiomatic, which is a crucial aspect of writing effective Ruby code. Idiomatic code is easier to read, understand, and maintain. It also tends to be more efficient, as idioms often reflect patterns that are optimized for the language.
To adhere to this rule, replace the use of array indexing with first
or last
methods when you want to access the first and last elements of an array. For instance, instead of arr[0]
use arr.first
and instead of arr[-1]
use arr.last
. However, note that this rule should be applied only when reading values. When modifying the first or last elements, array indexing should still be used. For example, arr[0] = 'new_value'
and arr[-1] = 'new_value'
.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #3979 +/- ##
=======================================
Coverage 97.86% 97.87%
=======================================
Files 1313 1313
Lines 78369 78356 -13
Branches 3888 3888
=======================================
- Hits 76695 76688 -7
+ Misses 1674 1668 -6 ☔ View full report in Codecov by Sentry. |
BenchmarksBenchmark execution time: 2024-10-07 15:11:38 Comparing candidate commit dcf347e in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 23 metrics, 2 unstable metrics. |
What does this PR do?
This PR does a very small refactoring to the tests and code in the profiler to print errors when talking to the backend.
Motivation:
In Ruby 3.4, the printing of arrays is being slightly tweaked, and so our tests started failing.
Regardless of that change sticking or being reverted (it does seem like it could cause a bit of annoyance across the ecosystem), I've decided to simplify a bit our code to provide our own printing rather than rely on the Ruby defaults, and thus work everywhere.
Also I decided to remove the specs for
HttpTransport#config_without_api_key
since it's only used internally for error printing (which did not use to be the case!).Additional Notes:
There's a few more things not working on Ruby head due to changes in rubygems/bundler, but I'll handle those separately.
How to test the change?
This change includes test coverage.