Skip to content

Refactor main() function to reduce its Cognitive Complexity#2913

Open
MeriemBchini wants to merge 2 commits into
sherlock-project:masterfrom
MeriemBchini:refactor-reduce-cognitive-complexity-main
Open

Refactor main() function to reduce its Cognitive Complexity#2913
MeriemBchini wants to merge 2 commits into
sherlock-project:masterfrom
MeriemBchini:refactor-reduce-cognitive-complexity-main

Conversation

@MeriemBchini
Copy link
Copy Markdown

Refactor: Reduce Cognitive Complexity of main()

Problem

The main() function had a Cognitive Complexity of 93 (Sonar rule S3776), making it hard to maintain and understand.

Solution

  • Split logic into smaller helper functions:
    • parse_arguments
    • load_sites
    • filter_sites
    • expand_usernames
    • write_txt / write_csv / write_xlsx
  • Reduced nesting and improved readability
  • Preserved all original functionality

Result

  • Cognitive Complexity reduced to < 15
  • Improved maintainability and testability

Notes

No functional changes introduced.

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.

1 participant