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

fix(manager/gradle): preserve next token for parsing in case dependency interpolation fails #18330

Merged
merged 3 commits into from
Oct 27, 2022

Conversation

Churro
Copy link
Collaborator

@Churro Churro commented Oct 13, 2022

Changes

Return {} instead of null for errors in processDepInterpolation. tryMatch() won't try other matchers but assume it was the correct one and that only handling failed.

Currently, token.shift() removes the next token if a) no matching sequence was found or b) it was found but an error occurred during processing. This is problematic if there is another potential match following directly afterwards, as it will miss the first token for matching.

This PR addresses this only for processDepInterpolation, although there are other spots in the code where the same behavior could show up (processLongFormDep, processDepString). Switching to {} everywhere seems risky to me as it could mean that other relevant matching sequences are simply skipped. In this case, I think this should be no issue since with the current order no other matching sequence follows that would begin with TokenType.StringInterpolation. Subsequent matching sequences including TokenType.StringInterpolation don't use it for the first token, so all other occurrences should still match fine with the token lookahead done in matchTokens.

More details also here.

To get rid of this problem overall, I'd prefer to address it in the parser refactoring (work ongoing).

Context

Closes #18317

Documentation (please check one with an [x])

  • I have updated the documentation, or
  • No documentation update is required

How I've tested my work (please tick one)

I have verified these changes via:

  • Code inspection only, or
  • Newly added/modified unit tests, or
  • No unit tests but ran on a real repository, or
  • Both unit tests + ran on a real repository

Test repository: renovate-demo/18317-renovate-gradle-variable-interpolate-reproduction#4

@rarkins rarkins requested a review from zharinov October 14, 2022 03:25
zharinov
zharinov previously approved these changes Oct 24, 2022
viceice
viceice previously approved these changes Oct 24, 2022
@viceice
Copy link
Member

viceice commented Oct 24, 2022

needs deconfliction

� Conflicts:
�	lib/modules/manager/gradle/parser.spec.ts
@Churro Churro dismissed stale reviews from viceice and zharinov via e289705 October 24, 2022 19:35
@rarkins rarkins enabled auto-merge (squash) October 27, 2022 04:49
@rarkins rarkins requested review from viceice and zharinov October 27, 2022 04:49
@rarkins rarkins merged commit 8279be4 into renovatebot:main Oct 27, 2022
@renovate-release
Copy link
Collaborator

🎉 This PR is included in version 34.2.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 27, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Gradle variable ordering breaks detected dependencies
5 participants