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
Autocorrect of Lint/DeprecatedOpenSSLConstant breaks code #8012
Labels
Comments
Can you show me the original code before auto-correction? |
Sure Paperclip.interpolates :class do |attachment, _style|
attachment.instance.class.to_s.split('::').last.underscore
end
# The security team complained, that the URL of (private) events would be
# guessable. To make this harder be added a hash to the path. In order to not
# migrate all existing files we need to distinguish between old and new
# images/documents. Adding a flag would be the more elegant way, but we have
# many models with assets so the more simple solution is the time bomb.
Paperclip.interpolates :xing_id_partition do |attachment, style|
id = attachment.instance.id || 0
if attachment.instance.updated_at > Time.zone.parse('2019-08-23 00:00')
# inspired by https://github.com/thoughtbot/paperclip/blob/90f9121a18df25bc3ef948356450ce19fbe1da83/lib/paperclip/attachment.rb#L325
data = %i[class id].map { |method| attachment.instance.send(method) }.push(style).join('/')
hash = OpenSSL::HMAC.hexdigest(OpenSSL::Digest::SHA1.new, Rails.application.secrets.secret_key_base, data)
end
format("%03x", id)[-3..].split('').push(id).push(hash).compact.join('/')
end |
koic
added a commit
to koic/rubocop
that referenced
this issue
May 22, 2020
…SSLConstant` Fixes rubocop#8012. This PR fixes an incorrect autocorrect for `Lint/DeprecatedOpenSSLConstant` when deprecated OpenSSL constant is used in a block.
8 tasks
I've opened #8014. Thank you! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When running
rubocop -a --only=Lint/DeprecatedOpenSSLConstant
its breaking the code.Output:
Broken Changes:
Expected behavior
Should only correct change, not other places.
Actual behavior
Correcting changes, but also breaking code.
Steps to reproduce the problem
rubocop -a --only=Lint/DeprecatedOpenSSLConstant
RuboCop version
0.84.0 (using Parser 2.7.1.2, rubocop-ast 0.0.3, running on ruby 2.7.1 x86_64-darwin19)
The text was updated successfully, but these errors were encountered: