chore(ci): replace golint with revive

This commit is contained in:
Jan De Dobbeleer 2021-05-21 20:01:08 +02:00 committed by Jan De Dobbeleer
parent ed610c13ee
commit 50473767a7
8 changed files with 24 additions and 23 deletions

View file

@ -15,7 +15,7 @@ linters:
- gocyclo - gocyclo
- gofmt - gofmt
- goimports - goimports
- golint - revive
- goprintffuncname - goprintffuncname
- gosimple - gosimple
- govet - govet

View file

@ -6,7 +6,7 @@ import (
) )
const ( 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 { type ansiUtils struct {
@ -105,14 +105,14 @@ func (a *ansiUtils) lenWithoutANSI(text string) int {
// replace hyperlinks // replace hyperlinks
matches := findAllNamedRegexMatch(`(?P<STR>\x1b]8;;file:\/\/(.+)\x1b\\(?P<URL>.+)\x1b]8;;\x1b\\)`, text) matches := findAllNamedRegexMatch(`(?P<STR>\x1b]8;;file:\/\/(.+)\x1b\\(?P<URL>.+)\x1b]8;;\x1b\\)`, text)
for _, match := range matches { for _, match := range matches {
text = strings.ReplaceAll(text, match[STR], match[URL]) text = strings.ReplaceAll(text, match[str], match[url])
} }
// replace console title // replace console title
matches = findAllNamedRegexMatch(`(?P<STR>\x1b\]0;(.+)\007)`, text) matches = findAllNamedRegexMatch(`(?P<STR>\x1b\]0;(.+)\007)`, text)
for _, match := range matches { 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.escapeLeft, "")
stripped = strings.ReplaceAll(stripped, a.escapeRight, "") stripped = strings.ReplaceAll(stripped, a.escapeRight, "")
runeText := []rune(stripped) runeText := []rune(stripped)

View file

@ -10,7 +10,7 @@ import (
var ( var (
// Map for color names and their respective foreground [0] or background [1] color codes // 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"}, "black": {"30", "40"},
"red": {"31", "41"}, "red": {"31", "41"},
"green": {"32", "42"}, "green": {"32", "42"},

View file

@ -150,7 +150,7 @@ func GetWindowTitle(pid int, windowTitleRegex string) (syscall.Handle, string) {
// callback fro EnumWindows // callback fro EnumWindows
cb := syscall.NewCallback(func(h syscall.Handle, p uintptr) uintptr { cb := syscall.NewCallback(func(h syscall.Handle, p uintptr) uintptr {
var prcsID int = 0 var prcsID int
// get pid // get pid
_, _, _ = procGetWindowThreadProcessID.Call(uintptr(h), uintptr(unsafe.Pointer(&prcsID))) _, _, _ = procGetWindowThreadProcessID.Call(uintptr(h), uintptr(unsafe.Pointer(&prcsID)))
// check if pid matches spotify pid // check if pid matches spotify pid

View file

@ -41,10 +41,11 @@ const (
green = "#71BD47" green = "#71BD47"
// known ansi sequences // known ansi sequences
FG = "FG"
BG = "BG" fg = "FG"
STR = "STR" bg = "BG"
URL = "URL" str = "STR"
url = "URL"
invertedColor = "inverted" invertedColor = "inverted"
invertedColorSingle = "invertedsingle" invertedColorSingle = "invertedsingle"
fullColor = "full" fullColor = "full"
@ -355,24 +356,24 @@ func (ir *ImageRenderer) shouldPrint() bool {
if len(match) == 0 { if len(match) == 0 {
continue continue
} }
ir.ansiString = strings.TrimPrefix(ir.ansiString, match[STR]) ir.ansiString = strings.TrimPrefix(ir.ansiString, match[str])
switch sequence { switch sequence {
case invertedColor: case invertedColor:
ir.foregroundColor = ir.defaultBackgroundColor ir.foregroundColor = ir.defaultBackgroundColor
ir.backgroundColor = NewRGBColor(match[BG]) ir.backgroundColor = NewRGBColor(match[bg])
return false return false
case invertedColorSingle: case invertedColorSingle:
ir.foregroundColor = ir.defaultBackgroundColor ir.foregroundColor = ir.defaultBackgroundColor
color, _ := strconv.Atoi(match[BG]) color, _ := strconv.Atoi(match[bg])
color += 10 color += 10
ir.setBase16Color(fmt.Sprint(color)) ir.setBase16Color(fmt.Sprint(color))
return false return false
case fullColor: case fullColor:
ir.foregroundColor = NewRGBColor(match[FG]) ir.foregroundColor = NewRGBColor(match[fg])
ir.backgroundColor = NewRGBColor(match[BG]) ir.backgroundColor = NewRGBColor(match[bg])
return false return false
case foreground: case foreground:
ir.foregroundColor = NewRGBColor(match[FG]) ir.foregroundColor = NewRGBColor(match[fg])
return false return false
case reset: case reset:
ir.foregroundColor = ir.defaultForegroundColor ir.foregroundColor = ir.defaultForegroundColor
@ -387,10 +388,10 @@ func (ir *ImageRenderer) shouldPrint() bool {
case strikethrough, strikethroughReset, left, osc99, lineChange, title: case strikethrough, strikethroughReset, left, osc99, lineChange, title:
return false return false
case color16: case color16:
ir.setBase16Color(match[FG]) ir.setBase16Color(match[fg])
return false return false
case link: case link:
ir.ansiString = match[URL] + ir.ansiString ir.ansiString = match[url] + ir.ansiString
} }
} }
return true return true

View file

@ -210,7 +210,7 @@ func main() {
} }
imageCreator.init() imageCreator.init()
match := findNamedRegexMatch(`.*(\/|\\)(?P<STR>.+).omp.(json|yaml|toml)`, *args.Config) 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 { if err != nil {
fmt.Print(err.Error()) fmt.Print(err.Error())
} }

View file

@ -6,7 +6,7 @@ import (
) )
var ( var (
regexCache map[string]*regexp.Regexp = make(map[string]*regexp.Regexp) regexCache = make(map[string]*regexp.Regexp)
regexCacheLock = sync.RWMutex{} regexCacheLock = sync.RWMutex{}
) )

View file

@ -19,7 +19,7 @@ func bootStrapKubectlTest(args *kubectlArgs) *kubectl {
env := new(MockedEnvironment) env := new(MockedEnvironment)
env.On("hasCommand", "kubectl").Return(args.kubectlExists) env.On("hasCommand", "kubectl").Return(args.kubectlExists)
kubectlOut := args.context + "," + args.namespace kubectlOut := args.context + "," + args.namespace
var kubectlErr error = nil var kubectlErr error
if args.kubectlErr { if args.kubectlErr {
kubectlErr = &commandError{ kubectlErr = &commandError{
err: "oops", err: "oops",