Skip to content

Commit

Permalink
Using string.Builder to generate warning message, as the linter consi…
Browse files Browse the repository at this point in the history
…dered the line too long.

Signed-off-by: Simon Heidrich <[email protected]>
  • Loading branch information
aunovis-heidrich committed Jan 9, 2025
1 parent 91d202c commit 0c6dc70
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 7 additions & 1 deletion clients/githubrepo/roundtripper/tokens/accessor.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,13 @@ type TokenAccessor interface {
}

var logDuplicateTokenWarning = func(firstName string, clashingName string) {
log.Printf("Warning: PATs stored in env variables %s and %s differ. Scorecard will use the former.\n", firstName, clashingName)
var stringBuilder strings.Builder
stringBuilder.WriteString("Warning: PATs stored in env variables ")
stringBuilder.WriteString(firstName)
stringBuilder.WriteString(" and ")
stringBuilder.WriteString(clashingName)
stringBuilder.WriteString(" differ. Scorecard will use the former.")
log.Println(stringBuilder.String())

Check warning on line 44 in clients/githubrepo/roundtripper/tokens/accessor.go

View check run for this annotation

Codecov / codecov/patch

clients/githubrepo/roundtripper/tokens/accessor.go#L37-L44

Added lines #L37 - L44 were not covered by tests
}

func readGitHubTokens() (string, bool) {
Expand Down
2 changes: 0 additions & 2 deletions clients/githubrepo/roundtripper/tokens/accessor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ func testServer(t *testing.T) {
}
}

//nolint:paralleltest // test uses t.Setenv indirectly
func TestClashingTokensDisplayWarning(t *testing.T) {
unsetTokens(t)

Expand Down Expand Up @@ -119,7 +118,6 @@ func TestClashingTokensDisplayWarning(t *testing.T) {
}
}

//nolint:paralleltest // test uses t.Setenv indirectly
func TestConsistentTokensDoNotDisplayWarning(t *testing.T) {
unsetTokens(t)

Expand Down

0 comments on commit 0c6dc70

Please sign in to comment.