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

Have correctors accept node instead of range #7863

Merged
merged 2 commits into from Apr 10, 2020

Conversation

@marcandre
Copy link
Contributor

marcandre commented Apr 9, 2020

This PR allows correctors to accept nodes in addition to ranges.

E.g: corrector.insert_before(node, 'blah')

Also provides better errors in case of wrong argument
Before: "undefined method `source_buffer' for 1..3:Range"
After: "Expected a Parser::Source::Range or Rubocop::AST::Node, got Range"

I don't think it would be particularly useful, but we could actually accept ranges like 1..3 if we wanted too...

This assumes #7862 is merged.

@marcandre marcandre force-pushed the marcandre:correct_node branch 2 times, most recently from 5ee7276 to a363f15 Apr 9, 2020
@bbatsov
Copy link
Collaborator

bbatsov commented Apr 10, 2020

Might be a good idea to also mention this in the docs.

@marcandre marcandre force-pushed the marcandre:correct_node branch from a363f15 to a654db2 Apr 10, 2020
@marcandre marcandre changed the title Correct node Have correctors accept node instead of range Apr 10, 2020
@marcandre marcandre force-pushed the marcandre:correct_node branch from a654db2 to 0d494a7 Apr 10, 2020
@marcandre
Copy link
Contributor Author

marcandre commented Apr 10, 2020

Might be a good idea to also mention this in the docs.

I modified slightly manual/development.md but couldn't find anywhere else...

I amended the PR with simplifications using this (mostly due to accepting node, a few using wrap, sometimes both at once...)

@marcandre marcandre force-pushed the marcandre:correct_node branch from 0d494a7 to 88117ec Apr 10, 2020
Provide better errors in case of wrong argument
Before: "undefined method `source_buffer' for 1..3:Range"
After: "Expected a Parser::Source::Range or Rubocop::AST::Node, got Range"
@marcandre marcandre force-pushed the marcandre:correct_node branch from 88117ec to f5f222e Apr 10, 2020
@marcandre marcandre force-pushed the marcandre:correct_node branch from f5f222e to 8efed68 Apr 10, 2020
@bbatsov bbatsov merged commit 9c3f904 into rubocop-hq:master Apr 10, 2020
24 of 25 checks passed
24 of 25 checks passed
ci/circleci: ruby-head-spec Your tests failed on CircleCI
Details
ci/circleci: cc-setup Your tests passed on CircleCI!
Details
ci/circleci: cc-upload-coverage Your tests passed on CircleCI!
Details
ci/circleci: documentation-checks Your tests passed on CircleCI!
Details
ci/circleci: jruby-9.2-ascii_spec Your tests passed on CircleCI!
Details
ci/circleci: jruby-9.2-rubocop Your tests passed on CircleCI!
Details
ci/circleci: jruby-9.2-spec Your tests passed on CircleCI!
Details
ci/circleci: ruby-2.3-ascii_spec Your tests passed on CircleCI!
Details
ci/circleci: ruby-2.3-rubocop Your tests passed on CircleCI!
Details
ci/circleci: ruby-2.3-spec Your tests passed on CircleCI!
Details
ci/circleci: ruby-2.4-ascii_spec Your tests passed on CircleCI!
Details
ci/circleci: ruby-2.4-rubocop Your tests passed on CircleCI!
Details
ci/circleci: ruby-2.4-spec Your tests passed on CircleCI!
Details
ci/circleci: ruby-2.5-ascii_spec Your tests passed on CircleCI!
Details
ci/circleci: ruby-2.5-rubocop Your tests passed on CircleCI!
Details
ci/circleci: ruby-2.5-spec Your tests passed on CircleCI!
Details
ci/circleci: ruby-2.6-ascii_spec Your tests passed on CircleCI!
Details
ci/circleci: ruby-2.6-rubocop Your tests passed on CircleCI!
Details
ci/circleci: ruby-2.6-spec Your tests passed on CircleCI!
Details
ci/circleci: ruby-2.7-ascii_spec Your tests passed on CircleCI!
Details
ci/circleci: ruby-2.7-rubocop Your tests passed on CircleCI!
Details
ci/circleci: ruby-2.7-spec Your tests passed on CircleCI!
Details
ci/circleci: ruby-head-ascii_spec Your tests passed on CircleCI!
Details
ci/circleci: ruby-head-rubocop Your tests passed on CircleCI!
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
@bbatsov
Copy link
Collaborator

bbatsov commented Apr 10, 2020

Nicely done! 🙇‍♂️

pftg added a commit to jetthoughts/erb-lint that referenced this pull request May 22, 2020
Rubocop changed interface and after
rubocop-hq/rubocop#7863 it requires correctors
to accept nodes.

Closes Shopify#162
pftg added a commit to jetthoughts/erb-lint that referenced this pull request May 22, 2020
Rubocop changed interface and after
rubocop-hq/rubocop#7863 it requires correctors
to accept nodes.

Closes Shopify#162
pftg added a commit to jetthoughts/erb-lint that referenced this pull request May 22, 2020
Rubocop changed interface and after
rubocop-hq/rubocop#7863 it requires correctors
to accept nodes.

Closes Shopify#162
pftg added a commit to jetthoughts/erb-lint that referenced this pull request May 22, 2020
Rubocop changed interface and after
rubocop-hq/rubocop#7863 it requires correctors
to accept nodes.

Closes Shopify#162
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.