Skip to content

Commit

Permalink
Fix golangci-lint 1.45.0 findings
Browse files Browse the repository at this point in the history
  • Loading branch information
scop committed Mar 18, 2022
1 parent 553ae74 commit f17d0f3
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 32 deletions.
1 change: 1 addition & 0 deletions defaults.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//nolint:deadcode,varcheck
package main

var defaults = Config{
Expand Down
3 changes: 2 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ const (
MaxUnsignedInteger = ^MinUnsignedInteger
// MaxInteger maximum integer
MaxInteger = int(MaxUnsignedInteger >> 1)
// MinInteger minimum integer
/* MinInteger minimum integer
MinInteger = ^MaxInteger
*/
)

func warn(msg string) {
Expand Down
36 changes: 17 additions & 19 deletions powerline.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,22 @@ type ShellInfo struct {
}

type powerline struct {
cfg Config
cwd string
userInfo user.User
userIsAdmin bool
hostname string
username string
theme Theme
shell ShellInfo
reset string
symbols SymbolTemplate
priorities map[string]int
ignoreRepos map[string]bool
Segments [][]pwl.Segment
curSegment int
align alignment
rightPowerline *powerline
appendEastAsianPadding int
cfg Config
cwd string
userInfo user.User
userIsAdmin bool
hostname string
username string
theme Theme
shell ShellInfo
reset string
symbols SymbolTemplate
priorities map[string]int
ignoreRepos map[string]bool
Segments [][]pwl.Segment
curSegment int
align alignment
rightPowerline *powerline
}

type prioritizedSegments struct {
Expand Down Expand Up @@ -208,8 +207,7 @@ func (p *powerline) appendSegment(origin string, segment pwl.Segment) {
if segment.SeparatorForeground == 0 {
segment.SeparatorForeground = segment.Background
}
priority, _ := p.priorities[origin]
segment.Priority += priority
segment.Priority += p.priorities[origin]
segment.Width = segment.ComputeWidth(p.cfg.Condensed)
if segment.NewLine {
p.newRow()
Expand Down
4 changes: 2 additions & 2 deletions segment-bzr.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ func segmentBzr(p *powerline) []pwl.Segment {
foreground = p.theme.RepoCleanFg
background = p.theme.RepoCleanBg

content = fmt.Sprintf(branch)
content = branch
}

return []pwl.Segment{{
Name: "bzr",
Name: "bzr",
Content: content,
Foreground: foreground,
Background: background,
Expand Down
14 changes: 7 additions & 7 deletions segment-duration.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,31 +68,31 @@ func segmentDuration(p *powerline) []pwl.Segment {
hrs := ns / hours
ns -= hrs * hours
mins := ns / minutes
content = fmt.Sprintf("%dh %dm", hrs, mins)
content = fmt.Sprintf("%d%c %d%c", hrs, hour, mins, minute)
} else if ns > minutes {
mins := ns / minutes
ns -= mins * minutes
secs := ns / seconds
content = fmt.Sprintf("%dm %ds", mins, secs)
content = fmt.Sprintf("%d%c %d%c", mins, minute, secs, second)
} else if !hasPrecision {
secs := ns / seconds
content = fmt.Sprintf("%ds", secs)
content = fmt.Sprintf("%d%c", secs, second)
} else if ns > seconds {
secs := ns / seconds
ns -= secs * seconds
millis := ns / milliseconds
content = fmt.Sprintf("%ds %dms", secs, millis)
content = fmt.Sprintf("%d%c %d%c%c", secs, second, millis, milli, second)
} else if ns > milliseconds || p.cfg.DurationLowPrecision {
millis := ns / milliseconds
ns -= millis * milliseconds
micros := ns / microseconds
if p.cfg.DurationLowPrecision {
content = fmt.Sprintf("%dms", millis)
content = fmt.Sprintf("%d%c%c", millis, milli, second)
} else {
content = fmt.Sprintf("%dms %d\u00B5s", millis, micros)
content = fmt.Sprintf("%d%c%c %d%c%c", millis, milli, second, micros, micro, second)
}
} else {
content = fmt.Sprintf("%d\u00B5s", ns/microseconds)
content = fmt.Sprintf("%d%c%c", ns/microseconds, micro, second)
}

return []pwl.Segment{{
Expand Down
4 changes: 2 additions & 2 deletions segment-fossil.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ func segmentFossil(p *powerline) []pwl.Segment {
foreground = p.theme.RepoCleanFg
background = p.theme.RepoCleanBg

content = fmt.Sprintf(branch)
content = branch
}

return []pwl.Segment{{
Name: "fossil",
Name: "fossil",
Content: content,
Foreground: foreground,
Background: background,
Expand Down
2 changes: 1 addition & 1 deletion segment-goenv.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func checkForGoenvOutput() (string, error) {
}

func segmentGoenv(p *powerline) []pwl.Segment {
global, err := checkForGoenvGlobalVersion()
global, _ := checkForGoenvGlobalVersion()

segment, err := checkEnvForGoenvVersion()
if err != nil || segment == global {
Expand Down

0 comments on commit f17d0f3

Please sign in to comment.