Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
samber committed Jun 27, 2024
1 parent ce9dfb2 commit 0efce40
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
4 changes: 4 additions & 0 deletions channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ func DispatchingStrategyRoundRobin[T any](msg T, index uint64, channels []<-chan
// If the channel capacity is exceeded, another random channel will be selected and so on.
func DispatchingStrategyRandom[T any](msg T, index uint64, channels []<-chan T) int {
for {
// @TODO: Upgrade to math/rand/v2 as soon as we set the minimum Go version to 1.22.
// bearer:disable go_gosec_crypto_weak_random
i := rand.Intn(len(channels))
if channelIsNotFull(channels[i]) {
return i
Expand All @@ -108,6 +110,8 @@ func DispatchingStrategyWeightedRandom[T any](weights []int) DispatchingStrategy

return func(msg T, index uint64, channels []<-chan T) int {
for {
// @TODO: Upgrade to math/rand/v2 as soon as we set the minimum Go version to 1.22.
// bearer:disable go_gosec_crypto_weak_random
i := seq[rand.Intn(len(seq))]
if channelIsNotFull(channels[i]) {
return i
Expand Down
4 changes: 4 additions & 0 deletions find.go
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,8 @@ func Sample[T any](collection []T) T {
return Empty[T]()
}

// @TODO: Upgrade to math/rand/v2 as soon as we set the minimum Go version to 1.22.
// bearer:disable go_gosec_crypto_weak_random
return collection[rand.Intn(size)]
}

Expand All @@ -404,6 +406,8 @@ func Samples[T any](collection []T, count int) []T {
for i := 0; i < size && i < count; i++ {
copyLength := size - i

// @TODO: Upgrade to math/rand/v2 as soon as we set the minimum Go version to 1.22.
// bearer:disable go_gosec_crypto_weak_random
index := rand.Intn(size - i)
results = append(results, copy[index])

Expand Down
6 changes: 5 additions & 1 deletion string.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ var (
SpecialCharset = []rune("!@#$%^&*()_+-=[]{}|;':\",./<>?")
AllCharset = append(AlphanumericCharset, SpecialCharset...)

splitWordReg = regexp.MustCompile(`([a-z])([A-Z0-9])|([a-zA-Z])([0-9])|([0-9])([a-zA-Z])|([A-Z])([A-Z])([a-z])`)
// bearer:disable go_lang_permissive_regex_validation
splitWordReg = regexp.MustCompile(`([a-z])([A-Z0-9])|([a-zA-Z])([0-9])|([0-9])([a-zA-Z])|([A-Z])([A-Z])([a-z])`)
// bearer:disable go_lang_permissive_regex_validation
splitNumberLetterReg = regexp.MustCompile(`([0-9])([a-zA-Z])`)
)

Expand All @@ -37,6 +39,8 @@ func RandomString(size int, charset []rune) string {
b := make([]rune, size)
possibleCharactersCount := len(charset)
for i := range b {
// @TODO: Upgrade to math/rand/v2 as soon as we set the minimum Go version to 1.22.
// bearer:disable go_gosec_crypto_weak_random
b[i] = charset[rand.Intn(possibleCharactersCount)]
}
return string(b)
Expand Down

0 comments on commit 0efce40

Please sign in to comment.