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

preserve trailing whitespace when bumping sigil #428

Merged

Conversation

jakebrady5
Copy link
Contributor

closes #427

By preserving trailing whitespace we can prevent spoom from generating invalid sorbet sigils which lead to invalid spoom bumps.

This regex change also makes Sigils#strictness_in_content match more closely to the sigils as parsed by sorbet.

Tests added in this PR fail with the previous SIGIL_REGEXP value as follows:

test_valid_bump_with_rubocop_on_sigil

        --- expected
        +++ actual
        @@ -1,4 +1,4 @@
        -"# typed: true # rubocop:todo Sorbet/StrictSigil
        +"# typed: true# rubocop:todo Sorbet/StrictSigil
         class PassesTypeChecking; end
         PassesTypeChecking
         "

test_invalid_bump_with_rubocop_on_sigil

        --- expected
        +++ actual
        @@ -1,4 +1,5 @@
         "Checking files...

        -No files to bump from `false` to `true`
        +Bumped `1` file from `false` to `true`:
        + + file1.rb
         "

test_strictness_invalid_string

        Expected: "true#"
          Actual: "true"

@jakebrady5 jakebrady5 requested a review from a team as a code owner August 3, 2023 19:13
@Morriar
Copy link
Collaborator

Morriar commented Aug 3, 2023

Hey @jakebrady5,

You'll need to fix sign the CLA: https://github.com/Shopify/spoom/actions/runs/5754767186/job/15600749537?pr=428

Thanks!

@jakebrady5
Copy link
Contributor Author

Yep, running it by our team quickly to see whether they prefer I proceed as corporate or individual. I'll get one of the options sorted soon. Thanks for the ping!

@@ -28,7 +28,7 @@ module Sigils
T::Array[String],
)

SIGIL_REGEXP = T.let(/^#[\ t]*typed[\ t]*:[ \t]*(\w*)[ \t]*/, Regexp)
SIGIL_REGEXP = T.let(/^#[\ t]*typed[\ t]*:[ \t]*(\S*)/, Regexp)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This original regexp seems of, [\ t] would not match tabs as expected. It should be changed to [[:blank:]].

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree. Sorbet's comment parsing also does not seem to support any whitespace between typed and :. What do you think about this?

/^#[[:blank:]]*typed:[[:blank:]]*(\S*)/

@jakebrady5
Copy link
Contributor Author

I have signed the CLA!

@Morriar Morriar merged commit dbcf8d7 into Shopify:main Aug 7, 2023
@jakebrady5
Copy link
Contributor Author

@Morriar sorry to ping, just wondering if we can expect a release for this and your dependency change? 🙏🏼

@shopify-shipit shopify-shipit bot temporarily deployed to production August 8, 2023 17:59 Inactive
@Morriar
Copy link
Collaborator

Morriar commented Aug 8, 2023

Done: https://rubygems.org/gems/spoom/versions/1.2.3 👍

@Morriar Morriar added the bugfix Fix a bug label Mar 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix Fix a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bumping sigils with rubocop comments yields invalid results
2 participants