From 5b80bf417b1aeba2f52ff4eadce9b1820d41480b Mon Sep 17 00:00:00 2001 From: Igor Chubin Date: Fri, 23 Dec 2022 20:05:30 +0100 Subject: [PATCH] Fix lll findings --- internal/view/v1/format.go | 35 +++++++++++++++++++---------------- internal/view/v1/view1.go | 2 ++ 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/internal/view/v1/format.go b/internal/view/v1/format.go index 035acf5..5c83b85 100644 --- a/internal/view/v1/format.go +++ b/internal/view/v1/format.go @@ -31,7 +31,7 @@ func formatTemp(c cond) string { color := func(temp int, explicitPlus bool) string { var col int if !config.Inverse { - // Extemely cold temperature must be shown with violet + // Extremely cold temperature must be shown with violet // because dark blue is too dark col = 165 switch temp { @@ -167,17 +167,6 @@ func formatTemp(c cond) string { unitTemp[config.Imperial]), 15) } - // if c.FeelsLikeC < t { - // if c.FeelsLikeC < 0 && t > 0 { - // explicitPlus = true - // } - // return pad(fmt.Sprintf("%s%s%s °%s", color(c.FeelsLikeC, false), hyphen, color(t, explicitPlus), unitTemp[config.Imperial]), 15) - // } else if c.FeelsLikeC > t { - // if t < 0 && c.FeelsLikeC > 0 { - // explicitPlus = true - // } - // return pad(fmt.Sprintf("%s%s%s °%s", color(t, false), hyphen, color(c.FeelsLikeC, explicitPlus), unitTemp[config.Imperial]), 15) - // } return pad(fmt.Sprintf("%s °%s", color(c.FeelsLikeC, false), unitTemp[config.Imperial]), 15) } @@ -241,7 +230,9 @@ func formatWind(c cond) string { cWindGustKmph := color(c.WindGustKmph) cWindspeedKmph := color(c.WindspeedKmph) if windInRightUnits(c.WindGustKmph) > windInRightUnits(c.WindspeedKmph) { - return pad(fmt.Sprintf("%s %s%s%s %s", windDir[c.Winddir16Point], cWindspeedKmph, hyphen, cWindGustKmph, unitWindString), 15) + return pad( + fmt.Sprintf("%s %s%s%s %s", windDir[c.Winddir16Point], cWindspeedKmph, hyphen, cWindGustKmph, unitWindString), + 15) } return pad(fmt.Sprintf("%s %s %s", windDir[c.Winddir16Point], cWindspeedKmph, unitWindString), 15) @@ -258,7 +249,7 @@ func formatVisibility(c cond) string { func formatRain(c cond) string { rainUnit := float32(c.PrecipMM) if config.Imperial { - rainUnit = float32(c.PrecipMM) * 0.039 + rainUnit = c.PrecipMM * 0.039 } if c.ChanceOfRain != "" { return pad(fmt.Sprintf( @@ -336,9 +327,21 @@ func formatCond(cur []string, c cond, current bool) (ret []string) { } } if config.RightToLeft { - ret = append(ret, fmt.Sprintf("%v %v %v", cur[0], desc, icon[0]), fmt.Sprintf("%v %v %v", cur[1], formatTemp(c), icon[1]), fmt.Sprintf("%v %v %v", cur[2], formatWind(c), icon[2]), fmt.Sprintf("%v %v %v", cur[3], formatVisibility(c), icon[3]), fmt.Sprintf("%v %v %v", cur[4], formatRain(c), icon[4])) + ret = append( + ret, + fmt.Sprintf("%v %v %v", cur[0], desc, icon[0]), + fmt.Sprintf("%v %v %v", cur[1], formatTemp(c), icon[1]), + fmt.Sprintf("%v %v %v", cur[2], formatWind(c), icon[2]), + fmt.Sprintf("%v %v %v", cur[3], formatVisibility(c), icon[3]), + fmt.Sprintf("%v %v %v", cur[4], formatRain(c), icon[4])) } else { - ret = append(ret, fmt.Sprintf("%v %v %v", cur[0], icon[0], desc), fmt.Sprintf("%v %v %v", cur[1], icon[1], formatTemp(c)), fmt.Sprintf("%v %v %v", cur[2], icon[2], formatWind(c)), fmt.Sprintf("%v %v %v", cur[3], icon[3], formatVisibility(c)), fmt.Sprintf("%v %v %v", cur[4], icon[4], formatRain(c))) + ret = append( + ret, + fmt.Sprintf("%v %v %v", cur[0], icon[0], desc), + fmt.Sprintf("%v %v %v", cur[1], icon[1], formatTemp(c)), + fmt.Sprintf("%v %v %v", cur[2], icon[2], formatWind(c)), + fmt.Sprintf("%v %v %v", cur[3], icon[3], formatVisibility(c)), + fmt.Sprintf("%v %v %v", cur[4], icon[4], formatRain(c))) } return diff --git a/internal/view/v1/view1.go b/internal/view/v1/view1.go index 9cc98e6..3d352b6 100644 --- a/internal/view/v1/view1.go +++ b/internal/view/v1/view1.go @@ -115,6 +115,7 @@ func printDay(w weather) (ret []string) { "└──────┬──────┘" + justifyCenter(trans[2], 16) + " │" + justifyCenter(trans[3], 29) + "│" } + //nolint:lll ret = append([]string{ " ┌─────────────┐ ", "┌──────────────────────────────┬───────────────────────" + dateFmt + "───────────────────────┬──────────────────────────────┐", @@ -123,6 +124,7 @@ func printDay(w weather) (ret []string) { }, ret...) + //nolint:lll return append(ret, "└──────────────────────────────┴──────────────────────────────┴──────────────────────────────┴──────────────────────────────┘") }