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

Apply SimplifyInterpolationRule to all expressions #6152

Conversation

jeskew
Copy link
Contributor

@jeskew jeskew commented Mar 8, 2022

Fixes #5963

Update the SimplifyInterpolationRule linter rule to apply to all expressions that resolve to strings, not just identifiers of string variables and parameters.

Contributing a Pull Request

If you haven't already, read the full contribution guide. The guide may have changed since the last time you read it, so please double-check. Once you are done and ready to submit your PR, run through the relevant checklist below.

Contributing a feature

  • I have opened a new issue for the proposal, or commented on an existing one, and ensured that the Bicep maintainers are good with the design of the feature being implemented
  • I have included "Fixes #{issue_number}" in the PR description, so GitHub can link to the issue and close it when the PR is merged
  • I have appropriate test coverage of my new feature

Update the SimplifyInterpolationRule linter rule to apply to all expressions that resolve to strings, not just identifiers of string variables and parameters.
@ghost
Copy link

ghost commented Mar 8, 2022

CLA assistant check
All CLA requirements met.

@majastrz
Copy link
Member

@jeskew There are some baseline test failures in. In the contribution guide, there are some instructions on how to force the tests to regenerate the baseline assets. Then, you just manually review the git diffs to ensure that the changes are legitimate.

@StephenWeatherford
Copy link
Contributor

@jeskew Thanks! I should be able to take a look today or tomorrow. Would love to have this fixed.

Copy link
Member

@majastrz majastrz left a comment

Choose a reason for hiding this comment

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

Thanks for fixing!

@StephenWeatherford StephenWeatherford added this to the v0.5 milestone Mar 11, 2022
@StephenWeatherford StephenWeatherford added this to In progress in 0.5 release Mar 11, 2022
@StephenWeatherford StephenWeatherford moved this from In progress to In Review in 0.5 release Mar 11, 2022
@StephenWeatherford
Copy link
Contributor

Re-running suites (timeout issue?)

@StephenWeatherford
Copy link
Contributor

@majastrz My original code had this comment indicating why it wasn't done:

// We only want to trigger if the var or param is of type string (because interpolation
// using non-string types can be a perfectly valid way to convert to string, e.g. '${intVar}')

It sounds like the rule should only trigger if the expression type is string? Does that sound right to you?

Copy link
Contributor

@StephenWeatherford StephenWeatherford left a comment

Choose a reason for hiding this comment

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

We need to resolve the comment I made to Marcin before merging

@jeskew
Copy link
Contributor Author

jeskew commented Mar 11, 2022

@StephenWeatherford The SemanticModel.GetTypeInfo method is able to determine the resolved type of complex expressions, so the use case you mention is already accounted for. I'll add some test cases to make sure expressions like '${max(1, 2)}' or '${concat(<array>, <array>)}' are left as is.

@StephenWeatherford
Copy link
Contributor

Ah, I missed that there was aleady a IsStrictlyAssignableToString(type)) check. Thanks!

@StephenWeatherford
Copy link
Contributor

Trying build again - I've had some issues with it recently.

@jeskew
Copy link
Contributor Author

jeskew commented Mar 14, 2022

@StephenWeatherford The failing tests are reporting errors about being unable to locate credentials for live tests. It looks like these tests require access to a couple repository secrets, so I believe those failures are expected given GitHub's policy of not sharing secrets with pull requests originating from forks.

@majastrz majastrz merged commit 8027108 into Azure:main Mar 14, 2022
@majastrz
Copy link
Member

Live tests aren't marked as required. We'll be updating the CI configuration to exclude them in fork PRs to avoid confusion in the future.

@jeskew jeskew deleted the feature/apply-simplify-interpolation-rule-to-all-expressions branch March 14, 2022 20:21
@alex-frankel alex-frankel moved this from In Review to Done in 0.5 release Mar 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
3 participants