Skip to content

fix: clear quick-win and test-cleanup SonarQube criticals#508

Open
will-yuponce-db wants to merge 1 commit into
mainfrom
fix/sonar-criticals-quickwins
Open

fix: clear quick-win and test-cleanup SonarQube criticals#508
will-yuponce-db wants to merge 1 commit into
mainfrom
fix/sonar-criticals-quickwins

Conversation

@will-yuponce-db

Copy link
Copy Markdown
Contributor

What & why

Follow-up to #507 (blockers). This clears the low-volume, bug-adjacent CRITICAL code smells flagged by SonarQube. The bulk maintainability criticals (S1192 duplicated literals ×309, S3776 cognitive complexity ×279) are intentionally out of scope — they're a separate deliberate refactor effort, not quick wins. No production behavior changes here.

Fixes by rule

python:S5754 — bare except (1)

  • controller/semantic_models_manager.py: a bare except: around KG context removal also swallowed KeyboardInterrupt/SystemExit. Narrowed to except Exception:.

python:S1186 — empty method (1)

  • utils/contract_cloner.py: removed a no-op def __init__(self): pass (class has no base requiring it).

python:S5655 — argument type mismatch (3)
These were flagged in tests that deliberately pass None/UUID to exercise edge cases. Rather than weaken the tests, the input type hints were widened to reflect what the code already accepts:

  • sanitize_uc_identifier(identifier: Optional[str]) — it validates and rejects None with a ValueError.
  • map_logical_type_to_column_type(logical_type: Optional[str]) — it already does (logical_type or '').
  • SemanticLinksManager.remove(link_id: Union[str, UUID]) — passes the id straight to the repo, which the integration test exercises with a UUID.

python:S5727 — identity check always true (11)

  • Redundant assert x is not None on freshly-created objects in unit tests. Removed where a stronger assertion follows (9). For the two test_data_products_manager init tests where it was the sole assertion, replaced with a meaningful degraded-state check (assert manager._ws_client is None / assert manager._notifications_manager is None).

Testing

  • Affected unit tests pass.
  • The 7 pre-existing test_data_products_manager failures (SQLite integrity quirks, DID NOT RAISE) are unchanged from main — verified by stashing this branch's changes and re-running.

SonarQube rescan

Local rescan (9.9.8 LTS) of this branch confirms all four targeted rules drop to 0:

Rule Before After
S5754 1 0
S1186 1 0
S5655 3 0
S5727 11 0
Critical total 612 596

This pull request and its description were written by Isaac.

Targets the low-volume, bug-adjacent CRITICAL code smells (the bulk
S1192/S3776 maintainability work is intentionally left for a separate
effort). No production behavior change.

- python:S5754 (1): semantic_models_manager removed a bare 'except:'
  that also swallowed KeyboardInterrupt/SystemExit -> 'except Exception:'.
- python:S1186 (1): contract_cloner dropped an empty no-op __init__.
- python:S5655 (3): widen input type hints to match what the code
  already accepts, so the existing negative/edge-case tests type-check:
    - sanitize_uc_identifier(identifier: Optional[str]) -- it validates
      and rejects None with a ValueError.
    - map_logical_type_to_column_type(logical_type: Optional[str]) -- it
      already does '(logical_type or "")'.
    - SemanticLinksManager.remove(link_id: Union[str, UUID]) -- it passes
      the id straight to the repo, which the test exercises with a UUID.
- python:S5727 (11): redundant 'assert x is not None' identity checks in
  unit tests. Removed where a stronger assertion follows (9); in the two
  data_products_manager init tests, replaced with a meaningful check on
  the degraded-state attribute (_ws_client / _notifications_manager).

Affected unit tests pass; the 7 pre-existing test_data_products_manager
failures (SQLite integrity quirks) are unchanged from main.

Co-authored-by: Isaac
@will-yuponce-db will-yuponce-db requested a review from a team as a code owner June 8, 2026 16:19

@larsgeorge-db larsgeorge-db left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

lgtm

@larsgeorge-db larsgeorge-db enabled auto-merge (rebase) June 11, 2026 08:08
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.

2 participants