Shopify / erb_lint

Lint your ERB or HTML files
MIT License
643 stars 119 forks source link

Osolete configuration found (`Rails` and `Performance/*` cops extracted to other gems) #227

Open afdev82 opened 3 years ago

afdev82 commented 3 years ago

I get a similar error of issue #155 (obsolete configuration found):

$ bundle exec erblint --lint-all
warning: parser/current is loading parser/ruby30, which recognizes
warning: 3.0.2-compliant syntax, but you are running 3.0.1.
warning: please see https://github.com/whitequark/parser#compatibility-with-ruby-mri.
Linting 163 files with 13 linters...
RuboCop::ValidationError: `Performance/*` has been extracted to the `rubocop-performance` gem.
(obsolete configuration found in .erblint-rubocop20210716-7788-nwtps0, please update it)
`Rails` cops have been extracted to the `rubocop-rails` gem.
(obsolete configuration found in .erblint-rubocop20210716-7788-nwtps0, please update it)
/home/antonio/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/rubocop-1.17.0/lib/rubocop/config_obsoletion.rb:43:in `reject_obsolete!'
/home/antonio/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/rubocop-1.17.0/lib/rubocop/config_validator.rb:70:in `check_obsoletions'
/home/antonio/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/rubocop-1.17.0/lib/rubocop/config_validator.rb:44:in `validate'
/home/antonio/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/rubocop-1.17.0/lib/rubocop/config.rb:49:in `check'
/home/antonio/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/rubocop-1.17.0/lib/rubocop/config.rb:38:in `create'
/home/antonio/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/rubocop-1.17.0/lib/rubocop/config_loader.rb:55:in `load_file'
/home/antonio/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/erb_lint-0.0.37/lib/erb_lint/linters/rubocop.rb:163:in `block in config_from_hash'
/home/antonio/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/erb_lint-0.0.37/lib/erb_lint/linters/rubocop.rb:126:in `block in tempfile_from'
/home/antonio/.rbenv/versions/3.0.1/lib/ruby/3.0.0/tempfile.rb:358:in `create'
/home/antonio/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/erb_lint-0.0.37/lib/erb_lint/linters/rubocop.rb:122:in `tempfile_from'
/home/antonio/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/erb_lint-0.0.37/lib/erb_lint/linters/rubocop.rb:162:in `config_from_hash'
/home/antonio/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/erb_lint-0.0.37/lib/erb_lint/linters/rubocop.rb:182:in `block in base_configs'
/home/antonio/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/erb_lint-0.0.37/lib/erb_lint/linters/rubocop.rb:178:in `map'
/home/antonio/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/erb_lint-0.0.37/lib/erb_lint/linters/rubocop.rb:178:in `base_configs'
/home/antonio/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/erb_lint-0.0.37/lib/erb_lint/linters/rubocop.rb:168:in `resolve_inheritance'
/home/antonio/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/erb_lint-0.0.37/lib/erb_lint/linters/rubocop.rb:160:in `config_from_hash'
/home/antonio/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/erb_lint-0.0.37/lib/erb_lint/linters/rubocop.rb:182:in `block in base_configs'
/home/antonio/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/erb_lint-0.0.37/lib/erb_lint/linters/rubocop.rb:178:in `map'
/home/antonio/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/erb_lint-0.0.37/lib/erb_lint/linters/rubocop.rb:178:in `base_configs'
/home/antonio/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/erb_lint-0.0.37/lib/erb_lint/linters/rubocop.rb:168:in `resolve_inheritance'
/home/antonio/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/erb_lint-0.0.37/lib/erb_lint/linters/rubocop.rb:160:in `config_from_hash'
/home/antonio/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/erb_lint-0.0.37/lib/erb_lint/linters/rubocop.rb:27:in `initialize'
/home/antonio/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/erb_lint-0.0.37/lib/erb_lint/runner.rb:15:in `new'
/home/antonio/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/erb_lint-0.0.37/lib/erb_lint/runner.rb:15:in `block in initialize'
/home/antonio/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/erb_lint-0.0.37/lib/erb_lint/runner.rb:14:in `map'
/home/antonio/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/erb_lint-0.0.37/lib/erb_lint/runner.rb:14:in `initialize'
/home/antonio/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/erb_lint-0.0.37/lib/erb_lint/cli.rb:53:in `new'
/home/antonio/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/erb_lint-0.0.37/lib/erb_lint/cli.rb:53:in `run'
/home/antonio/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/erb_lint-0.0.37/exe/erblint:9:in `<top (required)>'
/home/antonio/.rbenv/versions/3.0.1/bin/erblint:23:in `load'
/home/antonio/.rbenv/versions/3.0.1/bin/erblint:23:in `<top (required)>'
/home/antonio/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/bundler-2.2.23/lib/bundler/cli/exec.rb:63:in `load'
/home/antonio/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/bundler-2.2.23/lib/bundler/cli/exec.rb:63:in `kernel_load'
/home/antonio/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/bundler-2.2.23/lib/bundler/cli/exec.rb:28:in `run'
/home/antonio/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/bundler-2.2.23/lib/bundler/cli.rb:474:in `exec'
/home/antonio/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/bundler-2.2.23/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/home/antonio/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/bundler-2.2.23/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
/home/antonio/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/bundler-2.2.23/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
/home/antonio/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/bundler-2.2.23/lib/bundler/cli.rb:30:in `dispatch'
/home/antonio/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/bundler-2.2.23/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
/home/antonio/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/bundler-2.2.23/lib/bundler/cli.rb:24:in `start'
/home/antonio/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/bundler-2.2.23/exe/bundle:49:in `block in <top (required)>'
/home/antonio/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/bundler-2.2.23/lib/bundler/friendly_errors.rb:128:in `with_friendly_errors'
/home/antonio/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/bundler-2.2.23/exe/bundle:37:in `<top (required)>'
/home/antonio/.rbenv/versions/3.0.1/bin/bundle:23:in `load'
/home/antonio/.rbenv/versions/3.0.1/bin/bundle:23:in `<main>'

I don't have this error in another Rails project, with same versions of the following gems:

This is my erb-lint.yml (it's the same in the other project):

---
linters:
  FinalNewline:
    enabled: true
  NoJavascriptTagHelper:
    enabled: true
  Rubocop:
    enabled: true
    rubocop_config:
      inherit_from:
        - .rubocop.yml
      Layout/InitialIndentation:
        Enabled: false
      Layout/TrailingEmptyLines:
        Enabled: false
      Layout/LineLength:
        Enabled: false
      Layout/TrailingWhitespace:
        Enabled: false
      Lint/AmbiguousBlockAssociation:
        Enabled: false
      Lint/UselessAssignment:
        Enabled: false
      Naming/FileName:
        Enabled: false
      Rails/OutputSafety:
        Enabled: false
      Style/FrozenStringLiteralComment:
        Enabled: false # TODO
      Lint/SafeNavigationChain:
        Enabled: false # TODO
      Style/FormatStringToken:
        Enabled: false # TODO
      Style/MultilineBlockChain:
        Enabled: false # TODO
      Style/NestedTernaryOperator:
        Enabled: false # TODO
      Style/NumericPredicate:
        Enabled: false # TODO
  SelfClosingTag:
    enabled: true
    enforced_style: 'always'
  SpaceAroundErbTag:
    enabled: true

And this is my rubocop.yml (in the other project it's slightly different, because of different Exclude paths and some rules):

require:
  - rubocop-performance
  - rubocop-rails
  - rubocop-rspec

inherit_from: .rubocop_todo.yml

inherit_mode:
  merge:
    - Include

AllCops:
  Include:
    - [...]
  Exclude:
    - [...]
  TargetRubyVersion: 3.0
  TargetRailsVersion: 6.0
  DisplayCopNames: true
  DisplayStyleGuide: true
  NewCops: enable

Layout/LineLength:
  Enabled: false

Metrics/AbcSize:
  Enabled: false

Metrics/BlockLength:
  Enabled: false

Metrics/BlockNesting:
  Enabled: false

Metrics/ClassLength:
  Enabled: false

Metrics/CyclomaticComplexity:
  Enabled: false

Metrics/MethodLength:
  Enabled: false

Metrics/ModuleLength:
  Enabled: false

Metrics/PerceivedComplexity:
  Enabled: false

Naming/InclusiveLanguage:
  Enabled: false

Naming/VariableNumber:
  Enabled: false

Rails:
  Enabled: true

RSpec/BeforeAfterAll:
  Exclude:
    - [...]

RSpec/InstanceVariable:
  Exclude:
    - [...]

Rails/ApplicationController:
  Exclude:
    - [...]

Rails/FilePath:
  EnforcedStyle: arguments

Rails/UnknownEnv:
  Environments:
    - production
    - development
    - test
    - staging

Style/AndOr:
  EnforcedStyle: conditionals

Style/AsciiComments:
  AllowedChars: ['ä', 'ö', 'ü']

Style/Documentation:
  Enabled: false

Style/DocumentDynamicEvalDefinition:
  Exclude:
    - 'app/helpers/js_helper.rb'

Style/FrozenStringLiteralComment:
  Enabled: false

Style/RedundantBegin:
  Enabled: false

Any help will be much appreciated, thank you!

afdev82 commented 3 years ago

I tried the workaround and it worked once again. But it's an open issue that shows up every time I regenerate the rubocop_todo.yml file with the command:

rubocop --auto-gen-config --exclude-limit 30

I have always to remember to add the requires that are needed for erblint and not rubocop. Is there any possible definitive solution for that?

Thank you!

rafaelfranca commented 2 years ago

Do you still see this error?

jasonlor commented 2 years ago

I'm also seeing issue this issue

rafaelfranca commented 2 years ago

Do you have any Rails or Performance cops in your configuration? By default erb-lint doesn't, so I don't see why this is an issue on erb-lint.

afdev82 commented 2 years ago

I didn't get your question, which configuration are you referring to?

It's an issue with erb-lint, because if I use rubocop and I run rubocop --auto-gen-config --exclude-limit 30 everything is fine. If I run erb-lint, with the same rubocop_todo.yml file I get the error in the first post. If I require the plugins also in the rubocop_todo.yml file the error is gone, but it's a workaround only needed for erblint. Others in this issue probably have explained better than me: https://github.com/openstreetmap/openstreetmap-website/issues/2472#issuecomment-568255229

rafaelfranca commented 2 years ago

Ahhh. Now I get the problem. Thank you. We also have it in our app too. It is in my todo list to fix for a while. If you know the fix, I'd totally merge a PR.

afdev82 commented 2 years ago

If you know the fix, I'd totally merge a PR.

Unfortunately I don't know how to fix it :see_no_evil: