Skip to content

Commit

Permalink
chore(ci): replace golint with revive
Browse files Browse the repository at this point in the history
  • Loading branch information
JanDeDobbeleer committed May 21, 2021
1 parent ed610c1 commit 5047376
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 23 deletions.
2 changes: 1 addition & 1 deletion src/.golangci.yml
Expand Up @@ -15,7 +15,7 @@ linters:
- gocyclo
- gofmt
- goimports
- golint
- revive
- goprintffuncname
- gosimple
- govet
Expand Down
8 changes: 4 additions & 4 deletions src/ansi.go
Expand Up @@ -6,7 +6,7 @@ import (
)

const (
ANSIRegex = "[\u001B\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[a-zA-Z\\d]*)*)?\u0007)|(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PRZcf-ntqry=><~]))"
ansiRegex = "[\u001B\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[a-zA-Z\\d]*)*)?\u0007)|(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PRZcf-ntqry=><~]))"
)

type ansiUtils struct {
Expand Down Expand Up @@ -105,14 +105,14 @@ func (a *ansiUtils) lenWithoutANSI(text string) int {
// replace hyperlinks
matches := findAllNamedRegexMatch(`(?P<STR>\x1b]8;;file:\/\/(.+)\x1b\\(?P<URL>.+)\x1b]8;;\x1b\\)`, text)
for _, match := range matches {
text = strings.ReplaceAll(text, match[STR], match[URL])
text = strings.ReplaceAll(text, match[str], match[url])
}
// replace console title
matches = findAllNamedRegexMatch(`(?P<STR>\x1b\]0;(.+)\007)`, text)
for _, match := range matches {
text = strings.ReplaceAll(text, match[STR], "")
text = strings.ReplaceAll(text, match[str], "")
}
stripped := replaceAllString(ANSIRegex, text, "")
stripped := replaceAllString(ansiRegex, text, "")
stripped = strings.ReplaceAll(stripped, a.escapeLeft, "")
stripped = strings.ReplaceAll(stripped, a.escapeRight, "")
runeText := []rune(stripped)
Expand Down
2 changes: 1 addition & 1 deletion src/ansi_color.go
Expand Up @@ -10,7 +10,7 @@ import (

var (
// Map for color names and their respective foreground [0] or background [1] color codes
colorMap map[string][2]string = map[string][2]string{
colorMap = map[string][2]string{
"black": {"30", "40"},
"red": {"31", "41"},
"green": {"32", "42"},
Expand Down
2 changes: 1 addition & 1 deletion src/environment_windows_win32.go
Expand Up @@ -150,7 +150,7 @@ func GetWindowTitle(pid int, windowTitleRegex string) (syscall.Handle, string) {

// callback fro EnumWindows
cb := syscall.NewCallback(func(h syscall.Handle, p uintptr) uintptr {
var prcsID int = 0
var prcsID int
// get pid
_, _, _ = procGetWindowThreadProcessID.Call(uintptr(h), uintptr(unsafe.Pointer(&prcsID)))
// check if pid matches spotify pid
Expand Down
25 changes: 13 additions & 12 deletions src/image.go
Expand Up @@ -41,10 +41,11 @@ const (
green = "#71BD47"

// known ansi sequences
FG = "FG"
BG = "BG"
STR = "STR"
URL = "URL"

fg = "FG"
bg = "BG"
str = "STR"
url = "URL"
invertedColor = "inverted"
invertedColorSingle = "invertedsingle"
fullColor = "full"
Expand Down Expand Up @@ -355,24 +356,24 @@ func (ir *ImageRenderer) shouldPrint() bool {
if len(match) == 0 {
continue
}
ir.ansiString = strings.TrimPrefix(ir.ansiString, match[STR])
ir.ansiString = strings.TrimPrefix(ir.ansiString, match[str])
switch sequence {
case invertedColor:
ir.foregroundColor = ir.defaultBackgroundColor
ir.backgroundColor = NewRGBColor(match[BG])
ir.backgroundColor = NewRGBColor(match[bg])
return false
case invertedColorSingle:
ir.foregroundColor = ir.defaultBackgroundColor
color, _ := strconv.Atoi(match[BG])
color, _ := strconv.Atoi(match[bg])
color += 10
ir.setBase16Color(fmt.Sprint(color))
return false
case fullColor:
ir.foregroundColor = NewRGBColor(match[FG])
ir.backgroundColor = NewRGBColor(match[BG])
ir.foregroundColor = NewRGBColor(match[fg])
ir.backgroundColor = NewRGBColor(match[bg])
return false
case foreground:
ir.foregroundColor = NewRGBColor(match[FG])
ir.foregroundColor = NewRGBColor(match[fg])
return false
case reset:
ir.foregroundColor = ir.defaultForegroundColor
Expand All @@ -387,10 +388,10 @@ func (ir *ImageRenderer) shouldPrint() bool {
case strikethrough, strikethroughReset, left, osc99, lineChange, title:
return false
case color16:
ir.setBase16Color(match[FG])
ir.setBase16Color(match[fg])
return false
case link:
ir.ansiString = match[URL] + ir.ansiString
ir.ansiString = match[url] + ir.ansiString
}
}
return true
Expand Down
2 changes: 1 addition & 1 deletion src/main.go
Expand Up @@ -210,7 +210,7 @@ func main() {
}
imageCreator.init()
match := findNamedRegexMatch(`.*(\/|\\)(?P<STR>.+).omp.(json|yaml|toml)`, *args.Config)
err := imageCreator.SavePNG(fmt.Sprintf("%s.png", match[STR]))
err := imageCreator.SavePNG(fmt.Sprintf("%s.png", match[str]))
if err != nil {
fmt.Print(err.Error())
}
Expand Down
4 changes: 2 additions & 2 deletions src/regex.go
Expand Up @@ -6,8 +6,8 @@ import (
)

var (
regexCache map[string]*regexp.Regexp = make(map[string]*regexp.Regexp)
regexCacheLock = sync.RWMutex{}
regexCache = make(map[string]*regexp.Regexp)
regexCacheLock = sync.RWMutex{}
)

func getCompiledRegex(pattern string) *regexp.Regexp {
Expand Down
2 changes: 1 addition & 1 deletion src/segment_kubectl_test.go
Expand Up @@ -19,7 +19,7 @@ func bootStrapKubectlTest(args *kubectlArgs) *kubectl {
env := new(MockedEnvironment)
env.On("hasCommand", "kubectl").Return(args.kubectlExists)
kubectlOut := args.context + "," + args.namespace
var kubectlErr error = nil
var kubectlErr error
if args.kubectlErr {
kubectlErr = &commandError{
err: "oops",
Expand Down

0 comments on commit 5047376

Please sign in to comment.