Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display an error message if the RuboCop config is invalid #226

Merged
merged 2 commits into from
Jul 25, 2022

Conversation

vinistock
Copy link
Member

@vinistock vinistock commented Jul 25, 2022

Motivation

Closes #225

If a project using the LSP has invalid RuboCop configuration, like using a cop that no longer exists, diagnostics and formatting break. While this is not an error of the LSP itself, it would be nice to alert users and prompt them to fix their configuration.

Implementation

Rescue RuboCop's validation error when trying to run diagnostics and send a show message notification. This makes VS Code display an error notification if the configuration is invalid.

Automated Tests

Added a new integration example.

Manual Tests

  1. Start the LSP on this branch
  2. Change .rubocop.yml to make it invalid. For example, add
InvalidCop:
  Enabled: true
  1. Verify you get a notification about the invalid configuration

@vinistock vinistock requested a review from a team as a code owner July 25, 2022 19:02
@vinistock vinistock self-assigned this Jul 25, 2022
Copy link
Contributor

@Morriar Morriar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if the message should point fingers, something like: "There is an error with your Rubocop configure. Check your .rubocop.yml file."

So people understand the issue is not with ruby-lsp?

@vinistock
Copy link
Member Author

@Morriar I changed the phrasing to make it a bit more explicit.

@vinistock vinistock merged commit 82e92d2 into main Jul 25, 2022
@vinistock vinistock deleted the vs/display_message_on_invalid_rubocop_config branch July 25, 2022 20:59
vinistock added a commit that referenced this pull request Jul 27, 2022
…bocop_config

Display an error message if the RuboCop config is invalid
@shopify-shipit shopify-shipit bot temporarily deployed to production August 26, 2022 20:47 Inactive
andyw8 pushed a commit to andyw8/ruby-lsp that referenced this pull request Mar 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Surface incorrect rubocop.yml configurations
3 participants