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

feat: support PrintTextf and PrintErrorf on Reporter #706

Merged
merged 6 commits into from
Dec 27, 2023
Merged

feat: support PrintTextf and PrintErrorf on Reporter #706

merged 6 commits into from
Dec 27, 2023

Conversation

G-Rath
Copy link
Collaborator

@G-Rath G-Rath commented Dec 16, 2023

When I originally implemented Reporter, IDEs such as GoLand didn't support custom Printf functions so I stuck with plain methods and did the fmt formatting on the string; that's changed as of GoLand 2023.3 via GO-5841 🎉

Technically adding to Reporter is a breaking change but as covered in this comment:

I believe there are no other implementations (at least public on github, from a quick code search) of this interface, and there are no good use cases for implementing this manually instead of using one of the preset implementations we provide.

Either way I think it's better to land these ASAP to reduce the blast radius then to carry them around for possibly a lot longer - note that I'm not strictly against deprecating/removing PrintText and PrintError though I don't think there's a lot of value in keeping them.

As penance, I've also added rich method comments for the interface.

(having said that, since this is a breaking change already maybe we should just remove PrintText and PrintError right now)

@codecov-commenter
Copy link

codecov-commenter commented Dec 16, 2023

Codecov Report

Attention: 65 lines in your changes are missing coverage. Please review.

Comparison is base (86cf40f) 78.88% compared to head (0d00f07) 78.62%.
Report is 1 commits behind head on main.

Files Patch % Lines
pkg/osvscanner/osvscanner.go 36.11% 23 Missing ⚠️
pkg/reporter/void_reporter.go 12.50% 7 Missing ⚠️
internal/sourceanalysis/rust.go 14.28% 6 Missing ⚠️
internal/sourceanalysis/go.go 0.00% 5 Missing ⚠️
pkg/reporter/gh-annotations_reporter.go 33.33% 4 Missing ⚠️
pkg/reporter/json_reporter.go 33.33% 4 Missing ⚠️
pkg/reporter/sarif_reporter.go 33.33% 4 Missing ⚠️
cmd/osv-reporter/main.go 0.00% 3 Missing ⚠️
internal/local/check.go 25.00% 3 Missing ⚠️
pkg/reporter/table_reporter.go 66.66% 2 Missing ⚠️
... and 4 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #706      +/-   ##
==========================================
- Coverage   78.88%   78.62%   -0.27%     
==========================================
  Files          85       85              
  Lines        6035     6055      +20     
==========================================
  Hits         4761     4761              
- Misses       1068     1088      +20     
  Partials      206      206              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -67,6 +67,9 @@ linters-settings:

issues:
exclude-rules:
- path: pkg/reporter
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

These changes made the reporters big enough to trigger dupl - I've just disabled it for the whole package because while it's technically not wrong, the only way I know that we could address that would be by having a standardReporter that gets used by each struct with the basic "print to stdout and error" behaviour (like what I've done in osv-detector with the "memory database"), but from what I understand that would be a breaking change (because when initializing the struct you have to pass in the inner struct) and it won't actually result in much savings

@G-Rath
Copy link
Collaborator Author

G-Rath commented Dec 16, 2023

Attention: 65 lines in your changes are missing coverage. Please review.

(because they're code that we just don't have tests for, and adding them would be a lot of work for this PR 😅)

Copy link
Collaborator

@another-rex another-rex left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@another-rex another-rex merged commit 439e5c5 into google:main Dec 27, 2023
11 checks passed
@G-Rath G-Rath deleted the update-reporter branch December 27, 2023 20:19
@G-Rath
Copy link
Collaborator Author

G-Rath commented Dec 27, 2023

@another-rex let me know if you have thoughts about removing PrintText and PrintError entirely right now vs waiting

@another-rex
Copy link
Collaborator

I'm thinking we remove them now since it's breaking anyway, and we'll want to have the changes discussed in #698 to be added before we make a release to keep all the breaking changes in one release.

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