refactor: reduce cognitive complexity (S3776)#4994
Merged
Conversation
Extract the increment consolidation and base-version application out of the GetIncrements iterator into ConsolidateIncrement and ApplyBaseVersion helpers. Behaviour-preserving. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…xity (S3776) Flatten GetEffectiveConfigurationsRecursive with early yield breaks instead of nested if/else. Behaviour-preserving. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Extract the per-file work from Execute into UpdateAssemblyInfoFile and inline the version strings into their guarded conditionals. Behaviour-preserving. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Extract the per-file work from Execute into UpdateProjectFile (continue becomes return). Behaviour-preserving. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Split Execute into WriteDotEnv / WriteJsonToFile / WriteJsonToConsole helpers and remove the unreachable trailing switch (ShowVariable/Format are both already handled above). Behaviour-preserving. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Extract TryGetDirectories, TryGetFiles and AddFileContents out of CalculateDirectoryContents. Behaviour-preserving (null return mirrors the previous catch-and-continue). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Extract the nested base-version loops into GetNextVersions overloads and an OrderStrategiesWithFallbackLast helper. Behavior-preserving. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…nches (S3776) Extract the merge-ignore collection, cross-branch pruning, and per-group yielding into private helpers. Behavior-preserving. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…3776) Split the increment switch, alternative-version selection, and version building into focused helpers; collapse the duplicated return paths. Behavior-preserving. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…ateOverCommitsRecursive (S3776) Move the cross-iteration cursor into a TraversalState type and split the loop body into ApplyBranchedFromTransition, ProcessCommit, and HandleMergeCommit helpers. Behavior-preserving. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Extract the nested line/column position selection into a flat GetPositionFormat helper. Behavior-preserving. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
… (S3776) Extract the boolean-flag switches into a ParseBooleanArguments helper, mirroring the existing ParseConfigArguments/ParseRemoteArguments pattern. Behavior-preserving. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…hExistsForCurrentBranch (S3776) Extract local canonical name resolution and the create-or-update local branch logic into helpers. Behavior-preserving. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…583) Return (Content, Appended) from ReplaceOrInsertAfterLastAssemblyAttributeOrAppend instead of mutating a ref bool, and OR-accumulate the appended flag at the call sites. Removes the ref-mutation that tripped Sonar's S2583 false positive (condition always false / unreachable code). Behavior-preserving. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Contributor
|
Thank you @arturcic for your contribution! |
Member
Author
|
🎉 This issue has been resolved in version 6.8.0 🎉 Your GitReleaseManager bot 📦🚀 |
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.



Reduces SonarCloud S3776 (cognitive complexity > 15) on several methods, one commit per method. All changes are behaviour-preserving refactors — no logic changes.
MergeCommitOnNonTrunkBase.GetIncrementsConsolidateIncrement/ApplyBaseVersionEffectiveBranchConfigurationFinder.GetEffectiveConfigurationsRecursiveifs into earlyyield breaksAssemblyInfoFileUpdater.ExecuteUpdateAssemblyInfoFileProjectFileUpdater.ExecuteUpdateProjectFileOutputGenerator.ExecuteWriteDotEnv/WriteJsonToFile/WriteJsonToConsole; remove an unreachable trailingswitchMore S3776 fixes will follow on top of this branch (GitVersionCacheKeyFactory, NextVersionCalculator, RepositoryStore, GitPreparer, ArgumentParser, SemanticVersion, MainlineVersionStrategy).
Verification
dotnet build— 0 warnings / 0 errorsdotnet format --verify-no-changes— clean🤖 Generated with Claude Code