alingse / sundrylint

three thousand real world bug linter
MIT License
4 stars 0 forks source link

TODO for lint some bugs #2

Open alingse opened 8 months ago

alingse commented 8 months ago

1. iter over zero

nums := make([]int, 0)
for _, num := range nums {

}

2. unused result from pure function

id := 1
if id > 0 {
   strconv.FormatInt(id, 10)
}

the result from pure function FormatInt is unused

3. append all data when range it

for _, n := range ns {
    if n > 0 {
        rs = append(rs, ns...)
   }
}

4. if-else-if vs switch

if n == 1 {
} else if n == 2 {
} else if n == 3 {
} else {
}

5. useless continue

for _, n := range ns {
   ...
   if n > 0 {
      ...
      continue
   }
}