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

F1 bug: doesn't filter _value properly #167

Closed
erictt opened this issue Jan 23, 2024 · 7 comments
Closed

F1 bug: doesn't filter _value properly #167

erictt opened this issue Jan 23, 2024 · 7 comments
Labels
bug Something isn't working

Comments

@erictt
Copy link
Contributor

erictt commented Jan 23, 2024

For example,

    html:
    {% if currency._value == "usd" %}
    <p>${{rendered_value}}</p>
    {% elsif currency._value == "gbp" %}
    <p>£{{rendered_value}}</p>
    {% elsif currency._value == "eur" %}
    <p>€{{rendered_value}}</p>
    {% else %}
    <p>{{rendered_value}}</p>
    {% endif %}
    ;;
    description: "Amount"

This will trigger the F1 error.

❌      F1..... v:capital_advance_funnel/d:amount.............. amount references another view, if currency,  via if currency._value == "usd" %

I checked the regex here, and found the parts actually are:

[ 'if currency', '_value == "usd" %' ]

Given the parts, the filter list won't work since _value is not identified as a single field.

@erictt
Copy link
Contributor Author

erictt commented Jan 23, 2024

Maybe use a split at first before checking the exact match?

parts[parts.length - 1].split(" ").some(substring => [
			'SQL_TABLE_NAME',
			'_sql',
			'_value',
			'_name',
			'_filters',
			'_parameter_value',
			'_rendered_value',
			'_label',
			'_link',
		].includes(substring));

for this: https://github.com/looker-open-source/look-at-me-sideways/blob/master/rules/f1.js#L60

@fabio-looker
Copy link
Contributor

Yea, that regex is definitely suspect! Thanks for the clear example, I'll queue this up :)

@mariana-s-fernandes
Copy link

I have the same issue with fields dependent on parameters

@fabio-looker
Copy link
Contributor

@erictt's PR should be published to v3.1.3 and v2.1.8

@mariana-s-fernandes - does Eric's fix address your comment too, or no?

@erictt
Copy link
Contributor Author

erictt commented Apr 5, 2024

@erictt's PR should be published to v3.1.3 and v2.1.8

@mariana-s-fernandes - does Eric's fix address your comment too, or no?

Thank you so much for the merging!

@fabio-looker
Copy link
Contributor

Thank you so much for the merging!

My pleasure! I was a little strapped for time in the second half of Q1, so my apologies it took me so long. Had a few things to clean up & add along with the merge and it took me a while to get to it

@mariana-s-fernandes
Copy link

@fabio-looker this one is ok now! Thanks!
But my linting result is completely different now... But I will raise it somewhere else

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants