Skip to content

refactor: clear Sonar code smells in tests and the UI - #308

Draft
ffroliva wants to merge 1 commit into
mainfrom
chore/sonar-tests-ui
Draft

ffroliva wants to merge 1 commit into
mainfrom
chore/sonar-tests-ui

Conversation

@ffroliva

Copy link
Copy Markdown
Owner

Clears the 55 open SonarCloud code smells in tests/ and ui/, without changing behaviour.

  • python:S5778 (29): setup moves out of pytest.raises, so only the call under test is inside; assertions unchanged.
  • python:S3415, S8997, S5918: operand order, monkeypatch for global state, an explicit pytest.skip when ui/ is absent.
  • typescript:S5906, S4624, S3358, S7780, S7761: toHaveLength, no nested template literals, early returns, String.raw, dataset.
  • typescript:S6551 (2): kept with NOSONAR; the value is unknown and String(x) is the existing behaviour for JSON strings and numbers.
  • src/sharpit/ui/static/ is the rebuilt UI bundle.

sonar-baseline.txt is lowered once the scan reports this pull request's fixed count (after #307).

Verified: ruff check, ruff format --check, pyright clean; touched Python test files 520 passed; vitest 48 files / 363 tests passed; npm run build ok. tsc --noEmit reports the same 3 errors as main (untouched files).

Hoist setup out of pytest.raises blocks, order assertion operands actual-first,
use monkeypatch for the frozen-dataclass check, skip explicitly in the UI
source scan, prefer toHaveLength in vitest, and remove nested ternaries and
nested template literals in the UI library. Rebuilds the committed UI bundle.

Signed-off-by: Flavio Oliva <ffroliva@gmail.com>

This branch has not been deployed

No deployments
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