mirror of
https://github.com/idanoo/autobrr
synced 2025-07-23 00:39:13 +00:00
fix(filters): lint warning variable naming (#1783)
* fix(filters): variable naming * fix(filters): variable naming
This commit is contained in:
parent
d23e7ffca6
commit
8f2398a627
1 changed files with 48 additions and 43 deletions
|
@ -793,36 +793,38 @@ func matchRegex(tag string, filterList string) bool {
|
||||||
func containsIntStrings(value int, filterList string) bool {
|
func containsIntStrings(value int, filterList string) bool {
|
||||||
filters := strings.Split(filterList, ",")
|
filters := strings.Split(filterList, ",")
|
||||||
|
|
||||||
for _, s := range filters {
|
for _, filter := range filters {
|
||||||
s = strings.Replace(s, "%", "", -1)
|
filter = strings.Replace(filter, "%", "", -1)
|
||||||
s = strings.Trim(s, " ")
|
filter = strings.TrimSpace(filter)
|
||||||
|
|
||||||
if strings.Contains(s, "-") {
|
if strings.Contains(filter, "-") {
|
||||||
minMax := strings.Split(s, "-")
|
minMax := strings.Split(filter, "-")
|
||||||
|
|
||||||
// to int
|
if len(minMax) == 2 {
|
||||||
min, err := strconv.ParseInt(minMax[0], 10, 32)
|
// to int
|
||||||
if err != nil {
|
minValue, err := strconv.ParseInt(minMax[0], 10, 32)
|
||||||
return false
|
if err != nil {
|
||||||
}
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
max, err := strconv.ParseInt(minMax[1], 10, 32)
|
maxValue, err := strconv.ParseInt(minMax[1], 10, 32)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
if min > max {
|
if minValue > maxValue {
|
||||||
// handle error
|
// handle error
|
||||||
return false
|
return false
|
||||||
} else {
|
} else {
|
||||||
// if announcePercent is greater than min and less than max return true
|
// if announcePercent is greater than minValue and less than maxValue return true
|
||||||
if value >= int(min) && value <= int(max) {
|
if value >= int(minValue) && value <= int(maxValue) {
|
||||||
return true
|
return true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
filterInt, err := strconv.ParseInt(s, 10, 32)
|
filterInt, err := strconv.ParseInt(filter, 10, 32)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -1018,35 +1020,38 @@ func containsAnySlice(tags []string, filters []string) bool {
|
||||||
func checkFreeleechPercent(announcePercent int, filterPercent string) bool {
|
func checkFreeleechPercent(announcePercent int, filterPercent string) bool {
|
||||||
filters := strings.Split(filterPercent, ",")
|
filters := strings.Split(filterPercent, ",")
|
||||||
|
|
||||||
for _, s := range filters {
|
for _, filter := range filters {
|
||||||
s = strings.Replace(s, "%", "", -1)
|
filter = strings.Replace(filter, "%", "", -1)
|
||||||
|
filter = strings.TrimSpace(filter)
|
||||||
|
|
||||||
if strings.Contains(s, "-") {
|
if strings.Contains(filter, "-") {
|
||||||
minMax := strings.Split(s, "-")
|
minMax := strings.Split(filter, "-")
|
||||||
|
|
||||||
// to int
|
if len(minMax) == 2 {
|
||||||
min, err := strconv.ParseInt(minMax[0], 10, 32)
|
// to int
|
||||||
if err != nil {
|
minValue, err := strconv.ParseInt(minMax[0], 10, 32)
|
||||||
return false
|
if err != nil {
|
||||||
}
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
max, err := strconv.ParseInt(minMax[1], 10, 32)
|
maxValue, err := strconv.ParseInt(minMax[1], 10, 32)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
if min > max {
|
if minValue > maxValue {
|
||||||
// handle error
|
// handle error
|
||||||
return false
|
return false
|
||||||
} else {
|
} else {
|
||||||
// if announcePercent is greater than min and less than max return true
|
// if announcePercent is greater than minValue and less than maxValue return true
|
||||||
if announcePercent >= int(min) && announcePercent <= int(max) {
|
if announcePercent >= int(minValue) && announcePercent <= int(maxValue) {
|
||||||
return true
|
return true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
filterPercentInt, err := strconv.ParseInt(s, 10, 32)
|
filterPercentInt, err := strconv.ParseInt(filter, 10, 32)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue