Skip to content

refactor: replace magic numbers with named constants in bodyAllowedForStatus#4529

Merged
appleboy merged 1 commit intogin-gonic:masterfrom
veeceey:fix/issue-4489-magic-numbers
Feb 13, 2026
Merged

refactor: replace magic numbers with named constants in bodyAllowedForStatus#4529
appleboy merged 1 commit intogin-gonic:masterfrom
veeceey:fix/issue-4489-magic-numbers

Conversation

@veeceey
Copy link
Copy Markdown
Contributor

@veeceey veeceey commented Feb 8, 2026

Summary

  • Replace hardcoded 100 and 199 with http.StatusContinue and http.StatusOK in the bodyAllowedForStatus function
  • Uses status >= http.StatusContinue && status < http.StatusOK instead of status >= 100 && status <= 199
  • Consistent with the pattern already used in logger.go line 93

Fixes #4489

Test plan

  • All existing tests pass (go test ./...)
  • bodyAllowedForStatus test cases in context_test.go cover http.StatusProcessing (1xx), http.StatusNoContent, http.StatusNotModified, and http.StatusInternalServerError

…rStatus

Use http.StatusContinue and http.StatusOK instead of hardcoded 100 and
199 for the 1xx informational status range check, consistent with the
pattern already used in logger.go.

Fixes gin-gonic#4489
@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 8, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.01%. Comparing base (3dc1cd6) to head (ce7c8f9).
⚠️ Report is 241 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4529      +/-   ##
==========================================
- Coverage   99.21%   99.01%   -0.21%     
==========================================
  Files          42       46       +4     
  Lines        3182     3038     -144     
==========================================
- Hits         3157     3008     -149     
- Misses         17       21       +4     
- Partials        8        9       +1     
Flag Coverage Δ
?
--ldflags="-checklinkname=0" -tags sonic 99.00% <100.00%> (?)
-tags go_json 98.93% <100.00%> (?)
-tags nomsgpack 98.99% <100.00%> (?)
go-1.18 ?
go-1.19 ?
go-1.20 ?
go-1.21 ?
go-1.24 99.01% <100.00%> (?)
go-1.25 99.01% <100.00%> (?)
macos-latest 99.01% <100.00%> (-0.21%) ⬇️
ubuntu-latest 99.01% <100.00%> (-0.21%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

@appleboy appleboy added this to the v1.12 milestone Feb 13, 2026
@appleboy appleboy closed this Feb 13, 2026
@appleboy appleboy merged commit 488f8c3 into gin-gonic:master Feb 13, 2026
26 of 27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use http.StatusContinue constant instead of 100 for clarity in status code comparison

2 participants