Skip to content

add nested complexity - #72

Open
knorrest wants to merge 1 commit into
masterfrom
minor-degradation
Open

add nested complexity#72
knorrest wants to merge 1 commit into
masterfrom
minor-degradation

Conversation

@knorrest

@knorrest knorrest commented Jan 5, 2023

Copy link
Copy Markdown
Contributor

Change-Id: I9eda989f7f0f13210bc66932a50455345c02eb7a

@knorrest
knorrest force-pushed the minor-degradation branch 3 times, most recently from 17d0513 to 149c692 Compare January 5, 2023 10:46

@kalletest kalletest Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Quality Gates: OK

  • Declining Code Health: 1 findings(s) 🚩
  • Improving Code Health: 0 findings(s) ✅
  • Affected Hotspots: 1 files(s) 🔥

Recommended Review Level: Inconclusive -- Not enough commits to recommend a review strategy. The recommendation will be enabled automatically once you have more development activity.
View detailed results in CodeScene

🚩 Negative Code Health Impact (highest to lowest):

@kalletest kalletest Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Quality Gates: OK

  • Declining Code Health: 1 findings(s) 🚩
  • Improving Code Health: 0 findings(s) ✅
  • Affected Hotspots: 1 files(s) 🔥

Recommended Review Level: Inconclusive -- Not enough commits to recommend a review strategy. The recommendation will be enabled automatically once you have more development activity.
View detailed results in CodeScene

🚩 Negative Code Health Impact (highest to lowest):

@knorrest knorrest closed this Feb 24, 2023
@knorrest knorrest reopened this Feb 24, 2023
@knorrest knorrest closed this Feb 24, 2023
@knorrest knorrest reopened this Feb 24, 2023
@knorrest knorrest closed this Feb 24, 2023
@knorrest knorrest reopened this Feb 24, 2023

@kalletest kalletest Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Quality Gates: FAILED

  • Declining Code Health: 1 findings(s) 🚩
  • Improving Code Health: 0 findings(s) ✅
  • Affected Hotspots: 1 files(s) 🔥

Recommended Review Level: Inconclusive -- Not enough commits to recommend a review strategy. The recommendation will be enabled automatically once you have more development activity.
View detailed results in CodeScene

🚩 Negative Code Health Impact (highest to lowest):

Comment thread test/js-example.js
Comment on lines +169 to +187
function mark_purchased(transaction) {
transaction.state = TransactionState.PURCHASED
for (item in transaction.items) {
if (item.mtb_product_ids) {
if (item.mtb_product_ids) {
for (mp_id in item.mtb_product_ids) {
try {
mtb_prod = get_db_mtb_product(None, mp_id, all=True, refresh=False)
mtb_prod.purchased = True
mtb_prod.save()
}
catch(exc) {
logger.error("Failed to mark mtb_product {mp_id} as purchase", exc_info=exc)
}
}
}
}
}
} No newline at end of file

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 Impact on Code Health Score -0.5 (-0.5 in this PR)
mark_purchased has a nested complexity depth of 4, threshold = 4

Why does this problem occur?

This function contains deeply nested logic such as if statements and/or loops. The deeper the nesting, the lower the code health. Read more.

To ignore this warning click here.

@knorrest

Copy link
Copy Markdown
Contributor Author

/cs-agent skill:fix-code-health-degradations

@github-actions

github-actions Bot commented May 20, 2026

Copy link
Copy Markdown

CodeScene Refactoring Agent

✅ Completed

Summary

Fixed 2 Code Health degradations introduced in test/js-example.js.
Code Health improved from 9.09 → 10.0. Quality gate: passed.

Changes

  • Analyze change set — 2 degradations found in test/js-example.js (Deep Nested Complexity in mark_purchased, Excess Function Arguments in extractEvents)
  • Review flagged files — mark_purchased (nesting depth 4), extractEvents (7 arguments)
  • Apply fixes — grouped extractEvents args into ExtractEventsArgs type; extracted mark_mtb_product_purchased helper and removed duplicate if-guard
  • Verify improvements — Code Health 9.09 → 10.0, quality gates passed

Commits

ed70613 - refactor(js-example): fix Code Health degradations in extractEvents and mark_purchased


Finished at 2026-05-20 11:45:59 UTC

codescene-staging[bot]

This comment was marked as outdated.

@knorrest
knorrest force-pushed the minor-degradation branch from ed70613 to 6e5c9bf Compare May 22, 2026 07:47
@knorrest

Copy link
Copy Markdown
Contributor Author

/cs-agent skill:fix-code-health-degradations

codescene-staging[bot]

This comment was marked as outdated.

@github-actions

github-actions Bot commented May 22, 2026

Copy link
Copy Markdown

CodeScene Refactoring Agent

❌ Failed

Progress

  • Analyze change set — ⚠️ CodeScene access token is invalid or expired
  • Apply fixes

Failed at 2026-05-22 07:49:23 UTC

codescene-delta-analysis[bot]

This comment was marked as outdated.

@knorrest

Copy link
Copy Markdown
Contributor Author

/cs-agent skill:fix-code-health-degradations

@github-actions

github-actions Bot commented May 22, 2026

Copy link
Copy Markdown

CodeScene Refactoring Agent

✅ Completed

Summary

Fixed code health degradation in test/js-example.js introduced by the mark_purchased function.

Issues fixed:

  • Deep, Nested Complexity: extracted inner loop body into mark_mtb_products_purchased helper function, reducing nesting from 4 levels to 2 in each function
  • Duplicate Condition: removed redundant duplicate if (item.mtb_product_ids) check

Changes

  • Analyze change set — 1 file changed: test/js-example.js with mark_purchased function
  • Review flagged file — deep nesting (4 levels) and duplicate condition identified
  • Apply fixes — extracted helper function, removed duplicate condition
  • Verify improvements — nesting reduced from 4 to max 2 levels per function

Commits

1d39f58 - refactor: fix deep nesting and duplicate condition in mark_purchased


Finished at 2026-05-22 07:59:18 UTC

codescene-delta-analysis[bot]

This comment was marked as outdated.

codescene-staging[bot]

This comment was marked as outdated.

@knorrest
knorrest force-pushed the minor-degradation branch from 1d39f58 to 6e5c9bf Compare May 22, 2026 08:14
@knorrest

Copy link
Copy Markdown
Contributor Author

/cs-agent skill:fix-code-health-degradations

@github-actions

github-actions Bot commented May 22, 2026

Copy link
Copy Markdown

CodeScene Refactoring Agent

✅ Completed

Summary

Fixed code health degradations in test/js-example.js introduced by the mark_purchased function.

Issues fixed:

  • Removed duplicate if (item.mtb_product_ids) condition (Bumpy Road Ahead)
  • Extracted try/catch block into mark_mtb_product_purchased helper to reduce nesting from 4 to 2 levels (Deep Nested Complexity)

Changes

  • Analyze change set — deep nested complexity and duplicate condition in mark_purchased (test/js-example.js)
  • Review flagged file — confirmed 2 smells: Deep Nested Complexity and Bumpy Road (duplicate if)
  • Apply fixes — extracted helper function, removed duplicate conditional
  • Verify improvements — nesting reduced from 4 to 2 levels, duplicate condition removed

Commits

5dec9e7 - refactor(mark_purchased): fix deep nesting and duplicate condition


Finished at 2026-05-22 08:21:08 UTC

codescene-delta-analysis[bot]

This comment was marked as outdated.

@codescene-delta-analysis

Copy link
Copy Markdown

/cs-agent skill:fix-code-health-degradations

@github-actions

github-actions Bot commented May 28, 2026

Copy link
Copy Markdown

CodeScene Refactoring Agent

✅ Completed

Summary

test/js-example.js improved from 9.09 to 10.0 (Optimal Code).
Fixed 2 newly introduced degradations: Excess Number of Function Arguments in extractEvents and Deep Nested Complexity in mark_purchased.

Changes

  • Analyze change set — 2 degradations in test/js-example.js (Deep Nested Complexity, Excess Function Arguments)
  • Apply fixes — introduced EventContext type object to reduce extractEvents args (7→1); extracted mark_mtb_products_purchased helper to flatten nesting in mark_purchased
  • Verify improvements — Code Health 9.09 → 10.0, quality gates passed

Commits

f554d1d - refactor: fix code health degradations in js-example.js


Finished at 2026-05-28 15:46:16 UTC

codescene-staging[bot]

This comment was marked as outdated.

codescene-staging[bot]

This comment was marked as outdated.

codescene-delta-analysis[bot]

This comment was marked as outdated.

@knorrest
knorrest force-pushed the minor-degradation branch from f554d1d to 764438c Compare May 28, 2026 16:42
codescene-delta-analysis[bot]

This comment was marked as outdated.

codescene-staging[bot]

This comment was marked as outdated.

@codescene-delta-analysis

Copy link
Copy Markdown

/cs-agent skill:fix-code-health-degradations

@github-actions

github-actions Bot commented May 29, 2026

Copy link
Copy Markdown

CodeScene Refactoring Agent

✅ Completed

Summary

Fixed 2 code health degradations in test/js-example.js.
Code Health improved from 9.09 to 10.0 (Optimal).

Changes

  • Analyze change set — 2 degradations found in test/js-example.js (Deep Nested Complexity, Excess Function Arguments)
  • Review flagged files — extractEvents had 7 args; mark_purchased had nesting depth 4
  • Apply fixes — introduced ExtractEventsOptions type; extracted mark_mtb_products_purchased helper
  • Verify improvements — Code Health 9.09 → 10.0, all quality gates passed

Commits

b00ca82 - refactor: fix code health degradations in js-example.js


Finished at 2026-05-29 06:46:07 UTC

codescene-staging[bot]

This comment was marked as outdated.

codescene-delta-analysis[bot]

This comment was marked as outdated.

@knorrest
knorrest force-pushed the minor-degradation branch from b00ca82 to 764438c Compare May 29, 2026 07:46
codescene-delta-analysis[bot]

This comment was marked as outdated.

@codescene-delta-analysis

Copy link
Copy Markdown

/cs-agent skill:fix-code-health-degradations

@github-actions

github-actions Bot commented May 29, 2026

Copy link
Copy Markdown

CodeScene Refactoring Agent

✅ Completed

Summary

Fixed 2 Code Health degradations in test/js-example.js.
Score improved from 9.09 → 10.0 (Optimal Code).

Changes

  • Analyze change set — 2 degradations found in test/js-example.js (Deep Nested Complexity in mark_purchased, Excess Function Arguments in extractEvents)
  • Apply fixes — grouped extractEvents params into ExtractEventsParams type object; extracted mark_mtb_products_purchased helper to reduce nesting depth
  • Verify improvements — quality gates passed, Code Health 9.09 → 10.0

Commits

48eca5a - refactor(js-example): fix code health degradations in extractEvents and mark_purchased


Finished at 2026-05-29 07:50:39 UTC

codescene-staging[bot]

This comment was marked as outdated.

codescene-staging[bot]

This comment was marked as outdated.

codescene-delta-analysis[bot]

This comment was marked as outdated.

Change-Id: I9eda989f7f0f13210bc66932a50455345c02eb7a
@knorrest
knorrest force-pushed the minor-degradation branch from 48eca5a to 7d5b3bc Compare May 29, 2026 09:14
codescene-delta-analysis[bot]

This comment was marked as outdated.

codescene-staging[bot]

This comment was marked as outdated.

@codescene-delta-analysis

Copy link
Copy Markdown

/cs-agent skill:fix-code-health-degradations

@github-actions

github-actions Bot commented May 29, 2026

Copy link
Copy Markdown

CodeScene Refactoring Agent

✅ Completed

Summary

Fixed 2 newly introduced Code Health degradations in test/js-example.js.
Code Health improved from 9.09 → 10.0 (Optimal).

Changes

  • Analyze change set — 2 degradations found in test/js-example.js (Deep Nested Complexity, Excess Function Arguments)
  • Review flagged files — mark_purchased (nesting depth 4) and extractEvents (7 args)
  • Apply fixes — extracted params type for extractEvents; extracted mark_mtb_products_purchased helper and removed duplicate if-guard
  • Verify improvements — Code Health 9.09 → 10.0, all quality gates passed

Commits

4280c30 - refactor: fix code health degradations in js-example.js


Finished at 2026-05-29 09:18:28 UTC · Detailed steps? View logs

codescene-staging[bot]

This comment was marked as outdated.

@knorrest
knorrest force-pushed the minor-degradation branch from 4280c30 to 7d5b3bc Compare June 4, 2026 09:15

@codescene-access codescene-access Bot left a comment

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
Enforce critical code health rules (1 file with Deep, Nested Complexity)

Fix Code Health degradations ℹ️

Gates Passed
4 Quality Gates Passed

Reason for failure
Enforce critical code health rules Violations Code Health Impact
js-example.js 1 critical rule 9.69 → 9.10 Suppress

See analysis details in CodeScene

Quality Gate Profile: Pay Down Tech Debt
Install CodeScene MCP: safeguard and uplift AI-generated code. Catch issues early with our IDE extension and CLI tool.

Comment thread test/js-example.js
Comment on lines +169 to +187
function mark_purchased(transaction) {
transaction.state = TransactionState.PURCHASED
for (item in transaction.items) {
if (item.mtb_product_ids) {
if (item.mtb_product_ids) {
for (mp_id in item.mtb_product_ids) {
try {
mtb_prod = get_db_mtb_product(None, mp_id, all=True, refresh=False)
mtb_prod.purchased = True
mtb_prod.save()
}
catch(exc) {
logger.error("Failed to mark mtb_product {mp_id} as purchase", exc_info=exc)
}
}
}
}
}
} No newline at end of file

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
mark_purchased has a nested complexity depth of 4, threshold = 4

Suppress

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