Repository navigation
refactor(semantic): split the model's most involved derivations into one helper per concern - #2153
Open
devin-ai-integration[bot] wants to merge 5 commits into
Open
devin-ai-integration[bot] wants to merge 5 commits into
devin-ai-integration[bot] wants to merge 5 commits into
Conversation
…one helper per concern 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)".
|
devin-ai-integration
Bot
removed this pull request from the merge queue due to a manual request
Nov 12, 2026
This branch has not been deployed
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
developflags seven constructs ininternal/semanticfor cognitive complexity over 30 (go:S3776) and one switch with 37 branches (go:S1479). Each is addressed at the root by extracting one named helper per nested concern; nothing is suppressed, no rule orsonar-project.propertiesmoved, and every evaluation order, early return and derived answer is unchanged.internal/semantic/metamodel/structure_parameters.go(threego:S3776findings)structureBehaviorGenerals: the walk over the implied base features' behavior types moves intostructureImpliedBaseBehaviors; the nested-subsetting exception and theuniqueStructureElementsfold stay where they were.structureParameterTable: the symbol-backed table becomesstructureSymbolParameters, the owned-feature scan (direction, result role, first-result-wins) becomesstructureOwnedParameters, and the claiming of a general's parameters by redefinition clause, position-with-direction, or result role becomesstructureClaimedParameters. The recursion, thevisitingcycle guard and the inherited-parameter append loop remain in the method.structureImplicitParameterRedefinitions: the owning-type reading with its Behavior/Step test becomesstructureBehaviorOwner(keeping the three distinct outcomes: unknown, not behavior-like, behavior-like), and the per-general result-or-positional lookup becomesstructureParameterAt.internal/semantic/semantics/annotations.go(go:S1479)ReflectiveElements' feature switch drops from 37 to 27 branches. Ten data-like cases move to three helpers that run, in the switch's former position, right aftersendElements:featureChainElements(ownedFeatureChaining,featureTarget,crossFeature,chainingFeature; the crossed-chain reading is its owncrossFeatureElements),typeOperandElements(unioningType,intersectingType,differencingType, keyed to theModelmethod each reads) andexpressionElements(argument,referent,function,referencedElement). Each helper reportshandledso an unhandled feature still falls through to the remaining switch — including a non-Feature'sownedFeatureChaining, which the switch previously let fall to the trailing derivations.internal/semantic/semantics/nested.go(go:S3776)familyNestedFQNbecomes the composition offamilyRoleNestedFQN(the keyword-stated roles, composite or not) andfamilyCompositeNestedFQN(the kind-only composite rules), with the role rules still consulted first and the composite rules still gated onu.Composite.internal/semantic/semantics/redefinition.go(go:S3776)implicitParameterTargets: reading the direction and result role from a recorded symbol's facts or the usage's AST, and theskipExplicitrefusal, move intoparameterDirectionOf; the owner, position and general walk is untouched.internal/semantic/semantics/reflective_relationships.go(go:S3776)implicitRelationshipElements: the per-metaclass source/target end answers (specific,general,owningType,owningClassifier,owningFeatureandrelationshipEndFeature) move intoimplicitRelationshipEndElements, keeping the earlier implicit-form dispatch and the empty-versus-underived distinctions.How it was verified
go build ./... && go vet ./... && test -z "$(gofmt -l .)" && make lintpass.go test ./internal/semantic/...,go test ./tests/corpus -run 'TestTrainingExamples|TestPilotCorpora'(after./scripts/download-training-examples.shand./scripts/download-pilot-corpora.sh),make test-quick SHARDS="model export",go test ./tests/hygiene,python3 scripts/check-doc-ids.pyandpython3 scripts/changelog.py checkpass; no ratchet, baseline or golden moved.go run -C tools ./cmd/pilot-apijson-diff -checkreproducesdocs/project/api-json-differential/unchanged.Checklist
make testandmake lintpass locallychanges/unreleased/<slug>.<section>.md, not as an edit toCHANGELOG.mdmake docs-countsrun if a gate count moved (none moved)F4,K5) in the body, docs, or changelogRequested by: @HuiJun
🟢 Devin Review found nothing to fix · View findings