codeclimate / codeclimate-rubocop

Code Climate Engine for Rubocop
MIT License
59 stars 43 forks source link

Support Project Configuration Gems #199

Closed coding-bunny closed 5 years ago

coding-bunny commented 5 years ago

Hello,

Rubocop has the feature to use the inherit_gem directive in a configuration file. This allows you to wrap configuration files in a gem and use these to configure rubocop. Since we have around 187 different projects at work, we use this to streamline our Rubocop configruation.

This however is not supported it seems with the changed made in the rubocop-0-70 channel yesterday:

/usr/local/bundle/gems/rubocop-0.70.0/lib/rubocop/config_loader_resolver.rb:196:in `rescue in gem_config_path': Unable to find gem inkycop; is the gem installed? Gem::MissingSpecError (Gem::LoadError)
    from /usr/local/bundle/gems/rubocop-0.70.0/lib/rubocop/config_loader_resolver.rb:192:in `gem_config_path'
    from /usr/local/bundle/gems/rubocop-0.70.0/lib/rubocop/config_loader_resolver.rb:48:in `block (2 levels) in resolve_inheritance_from_gems'
    from /usr/local/bundle/gems/rubocop-0.70.0/lib/rubocop/config_loader_resolver.rb:46:in `reverse_each'
    from /usr/local/bundle/gems/rubocop-0.70.0/lib/rubocop/config_loader_resolver.rb:46:in `block in resolve_inheritance_from_gems'
    from /usr/local/bundle/gems/rubocop-0.70.0/lib/rubocop/config_loader_resolver.rb:39:in `each_pair'
    from /usr/local/bundle/gems/rubocop-0.70.0/lib/rubocop/config_loader_resolver.rb:39:in `resolve_inheritance_from_gems'
    from /usr/local/bundle/gems/rubocop-0.70.0/lib/rubocop/config_loader.rb:49:in `load_file'
    from /usr/local/bundle/gems/rubocop-0.70.0/lib/rubocop/config_loader.rb:86:in `configuration_from_file'
    from /usr/local/bundle/gems/rubocop-0.70.0/lib/rubocop/config_store.rb:44:in `for'
    from /usr/src/app/lib/cc/engine/file_list_resolver.rb:38:in `rubocop_file_to_include?'
    from /usr/src/app/lib/cc/engine/file_list_resolver.rb:16:in `block in expanded_list'
    from /usr/src/app/lib/cc/engine/file_list_resolver.rb:13:in `each'
    from /usr/src/app/lib/cc/engine/file_list_resolver.rb:13:in `flat_map'
    from /usr/src/app/lib/cc/engine/file_list_resolver.rb:13:in `expanded_list'
    from /usr/src/app/lib/cc/engine/rubocop.rb:49:in `files_to_inspect'
    from /usr/src/app/lib/cc/engine/rubocop.rb:29:in `block in run'
    from /usr/src/app/lib/cc/engine/rubocop.rb:28:in `chdir'
    from /usr/src/app/lib/cc/engine/rubocop.rb:28:in `run'
    from /usr/src/app/bin/codeclimate-rubocop:17:in `<main>'

This was working fine 2 days ago before the changes got merged related to the rubocop-0-70 changes.

This is currently impacting our builds for all projects.

coding-bunny commented 5 years ago

Is there any update regarding this issue? We really like to use our shared configuration across projects, but if CodeClimate cannot run this, we'll need to swap to our CI systems running the rubocop inspections from now on.

maxjacobson commented 5 years ago

Hi @coding-bunny, sorry for the delay in getting back to you about this issue.

It looks like you switched from the default channel of our rubocop plugin to the rubocop 0.70 channel, and that's when your builds started to fail. The default channel is actually using a fairly old version of RuboCop: https://github.com/codeclimate/codeclimate-rubocop/blob/dba3b70ec3042e8ccfb7848e3dfe709b2754380b/Gemfile#L9

It's likely that that version of rubocop simply ignored your inherit_gem line.

For security reasons outlined here, Code Climate plugins do not have network access while running. This prohibits them from loading remote code such as shared configurations.

We do, however, support a configuration in your .codeclimate.yml which will download shared configuration files from the public web before running the plugins. Those details are outlined here: https://docs.codeclimate.com/docs/configuring-the-prepare-step.

It sounds like inherit_gem is not currently something that we can easily support, given those constraints of our system, but perhaps the prepare step will meet your needs? Hopefully that's helpful context, regardless.

coding-bunny commented 5 years ago

that work around defies the point we are trying to solve with the gem. At the moment we're running rubocop as part of our CI to use the custom gem, and no longer through CodeClimate.