-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
That stolen figurine is omnipresent, like candy #2573
Conversation
83d0b7e
to
c5fd1d6
Compare
…ing multiple lines For example: if condition1 && condition2 && condition3 return end This will look funny if corrected to: return if condition1 && condition2 && condition3 Therefore, leave these cases to the discretion of individual programmers rather than requiring the 'guard clause' style with modifier if/unless to be used.
1bee23d
to
95e459d
Compare
The cached disabled line ranges and comments are used to add UnneededDisable offenses to the cached offenses. But this process is deterministic, so we can simply do it *before* caching and then just cache the resulting offenses. This greatly simplifies the caching code. As a bonus, the caching should be more effective, since more work is done once only and then reused, rather than being repeated every time the cached data is retrieved.
Under certain circumstances, Lint/UnneededDisable's autocorrection would bite off just a bit too much, and delete a space which was needed. My bad.
When only some cops in a rubocop:disable comment were unneeded, and the comment was not at the very beginning of the file, random junk would appear as the highlight, rather than the unneeded content.
…LambdaCall's toes A `#call` method can be called using this special syntax: obj.() `Style/LambdaCall` checks for this syntax, and depending on its enforced style, either enforces or forbids its use. Since `Style/LambdaCall` is already handling these cases, `Style/MethodCallParentheses` can just stay away.
95e459d
to
c85234c
Compare
I have fixed the problem with serializing invalid UTF-8 text in The commit which adds This is a very real issue; and yet, after further consideration, I still feel this is a better solution than poking config options in using setters like However, if the maintainers disagree, I am happy to re-implement in another way. |
c85234c
to
1f9a714
Compare
Added a couple of missing CHANGELOG entries. Ready for final review. |
f6f35a5
to
d370e19
Compare
This cop finds things like: if condition_a action_a else if condition_b action_b end end Which should be converted to: if condition_a action_a elsif condition_b action_b end
… modifier if ...or unless. The problem occurred when a redundant merge had more than 1 key-value pair, and a modifier `if`, like: hash.merge!(a: 1, b: 2) if condition That was erroneously auto-corrected to: hash[:a = 1] hash[:b = 2] if condition
…printing to TTY)
We had no tests checking whether `Lint/EndAlignment`'s `variable` style worked or not when a node with `end` is not on the RHS of an assignment. So it was never noticed when 31d0b31 completely broke the `variable` style. Fix it up, and add tests so this doesn't happen again.
Previously, when the `variable` style was used, auto-correction gave the wrong results on the RHS of an ivar assignment, cvar assignment, and so on.
d370e19
to
8f8630b
Compare
Hmm. I've searched and haven't found any equivalent method which I could unify this one with. We do have a lot of duplicate helper methods in RC, though, and I do want to de-duplicate more of them as we go. |
CachedData uses the JSON library. It is already required in json_formatter.rb, but it is better to require it here as well, since it is needed here.
As suggested by Jordon Bedwell.
Updated according to @bbatsov's review. There are no problematic "magic numbers" for target Ruby version any more (see 12c6efc). Added a commit which adjusts the default I was thinking of adding a cache busting value somewhere in I think |
8f8630b
to
91c98d9
Compare
This will only work for people using the stable release and I know there are users tracking the master branch (e.g. users impatient to get bug fixes, support for Ruby 2.3). For this to work we should start issuing some pre-releases. |
That stolen figurine is omnipresent, like candy
Anyways, this PR is good shape, so I'll merge it. We can figure out the cache-busting issue later. |
Another solution to cache busting would be to put a |
@alexdowad The reason why the cache invalidation logic uses a checksum for the entire RuboCop source (not just |
@jonas054 I didn't get that it was reading the source in If we wanted to avoid the overhead of calculating the source checksum, we could just disable caching in RC's own |
Yes. There are some cases where we can actually take advantage of caching during RuboCop development, and that's when you're only changing specs. So let's keep it for now. |
@jonas054, could you please look at 8c36731? (I think you are the author of the caching code.)
There was a spec there checking that text which is invalid under UTF-8 encoding could still be serialized out and in. It used a comment with some invalid text... but since comments are not cached any more, I moved the invalid text to the offense description instead. Unfortunately... the test doesn't pass.
Any idea on the best way to fix this?