refactor(conformance): reduce cognitive complexity in sdk dispatcher#82
Merged
refactor(conformance): reduce cognitive complexity in sdk dispatcher#82
Conversation
Extract 30+ sub-handler functions into sdkHelpers.ts to bring all 8 S3776 violations (max complexity 71) below the 15-allowed threshold. Removes dead StorageUtils import and redundant odd-hex padding. 6601 conformance vectors continue to pass. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
…lpers Extract helpers to bring functions at L195 (CC 19) and L696 (CC 21) under the cognitive-complexity limit of 15. - merklePathFromBump (CC 19) → split into assertMerklePathStructure, assertTxidMerkleRoots, assertSparseTxidRoots; public function now CC 2 - dispatchNodeTransactionFixture (CC 21) → split into parseTransactionOrReturnInvalid, countRejectedSpends, countOneSpend; public function now CC 3 Co-Authored-By: Claude Opus 4.7 <[email protected]>
ECDSA usage moved to sdkHelpers.ts during the L195/L696 refactor (commit 1b04e0e); the import in sdk.ts is now dead. decodeMessage is exported from sdk.ts but never consumed by sdkHelpers.ts.
|
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.


Summary
Wave 2 cognitive complexity refactor — clear all 8 S3776 violations in
conformance/runner/ts/dispatchers/sdk.ts.dispatchECDSA(was 34): extractedecdsaMessageTooLarge,ecdsaPubkeyInfinity,ecdsaExplicitSignatureVerify,ecdsaBatchMessages,ecdsaWrongPubkey,ecdsaSignAndVerifyintosdkHelpers.tsdispatchMerklePath(was 55): extractedmerklePathLeafPair,merklePathCoinbase,merklePathFromBump,computeMerkleRootFromDisplayTxidsdispatchSerialization(was 55): extractedserializationRawHex,serializationEfHex,serializationBeefHex,serializationBumpHex; post-switch fallthrough collapsed to 4 guard linesdispatchSignature(was 46): extractedsignatureFromPrivkey,signatureFromDer,signatureFromCompactdispatchBSM(was 26): extractedbsmVerifyDer,bsmVerifyCompact,bsmRecoverydispatchEvaluation(was 71): extractedevalWriteBn,evalWriteBnRange,evalFindAndDelete,evalHex,evalBinary,evalP2PKH,evalScriptPubkey,evalDataLengthBytes,evalScriptAsmplus the three node fixture dispatchersdispatchPrivateKey(was 21) anddispatchNodeTransactionFixture(was 21): moved to helpers with no structural change needed — shape already clean after extraction elsewhereStorageUtilsimport (getURLForHash/getHashFromURL/isValidURLwere never used)hexToBytesalready handles it)parseFillBytehelperVerification
node conformance/runner/src/runner.js✅Refs: #38 #44