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: unjustified errors for property binding info #639

Merged
merged 4 commits into from
Jul 19, 2023

Conversation

marufrasully
Copy link
Contributor

@marufrasully marufrasully commented Jul 19, 2023

fix unjustified error for following points.

  • escape diagnostic for metadata binding that contains colon e.g {/SomeValue/#@sap:label}
    • consider also HTML equivalent e.g. / or /
  • escape diagnostic for model that contains colon e.g Unknown property binding info on sap:label. #637
    • consider also HTML equivalent >

Refactoring

  • move some logic to binding-parser package for reuse

@changeset-bot
Copy link

changeset-bot bot commented Jul 19, 2023

🦋 Changeset detected

Latest commit: fab5c29

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 5 packages
Name Type
@ui5-language-assistant/vscode-ui5-language-assistant-bas-ext Patch
vscode-ui5-language-assistant Patch
@ui5-language-assistant/binding-parser Patch
@ui5-language-assistant/binding Patch
@ui5-language-assistant/language-server Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@voicis
Copy link
Contributor

voicis commented Jul 19, 2023

Wouldn't it be easier and safer to check if its simple binding (only model and binding path) via regex? UI5 also does something similar https://github.com/SAP/openui5/blob/master/src/sap.ui.core/src/sap/ui/base/BindingParser.js#L396.

Checking it by looking at errors seems to be rather error prone, because you need to check many things to make sure that the errors are actually representing the particular case you're looking for and not something else.

The reported issue is no longer reproducible, however here are some examples that seems to be still wrong:
{'path'>: ''} This should be handled as binding, because quotes are not allowed in simple binding. (currently no errors are shown)
{oData>#@sap:label} We still complain about the relative paths with simple binding.

@marufrasully
Copy link
Contributor Author

marufrasully commented Jul 19, 2023

Wouldn't it be easier and safer to check if its simple binding (only model and binding path) via regex? UI5 also does something similar https://github.com/SAP/openui5/blob/master/src/sap.ui.core/src/sap/ui/base/BindingParser.js#L396.

Checking it by looking at errors seems to be rather error prone, because you need to check many things to make sure that the errors are actually representing the particular case you're looking for and not something else.

The reported issue is no longer reproducible, however here are some examples that seems to be still wrong: {'path'>: ''} This should be handled as binding, because quotes are not allowed in simple binding. (currently no errors are shown) {oData>#@sap:label} We still complain about the relative paths with simple binding.

Using regex makes life easier, but it also has its own weakness for our use case. That reg expression assumes that it always starts with {key: [bracket, key and colon], which means for partially valid content, it may produce undesired result. e.g {path '', suspended: false} Here colon is missing in first key and causing to ignore complete binding expression. Anyway, I enhance the logic which also covers cases you detected.

@sonarcloud
Copy link

sonarcloud bot commented Jul 19, 2023

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 2 Code Smells

42.4% 42.4% Coverage
0.0% 0.0% Duplication

idea Catch issues before they fail your Quality Gate with our IDE extension sonarlint SonarLint

Copy link
Contributor

@voicis voicis left a comment

Choose a reason for hiding this comment

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

  • Tested locally and the issues are no longer reproducible
  • Wide range of cases are covered with tests (there seems to be an issue with SonarQube coverage reporting)

@marufrasully marufrasully merged commit 92e60aa into master Jul 19, 2023
8 of 9 checks passed
@marufrasully marufrasully deleted the fix/637/unjustified-error branch July 19, 2023 16:15
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.

2 participants