ACAB also applies to Rubocop
If you got #rubocop failing on EmptyInterpolation linter in the recent version (v1.76.0), there is good news for you. The issue got fixed - https://github.com/rubocop/rubocop/pull/14245
You might have noticed a record-breaking 7th consecutive bugfix release for #RuboCop (see https://github.com/rubocop/rubocop/releases/tag/v1.75.7). I just wanted to say that's not because the quality of RuboCop dropped, but because I've decided to focus on bug-fixing and polish for a while.
We have plenty of features already! š
I added a new configuration option to the `Naming/PredicateName` RuboCop rule: `UseSorbetSigs`. And itās now released.
If set, it will take into account Sorbet sigs. So it will only complain if the method doesnāt start/end with the right things (like is_, has_, question mark) if thereās a `returns(T::Boolean)` sig.
Setting this option has reduced the number of TODOs for this rule in the `github/github` codebase by over 50%.
I have no idea why I'm getting these rubocop errors. Rubocop seems to think these constants are defined within a `private` section, but they are not. The classes do however include a small `private` section above which is terminated by another `public` keyword, which should not effect the constants below the `public` keyword. I cannot seem to reproduce this rubocop bug in a stand-alone example.
https://github.com/ronin-rb/ronin-vulns/actions/runs/13342739549/job/37269447618
@MoskitoHero there's a #ruby convention about that:
https://rubystyle.guide/#safe-because-unsafe
But I've seen them disabled on most #rubocop configurations I've seen so far.
There's also something similar in #reek:
https://github.com/sdurko/reek/blob/master/docs/Prima-Donna-Method.md
Anyway, I do support that convention, but I lean more on not use them that often. I do prefer "safe" methods (functional style much) and I don't use it for side effect - it's implicit in their module names.
Seriously considering launching myself as able to take on #freelance work on #Ruby, #RuboCop, #Sorbet, etc stuff.
Thereās something very satisfying about fixing a list of things and making a codebase better in terms of consistency and developer experience. And I know a lot of people donāt enjoy that.
Very part-time. I love my ārealā job and everything else I do (OSS, events). After my maths exam would make more sense. But Iām still bored at weekends and the winter electricity bills are šš©.
A #Rubocop annoyance is that (last I checked) it doesnāt support my preferred formatting:
FactoryBot.create(:item,
foo: ābarā,
# Imagine more attributes here
)
You need either
FactoryBot.create(:item,
foo: ābarā # <- sad lack of comma
)
or
FactoryBot.create(
:item,
foo: ābarā,
)
or
FactoryBot.create(:item, foo: ābarā)
I may need to add support for it sometime, if itās not there and I missed it. Just me?
#Ruby's parser gem is nearly the end of the road https://github.com/whitequark/parser/issues/1046 Moving fully away from it will present some challenges to projects like #RuboCop (mostly because Prism currently misses some of parser's features), but it seems inevitable at this point.
I guess `Integer#allbits?` / `Integer#nobits?` optimizes better than `num & bitmask == result` since it's one method call vs. a bitwise operation and a comparison?
https://docs.rubocop.org/rubocop/cops_style.html#stylebitwisepredicate
Also apparently Style/BitwisePredicate is marked as an unsafe cop. Is there a rubocop configuration setting to disable *all* unsafe cops so I don't have to play wake-a-mole with rubocop?
Apparently rubocop is now recommending using Integer#allbits? / Integer#nobits? instead of `(num & 0xff) == 0xff`. I don't know how I feel about this... I feel like bitwise operations are more explicit.
https://docs.rubocop.org/rubocop/cops_style.html#stylebitwisepredicate
Wondering if rubocop should be in a separate GitHub Actions YAML file that only runs when any .rb file is changed? This might cut down on unnecessary rubocop runs.
#rubocop
The one about linting in a legacy Ruby project
https://blog.davidmp.es/the-one-about-linting-in-a-legacy-ruby-project
#ruby #rubyonrails #dev #programming #rubocop #linters
when #rubocop's ABC Size metric helps me refactor a method from ABC size of 35+ down to sub 17: Unbothered. Moisturized. Happy. In My Lane. Focused. #Flourishing.
I recently ran into an old codebase (~12 years old) without a Rubocop configuration, and figured adding one to existing code wasn't always as easy as it seems.
Here's a little step-by-step guide I wrote on how to tackle this kind of situation:
https://dev.to/lcsm0n/adding-a-rubocop-config-to-an-old-repository-step-by-step-guide-49db
The time has come for a gigantic RuboCop release, that's jam-packed with bug fixes and small improvements https://github.com/rubocop/rubocop/releases/tag/v1.67.0 Enjoy!