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

Add final, bind, & implementation to SignatureBuildOrder #189

Merged
merged 5 commits into from
Mar 18, 2024

Conversation

sambostock
Copy link
Contributor

@sambostock sambostock commented Oct 15, 2023

This teaches SignatureBuildOrder to also enforce the ordering of final, bind, and implementation builder methods.

As per #186 (comment)

It also includes a refactor which

  • drops the need for unparser, and
  • teaches SignatureBuildOrder to handle sigs which include unknown builder methods, rather than ignore them

Before Merging

@sambostock sambostock changed the base branch from main to document-sig-build-order October 15, 2023 22:09
Copy link
Contributor Author

@sambostock sambostock left a comment

Choose a reason for hiding this comment

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

We can probably skip specs for these, as the existing specs don't exhaustively cover the builder methods.

The documentation should be updated though.

Base automatically changed from document-sig-build-order to main October 15, 2023 22:20
@sambostock sambostock force-pushed the order-more-signature-builders branch from dbbdb2c to 5e4384f Compare October 15, 2023 22:21
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.

What if we took the order from an array in the configuration and we ship with a default (so we can use our preferred order and remove the old sig builders) but it enables people to use their own order and builders?

@paracycle
Copy link
Member

What if we took the order from an array in the configuration and we ship with a default (so we can use our preferred order and remove the old sig builders) but it enables people to use their own order and builders?

Yeah, I like this idea...

@sambostock
Copy link
Contributor Author

Oh, yeah, in retrospect that's definitely the way to go. 👍

I'll update when I get a minute.

@sambostock
Copy link
Contributor Author

Okay, I've updated the cop to extract a config, and added the missing methods to that config.

@sambostock sambostock marked this pull request as ready for review October 22, 2023 00:36
@sambostock sambostock requested a review from a team as a code owner October 22, 2023 00:36
@sambostock sambostock force-pushed the order-more-signature-builders branch 3 times, most recently from ca2eca1 to 7d6bdcc Compare October 22, 2023 03:30
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.

Very nice!

Do you mind adding a test that changes the order config please?

lib/rubocop/cop/sorbet/signatures/signature_build_order.rb Outdated Show resolved Hide resolved

This comment was marked as resolved.

This comment was marked as resolved.

@github-actions github-actions bot added the stale label Dec 25, 2023
@sambostock sambostock removed the stale label Dec 27, 2023
@sambostock sambostock force-pushed the order-more-signature-builders branch from 7d6bdcc to 171aa6f Compare December 27, 2023 16:04
@sambostock
Copy link
Contributor Author

I've added a test for the config change, and while doing that I realized I could improve the implementation to remove the need for unparser and handle unknown builder methods (by just ignoring them, rather than ignoring the entire sig).

@sambostock sambostock force-pushed the order-more-signature-builders branch from 96c2bbb to 8d0a2c4 Compare December 28, 2023 17:00
Copy link
Contributor

github-actions bot commented Feb 9, 2024

This PR has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale label Feb 9, 2024
@github-actions github-actions bot closed this Feb 16, 2024
@paracycle paracycle reopened this Mar 18, 2024
Copy link
Member

@paracycle paracycle left a comment

Choose a reason for hiding this comment

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

Thank you, this looks great and I think it just fell through the cracks.

If you can rebase it, we can merge and release.

This refactor removes the dependency on `unparser` for autocorrection,
and teaches the cop to handle unknown builder methods by ignoring their
ordering amongst known methods, rather than skipping the entire `sig`.

Incidentally, it also migrates from the deprecated `RuboCop::Cop::Cop`
class to `RuboCop::Cop::Base`.
@sambostock sambostock force-pushed the order-more-signature-builders branch from 8d0a2c4 to e9be4a9 Compare March 18, 2024 19:02
@sambostock sambostock removed the stale label Mar 18, 2024
@paracycle paracycle merged commit e4181c5 into main Mar 18, 2024
11 checks passed
@paracycle paracycle deleted the order-more-signature-builders branch March 18, 2024 19:04
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.

3 participants