Closed knutsenm closed 1 year ago
This is probably a legit bug as I've never used this feature or really understand how it's implemented
OK, could @mrbiggred possibly help?
Hmm, it's not a todo thing. I have the same problem even after I move the lines to .standard.yml
:
+++ b/.standard.yml
@@ -2,3 +2,6 @@ plugins:
- standard-rails
ignore:
- 'db/migrate/*'
+ - 'lib/log/logger.rb':
+ - Style/GlobalStdStream
+ - Rails/EnvironmentVariableAccess
The Style/GlobalStdStream
ignore in my .standard.yml
example above does work (tested by removing it), it's only the Rails cop that's not ignored.
The problem is even more specific: I can't ignore the Rails/EnvironmentVariableAccess cop. Other Rails cops can be ignored from either file. I changed the subject accordingly.
Thanks for narrowing your report. Unfortunately I was unable to replicate your issue in this commit, which adds a test of an ignore
https://github.com/standardrb/standard/commit/c741249517bbda747cb06d393e512c4212a8502b
Note that the nested ignore here is two levels of indentation deep (one more than you might expect) so that the YAML parses it as a nested map and not a subsequent element in an array:
ignore:
- '**/*.rb':
- Bananas/BananaBomb
Your example was this:
- lib/log/logger.rb:
- Style/GlobalStdStream
- Rails/EnvironmentVariableAccess
Does this work?
- lib/log/logger.rb:
- Style/GlobalStdStream
- Rails/EnvironmentVariableAccess
Note that the nested ignore here is two levels of indentation deep
I'm sorry to report that doesn't help in my case.
I'm baffled why this one particular cop can't be ignored. I'm trying to convert a private repo from rubocop to standard, and have removed old .rubocop.yml and .rubocop_todo.yml files. Rails/EnvironmentVariableAccess is disabled by default in rubocop-rails, and so the old config and code didn't have to ignore it.
I do note that I can successfully rubocop:disable
or standard:disable
it in code comments, so that's something.
@knutsenm I'm not sure why the Rails cops aren't being ignored. I haven't used this new Standard Rails plugin. I'll play around with it and if I find anything I'll post an update.
@knutsenm do you have an example project that show cases the issue?
@knutsenm do you have an example project that show cases the issue?
Yes, see https://github.com/CruGlobal/rails-infrastructure-canary/pull/99
The Ruby/lint Action fails the same way it does for me locally,
== lib/log/logger.rb ==
C: 15: 10: Rails/EnvironmentVariableAccess: Do not read from ENV directly post initialization.
C: 16: 36: Rails/EnvironmentVariableAccess: Do not read from ENV directly post initialization.
I figured this out and it was not fun. See https://github.com/standardrb/standard/commit/ed4253a0cdc3e8790cacf2e397f7c28e2b53157c for a description
Released a fix in standard@1.28.4
Glad you figured it out @searls.
I'm unable ignore this rule, I'm on Standard version: 1.36.0
plugins:
- standard-rails
ignore:
- 'Rails/EnvironmentVariableAccess'
@WMahoney09 try this:
plugins:
- standard-rails
ignore:
- config/initializers/*.rb:
- Rails/EnvironmentVariableAccess
standardrb --generate-todo
does create Rails exclusions; example:However, despite this: