Repository navigation
refactor(java): resolve the Sonar findings in the client and the Magic MDK plugin - #2150
Merged
Merged
Conversation
…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>
Contributor
Author
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
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 and why
SonarCloud's analysis of
developreports 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: noNOSONAR, rule exclusion orsonar-project.propertiesedit.java:S1192client/java/.../opensysml/Model.javasymbolResponsepasses the existingNAME_OPTIONSconstant toObjects.requireNonNullinstead of repeating its value.java:S1192editors/mdk/mdk-bridge/.../docgen/BridgeResult.java"elementId"map reads infromgo through a privateELEMENT_IDconstant.java:S1192editors/mdk/plugin/.../bridge/DocGenBridge.java"elementId"map writes in the flattening go through a privateELEMENT_IDconstant.mdk-bridgeandpluginare 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:S1192editors/mdk/plugin/.../actions/OperationActions.javaTITLE_PREFIXconstant ("Magic MDK: "); the resulting strings are unchanged.java:S3358editors/mdk/mdk-bridge/.../docgen/DocBookRenderer.javarowCountreturns"no rows"from a guard and keeps one ternary for the singular/plural suffix:0 → "no rows",1 → "1 row",n → "n rows".java:S3358editors/mdk/plugin/.../results/RunResult.javarename(Row, …)becomes arename(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:S135editors/mdk/plugin/.../engine/QueryResolver.javaparameterstakes its decision frominputParameter(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 withdirection == "in". Iteration order and the set of parameters are unchanged.java:S9395editors/mdk/plugin/.../actions/QueryArguments.java(double) item.value()when an integer token is bound to aRealparameter. The widening is intended:DocumentValue.RealValueholds adouble, so aRealparameter can carry nothing more precise, and integers beyondlongalready arrive asValue.RealValuethroughCalcArguments.value. The cast documents it without changing the value.java:S5961editors/mdk/plugin/src/test/.../PipelineEndToEndTest.javav2TextualRunQuery(29 assertions) is split by stage intov2TextualRunQueryMapsRowsBackToElements,v2TextualRunQueryPlansParameters,v2TextualRunQueryBindsParametersandv2TextualRunQueryReportsWhatItCannotRun(8 + 4 + 9 + 8). Every assertion, message and fixture is kept; the shared fixture load moves to ademo()helper.How it was verified
mvn -B -f client/java/pom.xml install -Dopensysml.requireService=true(JDK 17): 377 + 37 tests, 0 failures; conformanceMain -binary bin/sysml-grpc -protocols connect,connect-json -allow-skipspasses.mvn -B -f editors/mdk/pom.xml verify -Dopensysml.requireService=true: build success, 0 failures (the split tests run inPipelineEndToEndTest);make audit-java JAVA_PROJECT_DIRS=editors/mdk: no advisories.go build ./... && go vet ./... && gofmt -l . && make lintclean;scripts/check-doc-ids.py,scripts/changelog.py check,go test ./tests/hygienepass;go test ./...(no-race) passes exceptTestEmbeddedSnapshotIsCurrent, whose stalestdlib.snapshotpredates this branch (no Go file changes;scripts/ci-changed-areas.sh:java,mdk,syson).Checklist
make testandmake lintpass locally (see above)changes/unreleased/<slug>.<section>.md, not as an edit toCHANGELOG.md— none: an internal refactor with no user-visible change.make docs-countsrun if a gate count moved (compliance rows need nothing: the census is counted at docs build)F4,K5) in the body, docs, or changelog🟢 Devin Review found nothing to fix · View findings