Skip to content

Refactor Analyzers: Unify Range Logic & Optimize Allocations#1464

Merged
ccojocar merged 4 commits intosecurego:masterfrom
oittaa:perf/reduce-allocations-v2
Jan 14, 2026
Merged

Refactor Analyzers: Unify Range Logic & Optimize Allocations#1464
ccojocar merged 4 commits intosecurego:masterfrom
oittaa:perf/reduce-allocations-v2

Conversation

@oittaa
Copy link
Contributor

@oittaa oittaa commented Jan 14, 2026

  • Centralized integer range solving logic in util.go eliminating logic duplication.
  • Optimization & Pooling: Implemented sync.Pool for RangeAnalyzer, BaseAnalyzerState, and analyzer-specific caches.
  • Zero-Alloc Extraction: Replaced expensive regexp and string-based type inspection with direct go/types lookup (GetIntTypeInfo).
  • Covered more cases especially in G407 (hardcoded IV/nonce).

…alize numeric range analysis in util.go (shared by G115/G602).- Implement object pooling for slice_bounds and hardcoded_nonce.- Update conversion_overflow tests to use real analyzer logic.
@codecov-commenter
Copy link

codecov-commenter commented Jan 14, 2026

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

Codecov Report

❌ Patch coverage is 84.69251% with 229 lines in your changes missing coverage. Please review.
✅ Project coverage is 69.20%. Comparing base (1216c9b) to head (4f4401e).
⚠️ Report is 161 commits behind head on master.

Files with missing lines Patch % Lines
analyzers/range_analyzer.go 85.25% 82 Missing and 29 partials ⚠️
analyzers/util.go 81.64% 36 Missing and 13 partials ⚠️
analyzers/hardcoded_nonce.go 87.85% 22 Missing and 12 partials ⚠️
analyzers/slice_bounds.go 78.22% 21 Missing and 6 partials ⚠️
analyzers/conversion_overflow.go 88.88% 4 Missing and 4 partials ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1464      +/-   ##
==========================================
+ Coverage   68.49%   69.20%   +0.70%     
==========================================
  Files          75       80       +5     
  Lines        4384     6098    +1714     
==========================================
+ Hits         3003     4220    +1217     
- Misses       1233     1675     +442     
- Partials      148      203      +55     

☔ 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.

Copy link
Member

@ccojocar ccojocar left a comment

Choose a reason for hiding this comment

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

Are these PRs AI generated? Please could you send small PRs next time, which are only focused on one thing. This make the reviewing easier. Thanks

@ccojocar ccojocar merged commit 7284e15 into securego:master Jan 14, 2026
6 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