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

RuboCop taking issue with old source #339

Closed
smalleel opened this issue Aug 23, 2016 · 3 comments
Closed

RuboCop taking issue with old source #339

smalleel opened this issue Aug 23, 2016 · 3 comments

Comments

@smalleel
Copy link

The latest version of RuboCop seems to be getting caught on a few issues on most of the recent pull requests that aren't related to the commits in the pull requests. Here's one of the common complaints from RuboCop:

Offenses:

bin/t:21:1: W: Do not shadow rescued Exceptions
rescue Interrupt ...
^^^^^^^^^^^^^^^^
lib/t/identicon.rb:33:7: C: Use bit.zero? instead of bit == 0.
      bit == 0 ? "\033[48;5;#{@bcolor}m" : "\033[48;5;#{@fcolor}m"
      ^^^^^^^^
lib/t/printable.rb:139:7: C: Use concat instead of push(*).
      lines.push(*Array.new([3 - lines.length, 0].max) { '' })
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/t/rcfile.rb:23:60: C: Use empty? instead of size < 1.
        raise(ArgumentError.new("Username #{username} is #{possibilities.size < 1 ? 'not found.' : 'ambiguous, matching ' + possibilities.join(', ')}"))
                                                           ^^^^^^^^^^^^^^^^^^^^^^
lib/t/rcfile.rb:121:64: C: Use 0o for octal literals.
      File.open(@path, File::RDWR | File::TRUNC | File::CREAT, 0600) do |rcfile|
                                                               ^^^^

33 files inspected, 5 offenses detected
RuboCop failed!

This seems to be happening with a bunch of recent pull requests including:
#335
#320
#322
#338

I was able to reproduce there complaints from RuboCop with an unmodified clone of the most current release as well.

Was RuboCop updated at some point and is now upset with some pre-existing items in the source? I see that in the gemfile on line 17 is specifies any version >= 0.37. If the issue is with RuboCop becoming more stringent, should we address these issues? Alternatively, we could specify a version of RuboCop that's old enough not to care about these issues, but that seems like bad practice.

@groddeck
Copy link
Contributor

groddeck commented Sep 3, 2016

This is due to a mix of issues reported by rubocop, some of which are legitimate, but one of which is because of an error in rubocop itself.
#340 fixes the legitimate issues, but the one reported due to a rubocop error can be cleared up by either:

  • pinning the version of rubocop in this project Gemfile to one before the error was introduced (updating as soon as the new rubocop version is released that contains the fix)
  • specifying a rubocop version SHA in the Gemfile to one containing the fix, until the fix is released
  • just waiting for the next version of rubocop to be released

This is the commit that fixes the remaining (mis)reported violation:
rubocop/rubocop@90bc9d4

@smalleel
Copy link
Author

@groddeck: Wonderful, thanks for fixing the legit issues rubocop reported! As for the erronious report due to the rubocop, I just sent a pull request specifying the rubocop commit in the gemfile that you mentioned above with the fix. #341

@smalleel
Copy link
Author

Looks like with the latest release of Rubocop and @groddeck and @sferik 's contributions, this issue seems fixed! :) I'll close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants