Skip to content

Commit

Permalink
chore: Apply simple linter fixes.
Browse files Browse the repository at this point in the history
Use `_` for unused variables.
  • Loading branch information
jaqx0r committed Oct 15, 2023
1 parent 37f0f0f commit 26704f0
Show file tree
Hide file tree
Showing 13 changed files with 19 additions and 15 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,12 @@ jobs:
- uses: actions/checkout@v4
- uses: golangci/golangci-lint-action@v3
with:
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
# Required: the version of golangci-lint is required and must be
# specified without patch version: we always use the latest patch
# version.
version: v1.52

# Optional: show only new issues if it's a pull request. The default value is `false`.
# Optional: show only new issues if it's a pull request. The default
# value is `false`. Be careful upgrading because this won't show
# existing lints.
only-new-issues: true
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ veryclean: clean depclean

# This version should match the one in .github/workflows/golangci-lint.yml
GOLANGCILINT_VERSION=$(shell grep 'version: v' .github/workflows/golangci-lint.yml | cut -f2 -d: | tr -d ' ')
#GOLANGCILINT_VERSION=v1.52

# lint
.PHONY: lint
lint: $(GOFILES) $(GOGENFILES) $(GOTESTFILES)
Expand Down
2 changes: 1 addition & 1 deletion internal/exporter/graphite.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func (e *Exporter) HandleGraphite(w http.ResponseWriter, r *http.Request) {

// metricToGraphite encodes a metric in the graphite text protocol format. The
// metric lock is held before entering this function.
func metricToGraphite(hostname string, m *metrics.Metric, l *metrics.LabelSet, _ time.Duration) string {
func metricToGraphite(_ string, m *metrics.Metric, l *metrics.LabelSet, _ time.Duration) string {
var b strings.Builder
if m.Kind == metrics.Histogram && m.Type == metrics.Buckets {
d := m.LabelValues[0].Value
Expand Down
2 changes: 1 addition & 1 deletion internal/exporter/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
var exportJSONErrors = expvar.NewInt("exporter_json_errors")

// HandleJSON exports the metrics in JSON format via HTTP.
func (e *Exporter) HandleJSON(w http.ResponseWriter, r *http.Request) {
func (e *Exporter) HandleJSON(w http.ResponseWriter, _ *http.Request) {
b, err := json.MarshalIndent(e.store, "", " ")
if err != nil {
exportJSONErrors.Add(1)
Expand Down
2 changes: 1 addition & 1 deletion internal/exporter/statsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ var (

// metricToStatsd encodes a metric in the statsd text protocol format. The
// metric lock is held before entering this function.
func metricToStatsd(hostname string, m *metrics.Metric, l *metrics.LabelSet, _ time.Duration) string {
func metricToStatsd(_ string, m *metrics.Metric, l *metrics.LabelSet, _ time.Duration) string {
var t string
switch m.Kind {
case metrics.Counter:
Expand Down
2 changes: 1 addition & 1 deletion internal/metrics/datum/datum.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func MakeString(v string, ts time.Time) Datum {

// MakeBuckets creates a new bucket datum with the provided list of ranges and
// timestamp. If no +inf bucket is provided, one is created.
func MakeBuckets(buckets []Range, ts time.Time) Datum {
func MakeBuckets(buckets []Range, _ time.Time) Datum {
d := &Buckets{}
seenInf := false
highest := 0.0
Expand Down
2 changes: 1 addition & 1 deletion internal/metrics/metric.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func (m Kind) String() string {
}

// Generate implements the quick.Generator interface for Kind.
func (Kind) Generate(rand *rand.Rand, size int) reflect.Value {
func (Kind) Generate(rand *rand.Rand, _ int) reflect.Value {
return reflect.ValueOf(Kind(rand.Intn(int(endKind))))
}

Expand Down
2 changes: 1 addition & 1 deletion internal/metrics/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ func (t Type) String() string {
}

// Generate implements the quick.Generator interface for Type.
func (Type) Generate(rand *rand.Rand, size int) reflect.Value {
func (Type) Generate(rand *rand.Rand, _ int) reflect.Value {
return reflect.ValueOf(Type(rand.Intn(int(endType))))
}
4 changes: 2 additions & 2 deletions internal/mtail/httpstatus.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const statusTemplateEnd = `

// ServeHTTP satisfies the http.Handler interface, and is used to serve the
// root page of mtail for online status reporting.
func (m *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
func (m *Server) ServeHTTP(w http.ResponseWriter, _ *http.Request) {
t, err := template.New("status").Parse(statusTemplate)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
Expand Down Expand Up @@ -77,7 +77,7 @@ func (m *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
}

// FaviconHandler is used to serve up the favicon.ico for mtail's http server.
func FaviconHandler(w http.ResponseWriter, r *http.Request) {
func FaviconHandler(w http.ResponseWriter, _ *http.Request) {
w.Header().Set("Content-Type", "image/x-icon")
w.Header().Set("Cache-Control", "public, max-age=7776000")
if _, err := w.Write(logoFavicon); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion internal/mtail/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ var LogRuntimeErrors = &niladicOption{
// JaegerReporter creates a new jaeger reporter that sends to the given Jaeger endpoint address.
type JaegerReporter string

func (opt JaegerReporter) apply(m *Server) error {
func (opt JaegerReporter) apply(_ *Server) error {
je, err := jaeger.NewExporter(jaeger.Options{
CollectorEndpoint: string(opt),
Process: jaeger.Process{
Expand Down
2 changes: 1 addition & 1 deletion internal/runtime/compiler/symbol/symtab_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func TestInsertLookup(t *testing.T) {
}

// Generate implements the quick.Generator interface for SymbolKind.
func (Kind) Generate(rand *rand.Rand, size int) reflect.Value {
func (Kind) Generate(rand *rand.Rand, _ int) reflect.Value {
return reflect.ValueOf(Kind(rand.Intn(int(endSymbol))))
}

Expand Down
2 changes: 1 addition & 1 deletion internal/runtime/vm/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -959,7 +959,7 @@ func (v *VM) execute(t *thread, i code.Instr) {

// ProcessLogLine handles the incoming lines by running a fetch-execute cycle
// on the VM bytecode with the line as input to the program, until termination.
func (v *VM) ProcessLogLine(ctx context.Context, line *logline.LogLine) {
func (v *VM) ProcessLogLine(_ context.Context, line *logline.LogLine) {
start := time.Now()
defer func() {
LineProcessingDurations.WithLabelValues(v.name).Observe(time.Since(start).Seconds())
Expand Down
2 changes: 1 addition & 1 deletion internal/tailer/logstream/pipestream.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func (ps *pipeStream) LastReadTime() time.Time {
return ps.lastReadTime
}

func (ps *pipeStream) stream(ctx context.Context, wg *sync.WaitGroup, waker waker.Waker, fi os.FileInfo) error {
func (ps *pipeStream) stream(ctx context.Context, wg *sync.WaitGroup, waker waker.Waker, _ os.FileInfo) error {
// Open in nonblocking mode because the write end of the pipe may not have started yet.
fd, err := os.OpenFile(ps.pathname, os.O_RDONLY|syscall.O_NONBLOCK, 0o600)
if err != nil {
Expand Down

0 comments on commit 26704f0

Please sign in to comment.