-
Notifications
You must be signed in to change notification settings - Fork 183
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
Enable RuboCop in vscode
& jekyll
directories
#3246
base: main
Are you sure you want to change the base?
Conversation
This identifies a number of offenses, which have been corrected. Notably, `rubocop-md` treats Markdown code blocks without a language specified as Ruby by default. We could change this behaviour, but it's clearer to explicitly mark the snippets as `txt` when there is no matching language.
How to use the Graphite Merge QueueAdd the label graphite-merge to this PR to add it to the merge queue. You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. |
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.
Nice
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.
I don't know what to do about
jekyll/add-ons.markdown:274:3: C: RubyLsp/UseRegisterWithHandlerMethod: Created a handler without registering the associated on_call_node_enter event.
def on_call_node_enter(node) ...
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
jekyll/add-ons.markdown:301:3: C: RubyLsp/UseRegisterWithHandlerMethod: Created a handler without registering the associated on_call_node_leave event.
def on_call_node_leave(node); end
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
but it's the repo's own cops failing, so I'm guessing we should be addressing them?
Sorbet: | ||
Enabled: false |
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.
RuboCop was complaining that vscode/activation.rb
should be
# typed: strict
which enforces sig
s on all methods. The file currently has no method definitions, but if it ever gained any, we couldn't attach any sig
s without sorbet-runtime
, so strict
is clearly too high.
We could use
# typed: true
to simply benefit from type checking, but then Sorbet complains about
env = ENV.filter_map do |k, v|
utf_8_value = v.dup.force_encoding(Encoding::UTF_8)
"#{k}RUBY_LSP_VS#{utf_8_value}" if utf_8_value.valid_encoding?
end
env.unshift(RUBY_VERSION, Gem.path.join(","), !!defined?(RubyVM::YJIT))
# Expected `String` but found `T::Boolean` ^^^^^^^^^^^^^^^^^^^^^^^^^
$stderr.print("RUBY_LSP_ACTIVATION_SEPARATOR#{env.join("RUBY_LSP_FS")}RUBY_LSP_ACTIVATION_SEPARATOR")
because it thinks env
must be a T::Array[String]
. We could do
env.unshift(RUBY_VERSION, Gem.path.join(","), defined?(RubyVM::YJIT) ? "true" : "false")
but technically, we don't need to (interpolating a boolean works fine), so it seemed simplest to just disable the Sorbet cops.
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.
Yeah, all we have under vscode
for Ruby are the activation scripts. There's no point in adopting Sorbet, let's please keep it disabled.
The linting error doesn't make much sense because it's not really intended to run on Markdown. Let's just add a comment as the body of those methods saying what people are supposed to do in them. |
Motivation
The
vscode
andjekyll
directories are not being checked by RuboCop.vscode/activation.rb
should be checked, as it is RubyImplementation
The
Include
config is updated so the additional directories are linted.This identifies a number of offenses, which have been corrected.
Notably,
rubocop-md
treats Markdown code blocks without a language specified as Ruby by default. We could change this behaviour, but it's clearer to explicitly mark the snippets astxt
when there is no matching language.