Skip to content

Conversation

@steindvart
Copy link
Contributor

@steindvart steindvart commented Oct 28, 2025

Problem

Solution - what PR does

  • Comprehensive decomposition of the function (h handler) match(update *models.Update). To reduce cyclomatic complexity, and improve testability.

Now, for handlers.go file, the following indicators apply:

$ gocyclo handlers.go
9 bot getDataFromUpdate handlers.go:72:1
9 bot (handler).match handlers.go:44:1
5 bot (handler).matchCommandStartOnly handlers.go:137:1
4 bot (handler).matchCommand handlers.go:125:1
4 bot extractCommand handlers.go:116:1
3 bot (*Bot).UnregisterHandler handlers.go:205:1
1 bot (*Bot).RegisterHandler handlers.go:186:1
1 bot (*Bot).RegisterHandlerRegexp handlers.go:167:1
1 bot (*Bot).RegisterHandlerMatchFunc handlers.go:149:1
1 bot (handler).matchRegexp handlers.go:112:1
1 bot (handler).matchContains handlers.go:108:1
1 bot (handler).matchPrefix handlers.go:104:1
1 bot (handler).matchExact handlers.go:100:1

Previous:

$ gocyclo handlers.go                                                                                                                                                               
23 bot (handler).match handlers.go:43:1
3 bot (*Bot).UnregisterHandler handlers.go:165:1
1 bot (*Bot).RegisterHandler handlers.go:146:1
1 bot (*Bot).RegisterHandlerRegexp handlers.go:127:1
1 bot (*Bot).RegisterHandlerMatchFunc handlers.go:109:1
  • Achieving 100% branch coverage for the all added code.
  • Achieving 100% test coverage for the handlers.go file.
image

@codecov-commenter
Copy link

codecov-commenter commented Oct 28, 2025

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 47.85%. Comparing base (1efca4f) to head (ddec830).
⚠️ Report is 1 commits behind head on main.
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #222      +/-   ##
==========================================
+ Coverage   45.30%   47.85%   +2.54%     
==========================================
  Files          29       29              
  Lines        2355     2123     -232     
==========================================
- Hits         1067     1016      -51     
+ Misses       1241     1063     -178     
+ Partials       47       44       -3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

Reduce cyclomatic complexity in handler.match() (handlers.go, line 43)

2 participants