Modify or to || and Exception to RuntimeError #3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
1. Altered or with ||
Given this line:
We want to give higher precedence to
error_info['status'] != 'error'
and revert to check fornot error_info['name']
if and only if the first check fails. This will help improve the speed of our program as well!2. Altered Exception to RuntimeError
Given the code snippet:
Lint/RescueException looks for misuse of Exception in a rescue statement, and dutifully suggests to rescue from StandardError which is Ruby's default for rescue. Since there is a high chance a similar mistake when declaring an exception class is being made, the suggested fix may lead to the exception never being caught.
As an example, picture someone following Rubocop's advice and fixes this:
into this:
when he should have been doing this instead:
As a consequence it is quite interesting to lint for custom exceptions that may mistakenly inherit from Exception instead of either StandardError or RuntimeError, the latter being preferred since it's the default for fail/raise (perusing the symmetry with rescue being prodded into Ruby's default behaviour).
Expected behavior:
Conclusion:
Avoid inheriting from the Exception class. Perhaps you meant to inherit from RuntimeError