Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce complexity in Selector._setSelectorText #51

Merged
merged 7 commits into from
May 14, 2024

Conversation

jaraco
Copy link
Owner

@jaraco jaraco commented May 14, 2024

Reduces mccabe cyclomatic complexity from 88 to 7.

Ref #47

  • Use contextlib.suppress
  • Short circuit and reduce indentation.
  • Extract _prepare_tokens
  • Move the 'New' object into a dataclass.
  • Moved append function into 'New' class.
  • Moved productions into the 'New' class (and constants into their own class).
  • Remove 'else' clauses; none of the 'if' clauses fall through.

@jaraco
Copy link
Owner Author

jaraco commented May 14, 2024

I'm going to ignore the diffcov failures. 9% of the code that was moved isn't covered by tests, which isn't great, but isn't the end of the world either, considering that the logic is meant to be unchanged.

@jaraco jaraco merged commit c24ee15 into main May 14, 2024
23 of 26 checks passed
@jaraco jaraco deleted the feature/refactor-complexity branch May 14, 2024 19:50
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