Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug report: miss makezero in slice init #84

Open
alingse opened this issue May 27, 2024 · 3 comments
Open

bug report: miss makezero in slice init #84

alingse opened this issue May 27, 2024 · 3 comments

Comments

@alingse
Copy link

alingse commented May 27, 2024

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/9243004504/job/25426564828

====================================================================================================
append to slice `mode` with non-zero initialized length at https://github.com/montanaflynn/stats/blob/master/mode.go#L23:11
append to slice `mode` with non-zero initialized length at https://github.com/montanaflynn/stats/blob/master/mode.go#L34:[10](https://github.com/alingse/go-linter-runner/actions/runs/9243004504/job/25426564828#step:4:11)
====================================================================================================

https://github.com/montanaflynn/stats/blob/master/mode.go#L16C1-L23

	mode = make([]float64, 5)
	cnt, maxCnt := 1, 1
	for i := 1; i < l; i++ {
		switch {
		case c[i] == c[i-1]:
			cnt++
		case cnt == maxCnt && maxCnt != 1:
			mode = append(mode, c[i-1])

maybe the mode = make([]float64, 5) should be mode = make([]float64, 0, 5)

@ccoVeille

This comment has been minimized.

@ccoVeille

This comment has been minimized.

@alingse alingse changed the title bug report: maybe miss makezero in bug report: miss makezero in slice init May 27, 2024
@alingse
Copy link
Author

alingse commented May 27, 2024

no, I will write more linter's yaml config like this https://github.com/alingse/go-linter-runner/blob/main/jobs/alingse-makezero.yaml#L4

name: alingse-makezero
linter: makezero
workdir: .
install: go install github.com/alingse/makezero@f6a823578e89de5cdfdfef50d4a5d9a09ade16dd
includes:
  - non-zero initialized length
excludes:
  - called by funcs
  - assigned by index

this config will install and run the specified linter for repos, and check the output must have and must not have some text.

the source repo I run is in here https://github.com/alingse/go-linter-runner/blob/main/source/repos.url.top.1k

your repo is in the top3k.

The reason that why I create the repo is because I have some idea about linter alingse/sundrylint#2 , I want to check the idea in real-world

and than add the useful one to golangci-lint 🤔

and I want to add some auto-report-issuse to process the github actions output.

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

No branches or pull requests

2 participants