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

Review backticks to enclose variables in if condition and for loop - can't, high risk of error #1038

Closed
kensoh opened this issue May 24, 2021 · 1 comment
Assignees
Labels

Comments

@kensoh
Copy link
Member

kensoh commented May 24, 2021

#953 might open up possibility for this to be done with good risk / reward

@kensoh kensoh self-assigned this May 24, 2021
@kensoh kensoh added the feature label May 24, 2021
@kensoh kensoh changed the title Review use of backticks for variables in conditions - to review Review use of backticks for variables in if condition and for loop - to review May 24, 2021
@kensoh kensoh changed the title Review use of backticks for variables in if condition and for loop - to review Review using backticks for variables in if condition and for loop - to review May 24, 2021
@kensoh kensoh changed the title Review using backticks for variables in if condition and for loop - to review Review using backticks to enclose variables in if condition and for loop - to review May 24, 2021
@kensoh
Copy link
Member Author

kensoh commented May 27, 2021

Following changes will let parsing engine ignore the backticks in conditions and code, after replacing with repo and datatable.

// if line is code, replacing with repo and datatable should already be done
// thus below line support `variable` in conditions by ignoring `` detected
if (is_code($script_line)) return str_replace("`","",$script_line);
// if line is code, replacing with repo and datatable should already be done
// thus below line support `variable` in conditions by ignoring `` detected
if (is_code(script_line)) return script_line.replace(/`/g,'',script_line);

However, how to convert human language text into text with quotations?

Converting this

if `address` equals to block 123 apple lane

to this isn't straightforward

if (address == 'block 123 apple lane')

Converting this

if `address` equals to block 123 apple lane and `address` contains apple lane

to this most likely will lead to JS compilation error for some other user conditions

if ((address == 'block 123 apple lane') && (address.indexOf('apple lane') > -1))

For now, conclusion is it's hard to accurately do using backticks for variables and no quotation marks for text.

Thus, go in direction of giving examples and showing users, instead of changing to be consistent at expense of accuracy.

@kensoh kensoh closed this as completed May 27, 2021
@kensoh kensoh changed the title Review using backticks to enclose variables in if condition and for loop - to review Review using backticks to enclose variables in if condition and for loop - can't, risk of error May 27, 2021
@kensoh kensoh changed the title Review using backticks to enclose variables in if condition and for loop - can't, risk of error Review backticks to enclose variables in if condition and for loop - can't, high risk of error May 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant