1. Simplify Nested JavaScript Pricing Logic
Senior Frontend DeveloperBackground
A legacy checkout module contains a pricing function with multiple nested conditionals for discounts and VIP status, making it difficult to unit test and maintain safely.
Problem
The function has hidden complexity and deep nesting that increases bug risk during feature updates, but the exact metrics are unknown.
How to use
Paste the score function code into the Source Code field, select JavaScript as the language, and set the nesting threshold to 2 to catch deep conditional blocks.
{
"language": "javascript",
"longFunctionThreshold": 8,
"nestingThreshold": 2,
"duplicateWindow": 4
}Outcome
Analysis reveals cyclomatic complexity of 5 and flags deep nesting, prompting the team to extract discount logic into separate functions for improved testability and reduced cognitive load.