Skip to content

Comments

refactor(context): use http.StatusContinue constant instead of magic number 100#4542

Open
mehrdadbn9 wants to merge 3 commits intogin-gonic:masterfrom
mehrdadbn9:fix/issue-4489-use-status-continue-final-v3
Open

refactor(context): use http.StatusContinue constant instead of magic number 100#4542
mehrdadbn9 wants to merge 3 commits intogin-gonic:masterfrom
mehrdadbn9:fix/issue-4489-use-status-continue-final-v3

Conversation

@mehrdadbn9
Copy link

Replace magic number `100` with `http.StatusContinue` constant for better code clarity and maintainability in `bodyAllowedForStatus` function.

Fixes #4489

@codecov
Copy link

codecov bot commented Feb 18, 2026

Codecov Report

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

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4542      +/-   ##
==========================================
+ Coverage   99.21%   99.27%   +0.06%     
==========================================
  Files          42       46       +4     
  Lines        3182     3038     -144     
==========================================
- Hits         3157     3016     -141     
+ Misses         17       15       -2     
+ Partials        8        7       -1     
Flag Coverage Δ
?
--ldflags="-checklinkname=0" -tags sonic 99.27% <ø> (?)
-tags go_json 99.13% <ø> (?)
-tags nomsgpack 99.19% <ø> (?)
go-1.18 ?
go-1.19 ?
go-1.20 ?
go-1.21 ?
go-1.24 99.27% <ø> (?)
go-1.25 99.21% <ø> (?)
go-1.26 99.21% <ø> (?)
macos-latest 99.21% <ø> (-0.01%) ⬇️
ubuntu-latest 99.27% <ø> (+0.06%) ⬆️

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.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request refactors the bodyAllowedForStatus function in context.go to replace the magic number 100 with the http.StatusContinue constant for better code clarity. Additionally, the PR includes extensive test coverage improvements across multiple files.

Changes:

  • Replaced magic number 100 with http.StatusContinue constant in bodyAllowedForStatus function
  • Added comprehensive test coverage for multiple functions across the codebase
  • Added new test file for codec/json package

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
context.go Replaced magic number 100 with http.StatusContinue constant and added clarifying comment
context_test.go Added tests for http.StatusContinue, GetRawData with nil body, SameSiteDefaultMode cookie behavior, multipart form errors, and binding edge cases
utils_test.go Added test for successful XML marshaling of H type
logger_test.go Added test case for 400ms latency color
gin_test.go Added tests for error handling in ServeHTTP
codec/json/json_test.go New test file covering JSON codec API functions
binding/binding_test.go Added test for Plain binding BindBody method

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@mehrdadbn9 mehrdadbn9 force-pushed the fix/issue-4489-use-status-continue-final-v3 branch 4 times, most recently from 10e6086 to 96185ac Compare February 21, 2026 19:39
…number 100

Replace magic number 100 with http.StatusContinue constant for better
code clarity and maintainability in bodyAllowedForStatus function.

Also fix typo in logger_test.go: colorForLantency -> colorForLatency

Fixes gin-gonic#4489
@mehrdadbn9 mehrdadbn9 force-pushed the fix/issue-4489-use-status-continue-final-v3 branch from 46fc8ad to 65c72a8 Compare February 21, 2026 20:11
- Add TestContextGetRawDataNilBody to cover nil body error case
- Add SameSiteDefaultMode test case in SetCookieData
- Add 400ms latency test case for LatencyColor
- Add TestMarshalXMLforHSuccess for successful XML marshaling

Coverage improved from 99.1% to 99.2%
@mehrdadbn9 mehrdadbn9 force-pushed the fix/issue-4489-use-status-continue-final-v3 branch from 54bfc38 to 7df2142 Compare February 21, 2026 20:42
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