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:

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

    After:

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

    Available since
        2017.1

    Online documentation
        https://staticcheck.dev/docs/checks#S1000

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

    Online documentation
        https://staticcheck.dev/docs/checks#S1000
  • Loading branch information
arp242 committed May 27, 2024
1 parent 48e6907 commit 5788345
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions analysis/lint/lint.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,13 +167,13 @@ func (doc *Documentation) format(markdown bool, metadata bool) string {
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 5788345

Please sign in to comment.