Fix lint issues detected by golangci v2

This commit is contained in:
Manuel Rüger 2025-04-02 16:36:03 +02:00
parent a0c6abfa6d
commit f24d8c8957
4 changed files with 12 additions and 8 deletions

View File

@ -201,7 +201,9 @@ func prepareAttachment(opener vfs.Opener, base, name string) (Attachment, error)
if err != nil { if err != nil {
return Attachment{}, karma.Format(err, "unable to open file: %q", attachmentPath) return Attachment{}, karma.Format(err, "unable to open file: %q", attachmentPath)
} }
defer file.Close() defer func() {
_ = file.Close()
}()
fileBytes, err := io.ReadAll(file) fileBytes, err := io.ReadAll(file)
if err != nil { if err != nil {

View File

@ -260,7 +260,7 @@ func (api *API) CreateAttachment(
if len(result.Results) == 0 { if len(result.Results) == 0 {
return info, errors.New( return info, errors.New(
"Confluence REST API for creating attachments returned " + "the Confluence REST API for creating attachments returned " +
"0 json objects, expected at least 1", "0 json objects, expected at least 1",
) )
} }
@ -794,21 +794,23 @@ func (api *API) RestrictPageUpdates(
func newErrorStatusNotOK(request *gopencils.Resource) error { func newErrorStatusNotOK(request *gopencils.Resource) error {
if request.Raw.StatusCode == http.StatusUnauthorized { if request.Raw.StatusCode == http.StatusUnauthorized {
return errors.New( return errors.New(
"Confluence API returned unexpected status: 401 (Unauthorized)", "the Confluence API returned unexpected status: 401 (Unauthorized)",
) )
} }
if request.Raw.StatusCode == http.StatusNotFound { if request.Raw.StatusCode == http.StatusNotFound {
return errors.New( return errors.New(
"Confluence API returned unexpected status: 404 (Not Found)", "the Confluence API returned unexpected status: 404 (Not Found)",
) )
} }
output, _ := io.ReadAll(request.Raw.Body) output, _ := io.ReadAll(request.Raw.Body)
defer request.Raw.Body.Close() defer func() {
_ = request.Raw.Body.Close()
}()
return fmt.Errorf( return fmt.Errorf(
"Confluence API returned unexpected status: %v, "+ "the Confluence API returned unexpected status: %v, "+
"output: %q", "output: %q",
request.Raw.Status, output, request.Raw.Status, output,
) )

View File

@ -72,7 +72,7 @@ func (r *ConfluenceTextRenderer) renderText(w util.BufWriter, source []byte, nod
case html.EastAsianLineBreaksNone: case html.EastAsianLineBreaksNone:
writeLineBreak = false writeLineBreak = false
case html.EastAsianLineBreaksSimple: case html.EastAsianLineBreaksSimple:
writeLineBreak = !(util.IsEastAsianWideRune(thisLastRune) && util.IsEastAsianWideRune(siblingFirstRune)) writeLineBreak = !util.IsEastAsianWideRune(thisLastRune) || !util.IsEastAsianWideRune(siblingFirstRune)
case html.EastAsianLineBreaksCSS3Draft: case html.EastAsianLineBreaksCSS3Draft:
writeLineBreak = eastAsianLineBreaksCSS3DraftSoftLineBreak(thisLastRune, siblingFirstRune) writeLineBreak = eastAsianLineBreaksCSS3DraftSoftLineBreak(thisLastRune, siblingFirstRune)
} }

View File

@ -325,7 +325,7 @@ func processFile(
} }
var finalVersionMessage string var finalVersionMessage string
var shouldUpdatePage bool = true var shouldUpdatePage = true
if cCtx.Bool("changes-only") { if cCtx.Bool("changes-only") {
contentHash := getSHA1Hash(html) contentHash := getSHA1Hash(html)