Skip to content

Better logging for fees - #89

Open
josf wants to merge 2 commits into
masterfrom
josf-introduce-td
Open

Better logging for fees#89
josf wants to merge 2 commits into
masterfrom
josf-introduce-td

Conversation

@josf

@josf josf commented Mar 3, 2025

Copy link
Copy Markdown

Might be some added complexity. Let's see what CodeScene thinks!

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread test/js-example.js
Comment on lines +203 to +224
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}`);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ New issue: Complex Method
calculateTotalWithServiceFee has a cyclomatic complexity of 9, threshold = 9

Suppress

Comment thread test/js-example.js
Comment on lines +203 to +224
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}`);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ New issue: Deep, Nested Complexity
calculateTotalWithServiceFee has a nested complexity depth of 4, threshold = 4

Suppress

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant