Properly handle closing files that have been writen to#7199
Conversation
| // HasEnvToken returns true when a token has been specified in an | ||
| // environment variable, else returns false. |
There was a problem hiding this comment.
Unrelated change that I wanted to make to improve this comment a bit.
mislav
left a comment
There was a problem hiding this comment.
I'm not sure if we care enough about bubbling errors that result from file.Close() up to the user. I'd rather say that we'd want to ignore them, especially because gh is such a short-lived process. That way we could avoid restructuring whole functions with named return values.
Have you considered
defer func() {
_ = file.Close()
}()|
@mislav This is the same as the |
mislav
left a comment
There was a problem hiding this comment.
You're right about legitimate filesystem errors potentially being masked. I was just skittish about this requiring significant code changes at first.
abbf23a to
8695f8f
Compare
Addresses CodeQL warnings about properly handling the return value when closing a file that has been written to.
Fixes https://github.com/cli/cli/security/code-scanning/116
Fixes https://github.com/cli/cli/security/code-scanning/115
Fixes https://github.com/cli/cli/security/code-scanning/114
Fixes https://github.com/cli/cli/security/code-scanning/113