Skip to content

Commit

Permalink
Fix linter errors
Browse files Browse the repository at this point in the history
The linter is correctly flagging this bit:

	fmt.Fprintf(w, ExpectedMessage)

because it's a formatting function that doesn't appear to be formatting
anything (since there are not additional arguments after the formatting
string).

staticcheck has started flagging this import:

	"github.com/golang/protobuf/proto"

because that package has been rewritten and published as
google.golang.org/protobuf. The new package is not a drop-in replacement
for the old one, even if the staticcheck diagnostic suggests otherwise.
Newer versions of the old package are actually implemented in terms of
the new one. For this code base in particular, some of the text
marshalling functions have disappeared in the new package and they need
to be implemented in terms of the new reflection package. Until an
adequate solution is found, simply ignore the error.

Closes: #281

Signed-off-by: Marcelo E. Magallon <marcelo.magallon@grafana.com>
  • Loading branch information
mem committed Jul 15, 2021
1 parent a1b6ede commit 08ac5ff
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 11 deletions.
6 changes: 3 additions & 3 deletions config/http_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -335,11 +335,11 @@ func TestNewClientFromConfig(t *testing.T) {
handler: func(w http.ResponseWriter, r *http.Request) {
switch r.URL.Path {
case "/redirected":
fmt.Fprintf(w, ExpectedMessage)
fmt.Fprint(w, ExpectedMessage)
default:
w.Header().Set("Location", "/redirected")
w.WriteHeader(http.StatusFound)
fmt.Fprintf(w, "It should follow the redirect.")
fmt.Fprint(w, "It should follow the redirect.")
}
},
}, {
Expand All @@ -359,7 +359,7 @@ func TestNewClientFromConfig(t *testing.T) {
default:
w.Header().Set("Location", "/redirected")
w.WriteHeader(http.StatusFound)
fmt.Fprintf(w, ExpectedMessage)
fmt.Fprint(w, ExpectedMessage)
}
},
},
Expand Down
2 changes: 1 addition & 1 deletion expfmt/decode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"strings"
"testing"

"github.com/golang/protobuf/proto"
"github.com/golang/protobuf/proto" //nolint:staticcheck // Ignore SA1019. Need to keep deprecated package for compatibility.
dto "github.com/prometheus/client_model/go"

"github.com/prometheus/common/model"
Expand Down
2 changes: 1 addition & 1 deletion expfmt/encode.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"io"
"net/http"

"github.com/golang/protobuf/proto"
"github.com/golang/protobuf/proto" //nolint:staticcheck // Ignore SA1019. Need to keep deprecated package for compatibility.
"github.com/matttproud/golang_protobuf_extensions/pbutil"
"github.com/prometheus/common/internal/bitbucket.org/ww/goautoneg"

Expand Down
5 changes: 3 additions & 2 deletions expfmt/encode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ package expfmt

import (
"bytes"
"github.com/golang/protobuf/proto"
dto "github.com/prometheus/client_model/go"
"net/http"
"testing"

"github.com/golang/protobuf/proto" //nolint:staticcheck // Ignore SA1019. Need to keep deprecated package for compatibility.
dto "github.com/prometheus/client_model/go"
)

func TestNegotiate(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion expfmt/openmetrics_create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"testing"
"time"

"github.com/golang/protobuf/proto"
"github.com/golang/protobuf/proto" //nolint:staticcheck // Ignore SA1019. Need to keep deprecated package for compatibility.
"github.com/golang/protobuf/ptypes"

dto "github.com/prometheus/client_model/go"
Expand Down
2 changes: 1 addition & 1 deletion expfmt/text_create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"strings"
"testing"

"github.com/golang/protobuf/proto"
"github.com/golang/protobuf/proto" //nolint:staticcheck // Ignore SA1019. Need to keep deprecated package for compatibility.

dto "github.com/prometheus/client_model/go"
)
Expand Down
2 changes: 1 addition & 1 deletion expfmt/text_parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (

dto "github.com/prometheus/client_model/go"

"github.com/golang/protobuf/proto"
"github.com/golang/protobuf/proto" //nolint:staticcheck // Ignore SA1019. Need to keep deprecated package for compatibility.
"github.com/prometheus/common/model"
)

Expand Down
2 changes: 1 addition & 1 deletion expfmt/text_parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"strings"
"testing"

"github.com/golang/protobuf/proto"
"github.com/golang/protobuf/proto" //nolint:staticcheck // Ignore SA1019. Need to keep deprecated package for compatibility.
dto "github.com/prometheus/client_model/go"
)

Expand Down

0 comments on commit 08ac5ff

Please sign in to comment.