fix: clear quick-win and test-cleanup SonarQube criticals#508
Open
will-yuponce-db wants to merge 1 commit into
Open
fix: clear quick-win and test-cleanup SonarQube criticals#508will-yuponce-db wants to merge 1 commit into
will-yuponce-db wants to merge 1 commit into
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
Follow-up to #507 (blockers). This clears the low-volume, bug-adjacent CRITICAL code smells flagged by SonarQube. The bulk maintainability criticals (
S1192duplicated literals ×309,S3776cognitive 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— bareexcept(1)controller/semantic_models_manager.py: a bareexcept:around KG context removal also swallowedKeyboardInterrupt/SystemExit. Narrowed toexcept Exception:.python:S1186— empty method (1)utils/contract_cloner.py: removed a no-opdef __init__(self): pass(class has no base requiring it).python:S5655— argument type mismatch (3)These were flagged in tests that deliberately pass
None/UUIDto 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 rejectsNonewith aValueError.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 aUUID.python:S5727— identity check always true (11)assert x is not Noneon freshly-created objects in unit tests. Removed where a stronger assertion follows (9). For the twotest_data_products_managerinit 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
test_data_products_managerfailures (SQLite integrity quirks,DID NOT RAISE) are unchanged frommain— 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:
This pull request and its description were written by Isaac.