Skip to content

Conversation

alingse
Copy link

@alingse alingse commented May 26, 2024

What this PR does / why we need it:

Fixes #

I was running github actions to run linter makezero for top github golang repos.

see issues alingse/go-linter-runner#1

and the github actions output

https://github.com/alingse/go-linter-runner/actions/runs/9242655147/job/25425748900

====================================================================================================
append to slice `tags` with non-zero initialized length at https://github.com/m3db/m3/blob/master/src/dbnode/integration/integration_data_verify.go#L241:11
====================================================================================================

but the linter can't find the make(sort.StringSlice, len(*t)) so not reported in the actions output

Special notes for your reviewer

this is not cause a real bad bug because the []string was sort and finally called by WriteString(s)

so the empty value string was save in the slice but ignored when called by WriteString

func (r *result) genID() result {
	tags := make(sort.StringSlice, 0, len(r.Metric))
	for k, v := range r.Metric {
		tags = append(tags, fmt.Sprintf("%s:%s,", k, v))
	}

	sort.Sort(tags)
	var sb strings.Builder
	// NB: this may clash but exact tag values are also checked, and this is a
	// validation endpoint so there's less concern over correctness.
	for _, t := range tags {
		sb.WriteString(t) // this ignore the empty string t
	}

Does this PR introduce a user-facing and/or backwards incompatible change?:

NONE

Does this PR require updating code package or user-facing documentation?:


Signed-off-by: alingse <alingse@foxmail.com>
@CLAassistant
Copy link

CLAassistant commented May 26, 2024

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants