standardrb / standard-rails

A Standard Ruby plugin that configures rubocop-rails
MIT License
163 stars 15 forks source link

Adding `standard-rails` as a plugin seems to turn off most/all `standard` rules #4

Closed jmanian closed 1 year ago

jmanian commented 1 year ago

I'm fairly new to standard, so this might be my error in configuring something wrong, but...

I'm configuring standard on a new Rails project and I tried also adding standard-rails. I followed the instructions to add standard-rails as a plugin in .standard.yml.

When I include it as a plugin and I run standard (bundle exec standardrb) it no longer checks the rules from standard and it seems to only check the standard-rails rules. For example, I switched some strings to single quotes and messed with some indentations, and it does not catch these. When I remove standard-rails from the config file then it catches them again.

I don't have any other configuration, so my entire .standard.yml is this:

plugins:
  - standard-rails

Is this an issue with standard-rails, or am I missing something?

searls commented 1 year ago

This is entirely possible—I may have screwed something up in config merging the plugins, as I can imagine Standard's test suite missed this. I'll test this tomorrow!

searls commented 1 year ago

Alright, I just pushed out a hotfix in standard@1.28.1 -- try updating?

jmanian commented 1 year ago

That fixed it ... except for something weird: It made one of the rails rules disappear. Here's the different states that I reached and the rules that flagged issues:

standard@1.28.0, no standard-rails config:

Style/StringLiterals

standard@1.28.0, standard-rails added to .standard.yml:

Rails/RedundantPresenceValidationOnBelongsTo
Rails/ThreeStateBooleanColumn

standard@1.28.1 (via bundle update standard):

Style/StringLiterals
Rails/ThreeStateBooleanColumn

Maybe Rails/RedundantPresenceValidationOnBelongsTo wasn't supposed to be on in the first place?

searls commented 1 year ago

RedundantPresenceValidationOnBelongsTo should be enabled.

What version of Rails are you running?

This is probably related to the TargetRailsVersion hack I had to add to get the rules running (which likely broke that configuration property) and which I'm looking at now

jmanian commented 1 year ago

This app is running Rails 6.1.7.3

searls commented 1 year ago

Ok, I think I have this figured out now. Could you update to standard@1.28.2 and try again?

jmanian commented 1 year ago

Nice, now I have all 3 rules firing:

Rails/RedundantPresenceValidationOnBelongsTo
Rails/ThreeStateBooleanColumn
Style/StringLiterals