-
Notifications
You must be signed in to change notification settings - Fork 175
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
Remove RuboCop dependency and fallback to SyntaxTree formatting #184
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can test this by modifying the $LOAD_PATH
like so:
$ irb
> require "rubocop"
true
$ irb
> $LOAD_PATH.delete_if {|path| path.start_with?(Gem.loaded_specs["rubocop"].full_gem_path) }
> require "rubocop"
LoadError: cannot load such file -- rubocop
(of course, we would need to recover the original $LOAD_PATH
afterwards)
7bd89fe
to
57fbc26
Compare
@@ -20,7 +20,6 @@ Gem::Specification.new do |s| | |||
s.require_paths = ["lib"] | |||
|
|||
s.add_dependency("language_server-protocol") | |||
s.add_dependency("rubocop", ">= 1.0") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉
cb39605
to
081a6f7
Compare
Renamed the method and also made unloading constants a bit more resilient. It was making the tests flaky when trying to remove constants, so I just wrapped it in a rescue. |
…ypescript-eslint/eslint-plugin-5.33.0 Bump @typescript-eslint/eslint-plugin from 5.32.0 to 5.33.0
Motivation
Closes #76
Building on top of #183
If RuboCop is not present in the current application, we can fallback to formatting using SyntaxTree. Additionally, this allows us to drop the dependency on RuboCop and simply try to require it when available.
Implementation
Both the diagnostics and formatting runners will now exit early without defining the classes if RuboCop is not present. If the runner classes don't exist, then we can exit early in diagnostics and fallback to SyntaxTree on formatting.
Automated Tests
Honestly, I'm not sure about the best way to test this. If you have ideas on how to fake that RuboCop is not present in the bundle, please let me know.
Manual Tests
It's a bit of work, but here are the steps if you're interested in testing it out.
With RuboCop
Without RuboCop
Gemfile
,dev.yml
and anexample.rb
file)dev.yml
with the desired Ruby version and dev upGemfile
, add the Ruby LSP pointing to this branch (e.g.:gem "ruby-lsp", path: "../ruby-lsp"
)example.rb