Skip to content

refactor existing code to reduce cognitive complexity to 15#599

Merged
ziagham merged 4 commits intoflowsynx:masterfrom
lerrxws:refactor/597-configure-kestrel-endpoints
Oct 28, 2025
Merged

refactor existing code to reduce cognitive complexity to 15#599
ziagham merged 4 commits intoflowsynx:masterfrom
lerrxws:refactor/597-configure-kestrel-endpoints

Conversation

@lerrxws
Copy link
Copy Markdown
Contributor

@lerrxws lerrxws commented Oct 28, 2025

What type of PR is this? (check all applicable)

  • Refactor
  • Feature
  • Bug Fix
  • Optimization
  • Documentation Update

Description

Refactored the method to reduce cognitive complexity to ≤15 by simplifying nested logic and improving code readability.
Key changes include:

  • Extracted deeply nested if statements into smaller, dedicated private methods to make the main method more linear and focused.
  • Applied early returns (guard clauses) to handle invalid or edge cases immediately and reduce nesting depth.
  • Added null checks inside helper methods to ensure that required arguments (e.g., configuration or certificate objects) are always valid before proceeding.
  • Improved code clarity and maintainability without changing the external behavior of the system.

Issue reference

#597

Closes #

Checklist

Please make sure you've completed the relevant tasks for this PR, out of the following list:

  • Code compiles correctly
  • Created/updated tests
  • Unit tests passing
  • End-to-end tests passing
  • Extended the documentation / Created issue in flowsynx/website#
  • Specification has been updated / Created issue in flowsynx/website#
  • Provided sample for the feature / Created issue in flowsynx/website#

@lerrxws lerrxws requested review from a team as code owners October 28, 2025 16:25
Copy link
Copy Markdown
Contributor

@Sakeeb91 Sakeeb91 left a comment

Choose a reason for hiding this comment

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

Findings

  • Blocker (docs): .gitignore now ignores tests/FlowSynx.UnitTests/. Any future edits to the unit test project will be hidden locally, making it impossible to update or add tests. Remove this entry before merging.
  • Blocker (docs): The newly added .gitignore pattern ignores every .gitignore file across the repo. This prevents contributors from adding scoped ignore files (e.g., in plugin folders). Drop this line.

Tests

  • dotnet test (passes; only existing warnings appear)

Recommendation

Keep the Kestrel refactor, but revert the .gitignore additions (move personal exclusions to a global/local ignore) before merge.

Copy link
Copy Markdown
Member

@ziagham ziagham left a comment

Choose a reason for hiding this comment

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

Please review and resolve the comments.

.gitignore Outdated
**/flowsynxresults/ No newline at end of file
**/flowsynxresults/

# Personal settings file for FlowSynx
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It seems this commit includes unintended or incorrect modifications to the .gitignore file. Please revert those changes and ensure that no updates are committed to this file.

}

listenOptions.UseHttps(cert.Path, cert.Password);
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The changes look good.

@ziagham
Copy link
Copy Markdown
Member

ziagham commented Oct 28, 2025

@Sakeeb91
Please go ahead with the review 👍

@sonarqubecloud
Copy link
Copy Markdown

@lerrxws
Copy link
Copy Markdown
Contributor Author

lerrxws commented Oct 28, 2025

@ziagham
Sorry about that — I didn’t notice that I accidentally committed my .gitignore file.
I’ve reverted everything back, please check if it looks okay now.

@ziagham
Copy link
Copy Markdown
Member

ziagham commented Oct 28, 2025

@lerrxws
Now it's Ok. When @Sakeeb91 accepts the changes, it will be merged.

Copy link
Copy Markdown
Contributor

@Sakeeb91 Sakeeb91 left a comment

Choose a reason for hiding this comment

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

@ziagham

  • FOSSA check: The GitHub FOSSA gate is still red because the scan does not receive credentials on forked PRs. The job fails with the usual missing-token error (FOSSA_API_KEY is unavailable for forks). Maintainers will need to rerun the scan after merging or push a branch inside the org to let the check succeed.

Tests

  • dotnet test (passes; same warnings as on main)

Recommendation

Safe to merge once a maintainer reruns/overrides the external FOSSA compliance check. No additional code changes required.

@ziagham ziagham merged commit c70f7cd into flowsynx:master Oct 28, 2025
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants