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

Remove safe navigation rubocop rule #13347

Merged

Conversation

adfoster-r7
Copy link
Contributor

In certain scenarios it's possible for this Rubocop rule to produce broken Ruby code.

I believe rubocop is only meant to perform this transform for specific methods, but it doesn't appear to work:

  AllowedMethods:
    - present?
    - blank?
    - presence
    - try
    - try!

Let's disable the rule for now, and I've raised an issue with Rubocop

Full context: #13291 (comment)
Rubocop issue: rubocop/rubocop#7914

@adfoster-r7 adfoster-r7 added the code quality Improving code quality label Apr 27, 2020
@gwillcox-r7 gwillcox-r7 self-assigned this Apr 27, 2020
@gwillcox-r7
Copy link
Contributor

Seems to be working as expected:

$ git log
commit 81f0607ac3b1366abfb18081013def12a8352578 (HEAD, upstream/pr/13347)
Author: adfoster-r7 <adfoster-r7@github>
Date:   Mon Apr 27 18:04:33 2020 +0100

    Remove safe navigation rubocop rule

commit fc164e0c098456bcc65d3f2605a0580ff0e2965e (upstream/master, origin/master, origin/HEAD, upstream-master, master)
Author: Metasploit Bot <metasploit@rapid7.com>
Date:   Mon Apr 27 06:16:47 2020 -0500

    automatic module_metadata_base.json update

commit af239303d206ae2fb3c78c55244c662d7c463f1e
Merge: 64c04464e0 090cf259ee
Author: cdelafuente-r7 <cdelafuente-r7@github>
Date:   Mon Apr 27 13:05:38 2020 +0200

    Land #13257, .NET Deserialization Library Improvements

commit 64c04464e0aa9e4bb242232471a63c88106e39c2
Author: Metasploit Bot <metasploit@rapid7.com>
Date:   Sat Apr 25 15:48:58 2020 -0500

    automatic module_metadata_base.json update

$ rubocop -c .rubocop.yml modules/exploits/example_linux_priv_esc.rb 
.rubocop.yml: Metrics/LineLength has the wrong namespace - should be Layout
/*censored*/metasploit-framework/.rubocop.yml: Warning: no department given for Documentation.
Inspecting 1 file
.

1 file inspected, no offenses detected
$ 

Going to go ahead and merge this as rubocop/rubocop#7914 and #13291 (comment) clearly show that several people have tested this issue and confirmed that it is a bug in RuboCop.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code quality Improving code quality rn-no-release-notes no release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants