Skip to content

Fix violations of S3776: Cognitive Complexity of methods is too high - #1750

Merged
bart-vmware merged 2 commits into
mainfrom
fix-S3776-cognitive-complexity
Oct 1, 2026
Merged

bart-vmware merged 2 commits into
mainfrom
fix-S3776-cognitive-complexity

Conversation

@bart-vmware

Copy link
Copy Markdown
Member

Description

Fixes #935.

Quality checklist

  • Your code complies with our Coding Style.
  • You've updated unit and/or integration tests for your change, where applicable.
  • You've updated documentation for your change, where applicable.
    If your change affects other repositories, such as Documentation and/or Samples, add linked PRs here.
  • There's an open issue for the PR that you are making. If you'd like to propose a new feature or change, please open an issue to discuss the change or find an existing issue.
  • You've added required license files and/or file headers (explaining where the code came from with proper attribution), where code is copied from StackOverflow, a blog, or OSS.

@bart-vmware bart-vmware changed the title Fix violations of S3776: Cognitive Complexity of methods too high Fix violations of S3776: Cognitive Complexity of methods is too high Sep 28, 2026
@github-actions

github-actions Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary - All Code Coverage (ubuntu-latest)

Line coverage Branch coverage

Assembly Line coverage Branch coverage
Steeltoe.Bootstrap.AutoConfiguration 97.4% 83.3%
Steeltoe.Common 89.1% 82.2%
Steeltoe.Common.Certificates 95.6% 84.5%
Steeltoe.Common.Hosting 83.5% 65%
Steeltoe.Common.Http 97.4% 80.9%
Steeltoe.Common.Logging 80.6% 56.2%
Steeltoe.Common.Net 64.5% 66.6%
Steeltoe.Configuration.Abstractions 96.3% 89.4%
Steeltoe.Configuration.CloudFoundry 98.4% 92.7%
Steeltoe.Configuration.ConfigServer 91.4% 85.9%
Steeltoe.Configuration.Encryption 97.6% 87.5%
Steeltoe.Configuration.Kubernetes.ServiceBindings 95.6% 82.1%
Steeltoe.Configuration.Placeholder 94% 82.6%
Steeltoe.Configuration.RandomValue 93.2% 83.3%
Steeltoe.Configuration.SpringBoot 98.3% 85%
Steeltoe.Connectors 94.5% 85.2%
Steeltoe.Connectors.EntityFrameworkCore 81% 70.8%
Steeltoe.Discovery.Configuration 96.3% 75%
Steeltoe.Discovery.Consul 91.5% 84.4%
Steeltoe.Discovery.Eureka 90.2% 81.9%
Steeltoe.Discovery.HttpClients 89.9% 91.1%
Steeltoe.Logging.Abstractions 99.4% 95.6%
Steeltoe.Logging.DynamicConsole 100% 92.3%
Steeltoe.Logging.DynamicSerilog 99.1% 95.4%
Steeltoe.Management.Abstractions 100% 100%
Steeltoe.Management.Endpoint 95.9% 87%
Steeltoe.Management.GitProperties.Build 95.2% 83.9%
Steeltoe.Management.Prometheus 96.8% 81.2%
Steeltoe.Management.Tasks 95.2% 80%
Steeltoe.Management.Tracing 100% 75%
Steeltoe.Security.Authentication.JwtBearer 100% 95.6%
Steeltoe.Security.Authentication.OpenIdConnect 87.7% 77.2%
Steeltoe.Security.Authorization.Certificate 96.8% 66.6%
Steeltoe.Security.DataProtection.Redis 100% ****

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

The refactors preserve existing behavior while satisfying the requested analyzer configuration.

Review effort: Balanced
Findings: None

What changed in this PR

Reduces cognitive complexity across Steeltoe while enabling S3776 warnings in Debug and Release builds.

Changes:

  • Extracts focused helper methods from complex routines.
  • Simplifies nested control flow without changing behavior.
  • Enables S3776 as a warning in both rulesets.
File Description
Steeltoe.Release.ruleset Enables S3776 warnings.
Steeltoe.Debug.ruleset Promotes S3776 to warning.
src/​Management/​test/​GitProperties.Build.Test/​PropertiesFile.cs Simplifies property parsing.
src/​Management/​test/​GitProperties.Build.Test/​GitRepositoryBuilder.cs Simplifies directory exclusion.
src/​Management/​src/​Prometheus/​PrometheusExtensions.cs Extracts pipeline configuration.
src/​Management/​src/​GitProperties.Build/​GenerateGitPropertiesCacheTask.cs Extracts cache generation.
src/​Management/​src/​GitProperties.Build/​ComposeGitPropertiesTask.cs Extracts dirty-state handling.
src/​Management/​src/​Endpoint/​ManagementPort/​ManagementPortStartupFilter.cs Extracts binding logic.
src/​Management/​src/​Endpoint/​Actuators/​Info/​Contributors/​GitInfoContributor.cs Extracts property parsing.
src/​Management/​src/​Endpoint/​Actuators/​Hypermedia/​HypermediaService.cs Extracts link generation.
src/​Management/​src/​Endpoint/​Actuators/​DbMigrations/​DbMigrationsEndpointHandler.cs Simplifies null handling.
src/​Discovery/​src/​Eureka/​ValidateEurekaClientOptions.cs Extracts URL validation.
src/​Discovery/​src/​Eureka/​EurekaClient.cs Separates request creation and sending.
src/​Discovery/​src/​Eureka/​Configuration/​EurekaInstanceOptions.cs Separates port updates.
src/​Connectors/​src/​Connectors/​RabbitMQ/​RabbitMQConnectionStringBuilder.cs Extracts query parsing.
src/​Connectors/​src/​Connectors/​MongoDb/​MongoDbConnectionStringBuilder.cs Extracts query parsing.
src/​Connectors/​src/​Connectors/​ConnectionStringPostProcessor.cs Separates binding processing.
src/​Configuration/​src/​Placeholder/​PropertyPlaceHolderHelper.cs Extracts placeholder resolution.
src/​Configuration/​src/​ConfigServer/​ConfigServerDiscoveryService.cs Extracts discovery lookup.
src/​Configuration/​src/​ConfigServer/​ConfigServerConfigurationProvider.cs Extracts data and response handling.
src/​Configuration/​src/​CloudFoundry/​ServiceBindings/​PostProcessors/​CredHubCloudFoundryPostProcessor.cs Simplifies credential processing.
src/​Common/​src/​Common/​Net/​InetUtils.cs Decomposes network-address selection.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/Common/src/Common/Net/InetUtils.cs Resolved
@bart-vmware
bart-vmware marked this pull request as ready for review September 29, 2026 13:28
@bart-vmware
bart-vmware requested a review from TimHess September 29, 2026 13:28
@bart-vmware
bart-vmware force-pushed the fix-S3776-cognitive-complexity branch from 096b74c to ffee631 Compare September 29, 2026 14:34
@bart-vmware bart-vmware added Type/infrastructure ReleaseLine/4.x Identified as a feature/fix for the 4.x release line labels Sep 29, 2026
@bart-vmware bart-vmware added this to the 4.3.1 milestone Sep 29, 2026
Comment thread src/Common/src/Common/Net/InetUtils.cs Resolved
@sonarqubecloud

Copy link
Copy Markdown

@bart-vmware
bart-vmware requested a review from TimHess September 30, 2026 13:08
@bart-vmware
bart-vmware merged commit cc1f1a5 into main Oct 1, 2026
25 checks passed
@bart-vmware
bart-vmware deleted the fix-S3776-cognitive-complexity branch October 1, 2026 08:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ReleaseLine/4.x Identified as a feature/fix for the 4.x release line Type/infrastructure

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Address S3776: Cognitive Complexity of methods should not be too high

3 participants