coala / coala-bears

Bears for coala
https://coala.io/
GNU Affero General Public License v3.0
294 stars 580 forks source link

rubocop bear - Use .rubocop.yml as default config if the file exist. #1077

Open bekicot opened 7 years ago

bekicot commented 7 years ago

There is 2 issue i found.

  1. i tried to not use rubocop_config and it doesn't pick up default rubocop config, although it exist in the root project directory

    [ruby]
    bears = RuboCopBear
    files = **.gemspec, */**.rb
  2. I also tried to add rubocop_config and set the value to default rubocop config file, it doesnt pick up the rules specified

    [ruby]
    bears = RuboCopBear
    files = **.gemspec, */**.rb
    rubocop_config = .rubocop.yml

I also print the args variable in the RubocopBear.py (After i add rubocop_config in coafile) here is the results

 ('/Users/bekicot/Folks/jekyll/jekyll-admin/spec/jekyll-admin/server_spec.rb', '--stdin', '--format=json', '--config', '.rubocop.yml')
('/Users/bekicot/Folks/jekyll/jekyll-admin/lib/jekyll-admin/version.rb', '--stdin', '--format=json', '--config', '.rubocop.yml')
('/Users/bekicot/Folks/jekyll/jekyll-admin/spec/jekyll-admin/server/data_spec.rb', '--stdin', '--format=json', '--config', '.rubocop.yml')
('/Users/bekicot/Folks/jekyll/jekyll-admin/lib/jekyll-admin/server/collection.rb', '--stdin', '--format=json', '--config', '.rubocop.yml')
('/Users/bekicot/Folks/jekyll/jekyll-admin/spec/jekyll-admin/static_server_spec.rb', '--stdin', '--format=json', '--config', '.rubocop.yml')
('/Users/bekicot/Folks/jekyll/jekyll-admin/lib/jekyll-admin/server/configuration.rb', '--stdin', '--format=json', '--config', '.rubocop.yml')
('/Users/bekicot/Folks/jekyll/jekyll-admin/spec/jekyll_admin_spec.rb', '--stdin', '--format=json', '--config', '.rubocop.yml')
('/Users/bekicot/Folks/jekyll/jekyll-admin/node_modules/node-sass/src/libsass/extconf.rb', '--stdin', '--format=json', '--config', '.rubocop.yml')
('/Users/bekicot/Folks/jekyll/jekyll-admin/lib/jekyll-admin/static_server.rb', '--stdin', '--format=json', '--config', '.rubocop.yml')

I'm not python programmer, but hopefully that helps

Here is the project i tried to add coafile http://github.com/jekyll/jekyll-admin

Makman2 commented 7 years ago
  1. The rubocop-bear does not pick up the .rubocop.yml automatically. If you don't specify a config file, the bear is meant to generate one on its own, taking more specific settings like max_class_length, max_method_length or variable_naming_convention from the coafile (you can lookup those in the bear description).
  2. That's weird, it seems the args are correctly generated for rubocop. Could you post the contents of the .rubocop.yml ?
bekicot commented 7 years ago

@Makman2 The first one is kind of feature request. As coala should use the rubocop default config.

Here is the content of rubocop.yml


inherit_gem:
  jekyll: .rubocop.yml

AllCops:
  Exclude:
    - lib/jekyll-admin/public/**/*
    - src/**/*
    - node_modules/**/*

Metrics/BlockLength:
  Enabled: false
```+
nemani commented 7 years ago

I can take up the First Request, make RuboCopBear check the present directory for rubocop.yml Is that to be done?

Makman2 commented 7 years ago

@bekicot I would decline the first issue as a feature request on first sight (sorry :3), because coala's idea currently is to be the one and only interface for all codestyle tools. Especially the workaround is very easy, just specify .rubocop.yml as the rubocop_config. Also it would clash a bit with the current "feature" of coala to generate it's own rubocop-yml-file which you can assemble using settings inside your coafile (see previous answer). --> @nemaniarjun keep cool, there needs stuff to be discussed :)

@bekicot I assume the trailing backticks and + do not belong to the yml-file :) Does your code already conform to your given codestyle definitions? If so coala won't say something, as everything is alright :) If not, would you mind sending me one of your files so I can test?

bekicot commented 7 years ago

Here is the content of the rubocop.yml

inherit_gem:
  jekyll: .rubocop.yml

AllCops:
  Exclude:
    - lib/jekyll-admin/public/**/*
    - src/**/*
    - node_modules/**/*

Metrics/BlockLength:
  Enabled: false

https://github.com/jekyll/jekyll-admin/blob/master/.rubocop.yml

As you can see there is inherited rules come from https://github.com/jekyll/jekyll/blob/master/.rubocop.yml

Makman2 commented 7 years ago

I mean one of your code files you try to lint/analyze :)