Skip to content

Commit

Permalink
analysis/lint: don't print so many newlines for description
Browse files Browse the repository at this point in the history
The Before and After had extraneous newlines; before:

    % staticcheck -explain S1000
    Use plain channel send or receive instead of single-case select

    Select statements with a single case can be replaced with a simple
    send or receive.

    Before (· represents blank line, git strips double blanks otherwise):
        ·
        ·
        select {
        case x := <-ch:
            fmt.Println(x)
        }
        ·
    After:
        ·
        ·
        x := <-ch
        fmt.Println(x)
        ·
        ·
    Available since
        2017.1

And after:

    % staticcheck -explain S1000
    Use plain channel send or receive instead of single-case select

    Select statements with a single case can be replaced with a simple
    send or receive.

    Before:

        select {
        case x := <-ch:
            fmt.Println(x)
        }

    After:

        x := <-ch
        fmt.Println(x)

    Available since
        2017.1
  • Loading branch information
arp242 committed May 29, 2024
1 parent 48e6907 commit bc37651
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions analysis/lint/lint.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,25 +155,25 @@ func (doc *Documentation) format(markdown bool, metadata bool) string {
if markdown {
fmt.Fprintf(b, "%s\n\n", doc.TitleMarkdown)
if doc.Text != "" {
fmt.Fprintf(b, "%s\n\n", doc.TextMarkdown)
fmt.Fprintf(b, "%s\n\n", strings.TrimSpace(doc.TextMarkdown))
}
} else {
fmt.Fprintf(b, "%s\n\n", doc.Title)
if doc.Text != "" {
fmt.Fprintf(b, "%s\n\n", doc.Text)
fmt.Fprintf(b, "%s\n\n", strings.TrimSpace(doc.Text))
}
}

if doc.Before != "" {
fmt.Fprintln(b, "Before:")
fmt.Fprintln(b, "")
for _, line := range strings.Split(doc.Before, "\n") {
for _, line := range strings.Split(strings.TrimSpace(doc.Before), "\n") {
fmt.Fprint(b, " ", line, "\n")
}
fmt.Fprintln(b, "")
fmt.Fprintln(b, "After:")
fmt.Fprintln(b, "")
for _, line := range strings.Split(doc.After, "\n") {
for _, line := range strings.Split(strings.TrimSpace(doc.After), "\n") {
fmt.Fprint(b, " ", line, "\n")
}
fmt.Fprintln(b, "")
Expand Down

0 comments on commit bc37651

Please sign in to comment.