Liquid Complexity
Identifies Liquid files whose cyclomatic complexity is greater than the configured maxComplexity. Liquid complexity starts at 1 for each file and increases for each of the following:
- Branching or looping tags:
if,unless,case,for,tablerow, andpaginate. elsifandwhenbranches.- Logical
andandorexpressions inside control-flow conditions.
Reducing complexity helps keep theme files easier to understand and maintain. When a file exceeds the configured maximum, simplify the conditional logic or move self-contained decision logic into snippets that are rendered from the original file.
Anchor to ExamplesExamples
The following examples contain code snippets that either fail or pass this check.
Anchor to ✗ Fail✗ Fail
In the following example, the file has a complexity of 7. It fails when maxComplexity is set to 4:
Anchor to ✓ Pass✓ Pass
In the following example, repeated output and assignment logic doesn't add branching complexity:
Anchor to OptionsOptions
The following example contains the default configuration for this check:
| Parameter | Description |
|---|---|
enabled | Whether this check is enabled. |
severity | The severity of the check. |
maxComplexity | The maximum allowed Liquid complexity for a single file. |
Anchor to Disabling this checkDisabling this check
This check is safe to disable.