Skip to main content

UnusedAssign

Identifies variable definitions that aren't used.


The following examples contain code snippets that either fail or pass this check.

{% assign this_variable_is_not_used = 1 %}

{% assign this_variable_is_used = 1 %}
{% if this_variable_is_used == 1 %}
<span>Hello!</span>
{% endif %}
{% assign _prefixed_ok = 1}

UnusedAssign:
enabled: true
severity: warning
ParameterDescription
enabledWhether this check is enabled.
severityThe severity of the check.

Anchor to Disabling this checkDisabling this check

Variables that are known to be unused can be prefixed by a _ to disable the check. Example:

{% capture _ %}
{% form "cart", cart %}
{% assign posted_successfully = cart.posted_successfully? %}
{% endform %}
{% endcapture %}

{% assign _unused = 'some value' %}

This check is safe to disable.


Was this page helpful?