Skip to content

refactor(java): resolve the Sonar findings in the client and the Magic MDK plugin - #2150

Merged
HuiJun merged 2 commits into
developfrom
refactor/sonar-java
Nov 12, 2026
Merged

HuiJun merged 2 commits into
developfrom
refactor/sonar-java

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

What and why

SonarCloud's analysis of develop reports nine open findings in the Java client and the Magic MDK plugin. Each is fixed at the construct it flags, with no behaviour change and no suppression: no NOSONAR, rule exclusion or sonar-project.properties edit.

Rule File Fix
java:S1192 client/java/.../opensysml/Model.java symbolResponse passes the existing NAME_OPTIONS constant to Objects.requireNonNull instead of repeating its value.
java:S1192 editors/mdk/mdk-bridge/.../docgen/BridgeResult.java The three "elementId" map reads in from go through a private ELEMENT_ID constant.
java:S1192 editors/mdk/plugin/.../bridge/DocGenBridge.java The three "elementId" map writes in the flattening go through a private ELEMENT_ID constant. mdk-bridge and plugin are separate Maven modules and the plugin does not depend on the bridge, so each side names the wire key once rather than sharing a constant across modules.
java:S1192 editors/mdk/plugin/.../actions/OperationActions.java The three progress-dialog titles build on a TITLE_PREFIX constant ("Magic MDK: "); the resulting strings are unchanged.
java:S3358 editors/mdk/mdk-bridge/.../docgen/DocBookRenderer.java rowCount returns "no rows" from a guard and keeps one ternary for the singular/plural suffix: 0 → "no rows", 1 → "1 row", n → "n rows".
java:S3358 editors/mdk/plugin/.../results/RunResult.java The cell lambda in rename(Row, …) becomes a rename(Cell, …) helper: a cell without an element id is returned as is; otherwise its text follows the renaming only when it equals the element id, and the element id is always renamed.
java:S135 editors/mdk/plugin/.../engine/QueryResolver.java The loop in parameters takes its decision from inputParameter(model, member, named), which returns the member's symbol when the member is not a library member, its name has not been seen (named.add, still evaluated in loop order so the first declaration wins) and the symbol exists with direction == "in". Iteration order and the set of parameters are unchanged.
java:S9395 editors/mdk/plugin/.../actions/QueryArguments.java (double) item.value() when an integer token is bound to a Real parameter. The widening is intended: DocumentValue.RealValue holds a double, so a Real parameter can carry nothing more precise, and integers beyond long already arrive as Value.RealValue through CalcArguments.value. The cast documents it without changing the value.
java:S5961 editors/mdk/plugin/src/test/.../PipelineEndToEndTest.java v2TextualRunQuery (29 assertions) is split by stage into v2TextualRunQueryMapsRowsBackToElements, v2TextualRunQueryPlansParameters, v2TextualRunQueryBindsParameters and v2TextualRunQueryReportsWhatItCannotRun (8 + 4 + 9 + 8). Every assertion, message and fixture is kept; the shared fixture load moves to a demo() helper.

How it was verified

  • mvn -B -f client/java/pom.xml install -Dopensysml.requireService=true (JDK 17): 377 + 37 tests, 0 failures; conformance Main -binary bin/sysml-grpc -protocols connect,connect-json -allow-skips passes.
  • mvn -B -f editors/mdk/pom.xml verify -Dopensysml.requireService=true: build success, 0 failures (the split tests run in PipelineEndToEndTest); make audit-java JAVA_PROJECT_DIRS=editors/mdk: no advisories.
  • go build ./... && go vet ./... && gofmt -l . && make lint clean; scripts/check-doc-ids.py, scripts/changelog.py check, go test ./tests/hygiene pass; go test ./... (no -race) passes except TestEmbeddedSnapshotIsCurrent, whose stale stdlib.snapshot predates this branch (no Go file changes; scripts/ci-changed-areas.sh: java, mdk, syson).
  • Dry merge against feat(qvts): write a query's answer as a QVTS::QueryResult view on every query surface #2116 (touches five of these files): every shared Java file auto-merges.

Checklist

  • make test and make lint pass locally (see above)
  • Tests added or updated for the change
  • Documentation extended where it already covers the surface (see CONTRIBUTING.md)
  • Changelog entry added as changes/unreleased/<slug>.<section>.md, not as an edit to CHANGELOG.md — none: an internal refactor with no user-visible change.
  • baselines regenerated and make docs-counts run if a gate count moved (compliance rows need nothing: the census is counted at docs build)
  • No internal work-item labels (waves, slices, F4, K5) in the body, docs, or changelog

🟢 Devin Review found nothing to fix · View findings

Devin Review

…c MDK plugin

Reuse Model.NAME_OPTIONS for the options null-message, name the "elementId" key once in BridgeResult and DocGenBridge and the "Magic MDK: " title prefix once in OperationActions, flatten the nested ternaries in DocBookRenderer.rowCount and RunResult.rename into a guard and a Cell helper, let QueryResolver.parameters take its skip-or-keep decision from a helper returning the input parameter's symbol, make the long-to-double widening of an integer bound to a Real parameter explicit, and split PipelineEndToEndTest.v2TextualRunQuery into one test per stage it asserts.

Co-Authored-By: jason.han <hanhuijun@gmail.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

@HuiJun
HuiJun added this pull request to the merge queue Nov 12, 2026
Merged via the queue into develop with commit efdb07b Nov 12, 2026
34 of 44 checks passed
@HuiJun
HuiJun deleted the refactor/sonar-java branch November 12, 2026 01:55
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