rubocop-performance
or rubocop-rails
may be used with different versions of rubocop
, can they have different cop lists in such cases? E.g.: In the first case I have rubocop-rspec
version 1.42.0 and rubocop
version 0.87; in the second case I have rubocop-rspec
version 1.42.0 and rubocop
version 0.89. Will I get the same cops in both cases?
corrector.remove(node.loc.expression)
at the moment, but it leaves behind an empty line. I want to remove the empty line as well.
range_by_whole_lines
https://github.com/rubocop-hq/rubocop/blob/master/lib/rubocop/cop/mixin/range_help.rb#L69
%CONST
in nodepattern doesn't work in ruby 2.4 if it's a Set
(and it doesn't seem to work at all with an array). There's no test for that in rubocop-ast, but I'm getting this failure in rubocop-performance: https://app.circleci.com/pipelines/github/rubocop-hq/rubocop-performance/341/workflows/528ddd46-d4f6-4dc5-883c-fc02cc002540/jobs/2155
rubocop --only <dirty-cop-that-relies-on-others-to-clean-it-all-up>
is supposed to work though.
--autocorrect-info
to include it in JSON report
rubocop --format json
, and e.g. this JSON format gives you information if it's auto-correctable or not. Excerpt:{"path":"lib/rubocop/cop/rspec/describe_class.rb","offenses":[{"severity":"convention","message":"Extra blank line detected.","cop_name":"Layout/EmptyLines","corrected":false,"correctable":true,"location":{"start_line":51,"start_column":1,"last_line":52
.rubocop.yml
, even though it's mentioned in the docs https://github.com/rubocop-hq/rubocop/blame/c1b7dce1fc7af1ad13ab1fa975b31312925f6109/docs/modules/ROOT/pages/usage/basic_usage.adoc#L259RUBOCOP_OPTS
a try.RUBOCOP_OPTS
with https://github.com/direnv/direnv, but it's only my personal preference.
Hello Rubocop team!
Could you help to find how to implement a custom Rubocop rule for checking git branch naming convention?
I need to check the correctness of git branch naming - it should contain ticket ID.
I see, Rubocop processes only text nodes and checks only text lines. So, is it possible to define a rule that will be run only once to check one custom condition that is not related to the code but only to business logic(state of git repository)?
Thanks!
P.S.
Also created duplicates of this question here:
extend AutoCorrector
and then add_offense
will yield a corrector object. However, when I do that, my specs fail with undefined method autocorrect
which suggests that I should implement autocorrect
method in my cop. When I do, it's "automagically" called with the node as an argument, the corrector is nowhere to be seen. Am I doing it wrong? I'm running Rubocop 0.93.1
:point_up: Edit: I'm confused by AutoCorrector, https://docs.rubocop.org/rubocop/development.html#autocorrect says that you only need to extend AutoCorrector
and then add_offense
will yield a corrector object. However, when I do that, my specs fail with undefined method autocorrect
which suggests that I should implement autocorrect
method in my cop. When I do, it's "automagically" called with the node as an argument, the corrector is nowhere to be seen. Am I doing it wrong? I'm running Rubocop 0.93.1
EDIT: Here's the code I currently have – https://gitlab.com/-/snippets/2361004
:point_up: Edit: <del>I'm confused by AutoCorrector, https://docs.rubocop.org/rubocop/development.html#autocorrect says that you only need to extend AutoCorrector
and then add_offense
will yield a corrector object. However, when I do that, my specs fail with undefined method autocorrect
which suggests that I should implement autocorrect
method in my cop. When I do, it's "automagically" called with the node as an argument, the corrector is nowhere to be seen. Am I doing it wrong? I'm running Rubocop 0.93.1</del>
<del>EDIT: Here's the code I currently have – https://gitlab.com/-/snippets/2361004</del>
It turns out I needed to inherit from Rubocop::Cop::Base