You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Make plugin load error messages more user-friendly
Users who encounter plugin load errors are usually those who have misconfigured the plugin, rather than the plugin developers.
## Before
The previous error message was more geared towards plugin developers.
```console
$ bundle exec rubocop lib/rubocop.rb
Error: Failed loading plugin `rubocop-performance` because we couldn't determine the corresponding plugin class to instantiate.
First, try upgrading it. If the issue persists, please check with the developer regarding the following points.
RuboCop plugin class names must either be:
- If the plugin is a gem, defined in the gemspec as `default_lint_roller_plugin'
spec.metadata['default_lint_roller_plugin'] = 'MyModule::Plugin'
- Set in YAML as `plugin_class_name'; example:
plugins:
- incomplete:
require_path: my_module/plugin
plugin_class_name: "MyModule::Plugin"
```
This error message might only confuse the user.
## After
This PR adjusts the message to guide users on the actions they should take when they see the error.
```console
$ bundle exec rubocop path/to/file.rb
Error: Failed to load plugin `rubocop-performance` because the corresponding plugin class could not be determined for instantiation.
Try upgrading it first (e.g., `bundle update rubocop-performance`).
If `rubocop-performance` is not yet a plugin, use `require: rubocop-performance` instead of `plugins: `rubocop-performance` in your configuration.
For further assistance, check with the developer regarding the following points:
https://docs.rubocop.org/rubocop/plugin_migration_guide.html
```
In most cases, this load error occurs because an extension cop doesn't support plugin system yet, `.rubocop.yml` contains `plugins: rubocop-foo`.
In this situation, the user has two options: run `bundle update`, or if that doesn't resolve the issue,
update `.rubocop.yml` to use `require: rubocop-foo` instead.
If contacting the developer is necessary, the migration guide included in this message may be helpful.
0 commit comments