Go home rubocop, you are drunk:
undefined method `value' for s(:send,
s(:lvar, :gemspec), :[],
s(:str, "required_ruby_version")):RuboCop::AST::SendNode
Saturday MP Show #10: Finally get a System Tests Working for the Standard Ruby Linter ToDo Bug
I get my system test working but the problem is it works so well that it still passes even after I re-introduce the bug when it should have failed. Crap!
Question you want answered in a future video? Pair on a problem? Constructive feedback? DM me or email ask@saturdaymp.com.
#systemtesting #ruby #standardrb #rubocop #testdrivendevelopment #saturdaympshow #saturdaymp
#systemtesting #ruby #standardrb #rubocop #testdrivendevelopment #saturdaympshow #saturdaymp
@klaustopher #rubocop Metrics were a bit of a mistake. I still want my methods with 10 lines but there's no point in having hundreds of warnings because of it
It took me a while to figure out the collection of magical incantations required to get #RuboCop to run on ONLY the changed files in a GitHub Workflow. So, I made a quick blog post with the details. I also included a variation for when you're ready to have it run on _all_ your files. I recommend the latter.
https://weblog.masukomi.org/2023/06/19/github-rubocop-workflow/
@aesthetikx Since I think the untuned #RuboCop defaults are often silly, I avoid it and didn't realize this was even a question until I saw your post. I think you should always do whatever clearly expresses the programmer's intent most clearly to the rest of your team, but a famous writer (RAH?) once said something like "obsessive consistency is the hobgoblin of little minds."
Be semantically clear. Don' let It prevent you from raising or failing when that makes more sense, though.
Has anyone built a #Rubocop to assert that all #RailsEventStore event handlers are subscribed to the domain events they expect to receive? If not, I wrote something that might be extractable.
I found 5 event handlers out of 20 that expected some domain events but weren’t wired up properly!
All right, StandardRb v1.29.0 is up and out!
A whole host of rules enabled to simplify your life and reduce code redundancy, like array constructors with arrays in them! regex constructors with regex in them! kablow! gone!
Standard-performance is now up to date with rubocop-performance as well, so enjoy those bugfixes.
🔗 https://rubygems.org/gems/standard/versions/1.29.0
#Ruby #Rails #RubyOnRails #StandardRails #RuboCop
#ruby #rails #rubyonrails #standardrails #rubocop
Ugh, rubocop is claiming `URI.regexp` is obsolete, and that I should use `URI::DEFAULT_PARSER.make_regexp('https')`. Is this true? The official Ruby 3.2 docs don't seem to mention this.
https://docs.ruby-lang.org/en/3.2/URI.html
#rubocop
#lazyweb #rails #rubocop help!?
I have a Rails app.
It has an engine (/engines/admin).
When I run `rubocop --auto-gen-config`, it doesn't create entries for failures in the admin engine.
When I run `rubocop`, it tells me about the failures (that weren't added to the root todo file).
How do I tell Rubocop about my engine at `todo` time and at `check` time?
I'm curious if there's a rubocop rule for checking if a `to_s` method contains memoization. This could cause problems if an object is converted to a String and then the String is mutated, which then modifies the cached version of the String.
#rubocop
Is there a tool for #ruby or #rubocop to check for deprecated code? I’m migrating some code from 2.5 to 3.2 and I’ve only found this article from 2014 that mentions it’s a difficult problem (understandably!)
https://batsov.com/articles/2014/02/05/a-list-of-deprecated-stuff-in-ruby/
This is interesting: 🤔 https://www.reddit.com/r/rails/comments/11krlmz/are_you_using_rubocopairbnb/
well, not just the topic but the content too.
#ruby #rubocop #codestyle
Awesome. Made my first rubocop gem that contains all of the custom configuration and overrides.
https://github.com/ronin-rb/rubocop-ronin
#rubocop
Or maybe I should try creating my own rubocop extension gem? Apparently it's possible to package one's `.rubocop.yml` up into a gem.
https://github.com/Shopify/ruby-style-guide/tree/v2.12.0
#rubocop
Another rubocop bummer, `Layout/ExtraSpacing` only checks non-commented lines of code. If you have one line of code followed by commented out lines, all of which are vertically aligned with each other, rubocop will claim the first line has excess spacing in between it's arguments.
```ruby
gem 'foo', '~> 0.1'
# gem 'bar', '~> 0.2'
# gem 'baz', '~> 0.3'
```
I wish rubocop's `Layout/ParameterAlignment` could be aware of vertically aligned keyword arguments that follow a positional argument:
```ruby
def foo(a,b, bar: nil,
baz: nil,
qux: nil)
end
```
Aligning the keyword arguments to the first argument breaks the alignment with the keyword argument names.
#rubocop
Found an interesting bug in rubocop: `%{%{0}}`. This time I am pretty sure this is a bug. Ruby does allow `%{} to exist within `%{ ... }` string literals. However, rubocop seems to think it's a format string of some sort?
https://github.com/rubocop/rubocop/issues/11618
#rubocop
Ugh, `Lint/MissingSuper` should not flag code where the superclass does not define it's own initialize method.
#rubocop
I'm also curious whether `Style/MutableConstant` actually catches legitimate bugs? I feel like most people either intend a constant to be mutable, or never intentionally modify a constant.
#rubocop