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

Refactor newRequest function to remove error return value #312

Merged
merged 1 commit into from
Mar 8, 2024

Conversation

s4s7
Copy link
Contributor

@s4s7 s4s7 commented Mar 7, 2024

Summary

This PR refactors the newRequest function in the Swagger HTTP client to remove the error return value, as it is unnecessary. The function does not perform any operations that can result in an error, so the error return value has been removed for simplicity and clarity.

Changes

  • Removed the error return value from the newRequest function signature.
  • Modified associated tests to reflect changes in the newRequest function.

Before:

func newRequest(method, pathPattern string, writer runtime.ClientRequestWriter) (*request, error) {
	return &request{
		pathPattern: pathPattern,
		method:      method,
		writer:      writer,
		header:      make(http.Header),
		query:       make(url.Values),
		timeout:     DefaultTimeout,
		getBody:     getRequestBuffer,
	}, nil
}

After:

func newRequest(method, pathPattern string, writer runtime.ClientRequestWriter) *request {
	return &request{
		pathPattern: pathPattern,
		method:      method,
		writer:      writer,
		header:      make(http.Header),
		query:       make(url.Values),
		timeout:     DefaultTimeout,
		getBody:     getRequestBuffer,
	}
}

Rationale

Removing the error return value simplifies the function signature and makes it clear that the function does not generate any errors that need to be handled. This change enhances the readability and maintainability of the code.

@s4s7 s4s7 force-pushed the feature/refactor-newRequest-func branch from e81bb74 to 1cc63fa Compare March 7, 2024 15:17
Copy link

codecov bot commented Mar 8, 2024

Codecov Report

Attention: Patch coverage is 66.66667% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 81.88%. Comparing base (91a8d68) to head (1cc63fa).
Report is 8 commits behind head on master.

Files Patch % Lines
client/runtime.go 50.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #312      +/-   ##
==========================================
+ Coverage   81.67%   81.88%   +0.20%     
==========================================
  Files          49       49              
  Lines        4066     3351     -715     
==========================================
- Hits         3321     2744     -577     
+ Misses        632      495     -137     
+ Partials      113      112       -1     
Flag Coverage Δ
1.19 81.88% <66.66%> (+0.20%) ⬆️
oldstable 81.88% <66.66%> (+0.20%) ⬆️
stable 81.88% <66.66%> (+0.20%) ⬆️

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.

@youyuanwu youyuanwu merged commit 424b9cb into go-openapi:master Mar 8, 2024
13 of 14 checks passed
@s4s7 s4s7 deleted the feature/refactor-newRequest-func branch March 8, 2024 08:06
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.

2 participants