Better logging for fees - #89
Conversation
There was a problem hiding this comment.
Gates Failed
Prevent hotspot decline
(1 hotspot with Complex Method, Deep, Nested Complexity)
Enforce critical code health rules
(1 file with Deep, Nested Complexity)
Enforce advisory code health rules
(1 file with Complex Method)
Gates Passed
3 Quality Gates Passed
See analysis details in CodeScene
Reason for failure
| Prevent hotspot decline | Violations | Code Health Impact | |
|---|---|---|---|
| js-example.js | 2 rules in this hotspot | 10.00 → 9.10 | Suppress |
| Enforce critical code health rules | Violations | Code Health Impact | |
|---|---|---|---|
| js-example.js | 1 critical rule | 10.00 → 9.10 | Suppress |
| Enforce advisory code health rules | Violations | Code Health Impact | |
|---|---|---|---|
| js-example.js | 1 advisory rule | 10.00 → 9.10 | Suppress |
Quality Gate Profile: Custom Configuration
Want more control? Customize Code Health rules or catch issues early with our IDE extension and CLI tool.
| const itemServiceFee = items[i].quantity * items[i].price * serviceFeeRate; | ||
| if (itemServiceFee > 10) { | ||
| console.log(`Very large service fee: ${itemServiceFee} for ${items[i].name}: ${items[i].quantity} items @ ${items[i].price}`); | ||
| const sortedItems = [...items].map(({quantity, price}) => quantity * price * serviceFeeRate); | ||
| sortedItems.sort((a, b) => a - b); | ||
| let indexOfmatch; | ||
| for (let si = 0; si < sortedItems.length; si++) { | ||
| if (!indexOfMatch && sortedItems[si] === itemServiceFee) { | ||
| indexOfmatch = si; | ||
| } | ||
| } | ||
| console.log(`Very large service fee ${itemServiceFee} rank: ${indexOfMatch}`); | ||
| } | ||
| else if (itemServiceFee > 5) { | ||
| console.log(`Large service fee: ${itemServiceFee} for ${items[i].name}: ${items[i].quantity} items @ ${items[i].price}`); | ||
| } | ||
| else if (itemServiceFee === 0) { | ||
| console.log(`No service fee!?!: ${itemServiceFee} for ${items[i].name}: ${items[i].quantity} items @ ${items[i].price}`); | ||
| } | ||
| else { | ||
| console.log(`Normal service fee: ${itemServiceFee} for ${items[i].name}: ${items[i].quantity} items @ ${items[i].price}`); | ||
| } |
There was a problem hiding this comment.
❌ New issue: Complex Method
calculateTotalWithServiceFee has a cyclomatic complexity of 9, threshold = 9
| const itemServiceFee = items[i].quantity * items[i].price * serviceFeeRate; | ||
| if (itemServiceFee > 10) { | ||
| console.log(`Very large service fee: ${itemServiceFee} for ${items[i].name}: ${items[i].quantity} items @ ${items[i].price}`); | ||
| const sortedItems = [...items].map(({quantity, price}) => quantity * price * serviceFeeRate); | ||
| sortedItems.sort((a, b) => a - b); | ||
| let indexOfmatch; | ||
| for (let si = 0; si < sortedItems.length; si++) { | ||
| if (!indexOfMatch && sortedItems[si] === itemServiceFee) { | ||
| indexOfmatch = si; | ||
| } | ||
| } | ||
| console.log(`Very large service fee ${itemServiceFee} rank: ${indexOfMatch}`); | ||
| } | ||
| else if (itemServiceFee > 5) { | ||
| console.log(`Large service fee: ${itemServiceFee} for ${items[i].name}: ${items[i].quantity} items @ ${items[i].price}`); | ||
| } | ||
| else if (itemServiceFee === 0) { | ||
| console.log(`No service fee!?!: ${itemServiceFee} for ${items[i].name}: ${items[i].quantity} items @ ${items[i].price}`); | ||
| } | ||
| else { | ||
| console.log(`Normal service fee: ${itemServiceFee} for ${items[i].name}: ${items[i].quantity} items @ ${items[i].price}`); | ||
| } |
There was a problem hiding this comment.
❌ New issue: Deep, Nested Complexity
calculateTotalWithServiceFee has a nested complexity depth of 4, threshold = 4
There was a problem hiding this comment.
Gates Failed
Prevent hotspot decline
(1 hotspot with Complex Method, Deep, Nested Complexity)
Enforce critical code health rules
(1 file with Deep, Nested Complexity)
Enforce advisory code health rules
(1 file with Complex Method)
Gates Passed
3 Quality Gates Passed
See analysis details in CodeScene
Reason for failure
| Prevent hotspot decline | Violations | Code Health Impact | |
|---|---|---|---|
| js-example.js | 2 rules in this hotspot | 10.00 → 9.10 | Suppress |
| Enforce critical code health rules | Violations | Code Health Impact | |
|---|---|---|---|
| js-example.js | 1 critical rule | 10.00 → 9.10 | Suppress |
| Enforce advisory code health rules | Violations | Code Health Impact | |
|---|---|---|---|
| js-example.js | 1 advisory rule | 10.00 → 9.10 | Suppress |
Quality Gate Profile: Custom Configuration
Want more control? Customize Code Health rules or catch issues early with our IDE extension and CLI tool.
Might be some added complexity. Let's see what CodeScene thinks!