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
Fix RuboCop offenses #3740
Fix RuboCop offenses #3740
Conversation
|
I'm sorry I have missed https://github.com/rubygems/rubygems/pull/3731/files, but I think we should ship no rule overrides, just follow the default ones (to not bring any another opinion in there actually) and create on CI new test to create gem and run rubocop on top of that to ensure no offences are present on skeleton. |
|
@simi I tend to recall that we discussed this in the past and we want to encourage using double quotes by overriding this default in the generated gem skeleton. That's my opinion anyways :) |
|
I'm happy with adding a CI test to ensure that rubocop is green on generated gems. |
AFAICU, the team prefers the use of double quotes so in case there's a case of string interpolation, there'll be no inconsistency with both sorts of "StringLiterals". And I tend to agree with this. |
|
@utkarsh2102 Yeah, I believe that's why the |
I wholeheartedly agree with this as well 😄 |
|
@simi Well, my recollection was wrong. I double checked rubygems/bundler#6455, and the only opinions there are:
So, it seems that I'm losing this battle too 😅 |
I do not fight for any rule and actually bundler/rubygems standards are not related here since it is new gem skeleton, not actual part of runtime. I'm just trying to say that if we would like to integrate rubocop in new gem skeleton, we should not do any decision on configuration. The same we do for rspec and minitest, just minimal default integration needed to be able to start testing without bringing any opinions. |
|
Yeah, that's the debate here. My opinion is that it is fine that we bring some opinions, specially with double_quotes, since a relevant part of the community actively changes this default. And it also provides a sample configuration, which is nice to get started in my opinion. |
Of course. It's just opinion-based. #3731 was raised because I didn't like I am perfectly fine with whatever the outcome of this discussion is, but I think it's important that we, at least, discuss this. And obviously, all in good faith! ❤️❤️ |
|
Yeah, as long as we ship an offense free rubocop setup, I'm fine with any outcome here. Let's wait for some more opinions, and if the current balance (2 to 1) doesn't change, let's remove the generated |
Yes, I think we all have the same goal. Provide skeleton without any rubocop violations. The question is how to get to this state :) My opinion was written already, anyway I'm ok with any solution. 🤔 Next step should be actually pull request to integrate rubocop check in bundled CI scripts as well and have CI green by default. 🥳 |
|
@utkarsh2102 Do you want to give that test a try? In the new gem specs, add a spec that runs rubocop inside the generated gem, and checks that there are no errors. |
Sure, I'd love to do that! 😄 |
|
I don't like rubocop's default rule. In fact, many of projects disable it rule.
In my opinion, we put |
1538d54
to
1a4c613
Compare
|
Yeah, have a look at rubocop/rubocop#5306 for a discussion on what the preferred quote style is in the ruby community. It's about 50/50, although the most popular projects usually use double quotes. I don't mind about However, I believe |
I don't mind, but how about, we consider this road: This might be sounding crazy, but the whole idea of doing this is to not show any offenses by running |
|
@utkarsh2102 What @hsbt is suggesting is to add Style/FrozenStringLiteralComment:
Enabled: falseto the generated gem |
Ah, sure. This means that we are definitely shipping a |
|
Haha, good question 😆. It seems that we have a tie (2-2), although I'm still giving this some more thought and I might even reconsider my vote 😅 Let's hold on a bit on that, but you can definitely add the spec already since everybody wants that. |
Also forgot to ask @bronzdoc! |
|
I am strongly in favor of having tests for this, good suggestion @utkarsh2102! Personally, I would like my new gems to use double-quotes. 😅 I am happy with removing frozen string literals, to get us ahead of the Ruby 3 curve, and I would agree with @deivid-rodriguez to leave the rules on by default since this is a new project. That said, I am in favor of this work even if the consensus ends up not agreeing with my personal preferences. 😄 |
35a5104
to
578f4c5
Compare
These offenses appear when you create a gem with `bundle gem foo` and run `rubocop` over it. Initially, there were around 45 offenses detected, but with rubygems#3731 and this, the number of offenses have been reduced to 2. Signed-off-by: Utkarsh Gupta <utkarsh@debian.org>
Signed-off-by: Utkarsh Gupta <utkarsh@debian.org>
since without that, evaluating the gemspec from outside `File.expand_path( __dir__)` won't work. Signed-off-by: Utkarsh Gupta <utkarsh@debian.org>
Signed-off-by: Utkarsh Gupta <utkarsh@debian.org>
Previously, we were using the old syntax like: `task :default => :spec`, but now this commit uses the new Ruby 1.9 hash syntax. Signed-off-by: Utkarsh Gupta <utkarsh@debian.org>
to use double_quotes instead of single_quotes. Signed-off-by: Utkarsh Gupta <utkarsh@debian.org>
With this, it will be ensured that the generated (skeleton) gem will have no offenses. Signed-off-by: Utkarsh Gupta <utkarsh@debian.org>
Signed-off-by: Utkarsh Gupta <utkarsh@debian.org>
aab10cf
to
0530137
Compare
The later RuboCop versions don't work with ruby2.3 so we should lock the version to what works with ruby2.3 as we haven't dropped the support yet. And since we're using the older version of rubocop, also fix `Max` value of `LineLength` to 120, which is the current standard. Without this, rubocop will throw the line length offenses. Signed-off-by: Utkarsh Gupta <utkarsh@debian.org>
0530137
to
46d0a80
Compare
because rubocop configuration inheritance is messed up and when using `--ignore-parent-exclusion`, even though the exit status is 0, the example still fails because of the configuration issue. Signed-off-by: Utkarsh Gupta <utkarsh@debian.org>
With older versions of rubocop, the dependency on `jaro_winkler` seems to be a pain. However, in the later versions of rubocop, this dependency was dropped. So we only need to use the older version for ruby2.3. Signed-off-by: Utkarsh Gupta <utkarsh@debian.org>
ruby_core has an 'ast.rb' file that gets in the middle and breaks this spec, so it's better we skip this test on this workflow for now. Also, slightly change the spec name from "run" to "runs" and change the last assertion, it's cleaner to check empty error. Thanks to David Rodríguez for this! Signed-off-by: Utkarsh Gupta <utkarsh@debian.org>
|
Finallyyy! The CI is greeeen! 😭🎉 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't believe this is green finally 😭
Great job 💪
Thanks to you for helping and being patient with me ❤️ |
|
Since this PR fulfills our main goal of having a clean As @simi suggested, we can discuss further tweaks on the default configuration later. |
|
Ah, I just noticed the change from %q to double quotes in the gemspec—this isn't blocking, but the reason I did that is so that gem descriptions can contain both double and single quotes (like |
|
Hi @indirect,
I hear you, I really do! Personally, I am happy to do so but again, we will need to discuss more about whether we want to ship a default The best way forward, I think, is
That said, I can even revert back to So let me know what you think? 😅 |
|
Oh I think we should merge first! I called that out as not blocking on purpose. 😄 Thanks for trying to work with us. |
It's both, an honor and a pleasure to do so ❤️ |
|
Awesome, merging this pending further discussions about magic string literals comments, or specific exclusions to the default string quotes rule in the gemspec 👍. Thanks so much for your patience @utkarsh2102! |
With rubygems#3731 and rubygems#3740 merged, this covers up the remaining part of the issues. This was discovered when one tries to create a gem with a different framework. Could be reproduced with: `bundle gem foo --ext --test=test-unit` Signed-off-by: Utkarsh Gupta <utkarsh@debian.org>
These offenses appear when you create a gem with
bundle gem fooand runrubocopover it.Initially, there were around 45 offenses detected,
but with #3731 and this, the number of offenses
have been reduced to 0.
@bronzdoc, as promised, here's this 🎉
Signed-off-by: Utkarsh Gupta <utkarsh@debian.org>
Tasks:
I will abide by the code of conduct.