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
ShadowedException
cop cause warning: constant ::TimeoutError is deprecated
#6675
Comments
Thank you for reporting issue! https://github.com/rubocop-hq/rubocop/blob/7abc4badefca71f5fd9cb3f9b0e8e0f78801a51e/lib/rubocop/cop/lint/shadowed_exception.rb#L115 require 'timeout'
p TimeoutError # => warning: constant ::TimeoutError is deprecated I'm not sure we avoid this warning, If we supress the warning, we need a comment why it is supressed. |
By the way, we can add a cop like I think it is the best way if MRI's warning includes "Use Timeout::Error instead.". |
@pocke Yeah, I fought that adding cop about this exact message is best solution for this situation |
It really is a shame that Ruby's message only gives the deprecation and does not supply the replacement.
silence_warnings do
# Avoid printing deprecation warnings about constants
converted << Kernel.const_get(exception)
end This would prevent the warning from showing up when RuboCop runs. I think it would make sense for us to silence the warning since the deprecation warning doesn't have anything to do with the RuboCop code itself. |
Indeed. Found another case of this recently. 🙁
I agree. |
Hey, I just opened a PR with the changes required in order to avoid showing deprecation warnings about constants.
I agree with this, and I'm not sure if the feature described by @pocke is really needed, but if it is, maybe should be done in a differente branch. |
I'm not 100% sure this is an issue, but I don't think this is correct behaviour
Steps to reproduce the problem
test.rb
file withrubocop test.rb
Expected behavior
Some cop should warn me about deprecation of TimeoutError
Actual behavior
RuboCop version
The text was updated successfully, but these errors were encountered: