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

chore: Remove gomonkey dependency from formatter #1192

Merged
merged 3 commits into from
Apr 29, 2022

Conversation

akojo
Copy link
Contributor

@akojo akojo commented Apr 28, 2022

Describe the PR
Refactor formatter file handling code so that formatter itself and the fmt command-line tool can be tested without using gomonkey.

Implement formatter tests so that they tests against actual pieces of go code with comments. While doing that clean up formatter code so that it's 100% covered by tests.

Relation issue
#1178

Move directory tree walking code from Formatter to format/ package that
handles `fmt` subcommand.
- Handle file open/read/update in format/format.go
- Only handle formatting file contents in formatter.go
- Write tests against formatter public API only
- Clean up formatter code
@akojo
Copy link
Contributor Author

akojo commented Apr 29, 2022

@ubogdan have you seen this one before with CI tests?

# cd .; git clone -- https://go.googlesource.com/lint /home/runner/work/swag/src/golang.org/x/lint
Cloning into '/home/runner/work/swag/src/golang.org/x/lint'...
fatal: unable to access 'https://go.googlesource.com/lint/': The requested URL returned error: 502
package golang.org/x/lint/golint: exit status 128

I couldn't reproduce locally

@codecov
Copy link

codecov bot commented Apr 29, 2022

Codecov Report

Merging #1192 (bbbb6c5) into master (47d5a76) will decrease coverage by 0.32%.
The diff coverage is 95.95%.

@@            Coverage Diff             @@
##           master    #1192      +/-   ##
==========================================
- Coverage   95.03%   94.70%   -0.33%     
==========================================
  Files          10       11       +1     
  Lines        2557     2475      -82     
==========================================
- Hits         2430     2344      -86     
- Misses         69       71       +2     
- Partials       58       60       +2     
Impacted Files Coverage Δ
format/format.go 92.30% <92.30%> (ø)
formatter.go 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 47d5a76...bbbb6c5. Read the comment docs.

@ubogdan
Copy link
Contributor

ubogdan commented Apr 29, 2022

@akojo looks like a temporary issue.

@akojo
Copy link
Contributor Author

akojo commented Apr 29, 2022

Coverage test seems to be failing because decreasing the amount of code lines in the repo brings overall coverage down.

Copy link
Contributor

@ubogdan ubogdan left a comment

Choose a reason for hiding this comment

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

LGTM

@ubogdan ubogdan merged commit 36ae7af into swaggo:master Apr 29, 2022
@ubogdan
Copy link
Contributor

ubogdan commented Apr 29, 2022

@akojo Thanks for your contribution.

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