mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Merge branch 'lint' of github.com:sam-github/wtf into sam-github-lint
This commit is contained in:
commit
86c7e127aa
20
.github/workflows/golangci-lint.yml
vendored
Normal file
20
.github/workflows/golangci-lint.yml
vendored
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
name: golangci-lint
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- v*
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
pull_request:
|
||||||
|
jobs:
|
||||||
|
golangci:
|
||||||
|
name: lint
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: golangci-lint
|
||||||
|
uses: golangci/golangci-lint-action@v0.2.0
|
||||||
|
with:
|
||||||
|
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
|
||||||
|
version: v1.27
|
||||||
|
args: ./...
|
15
.golangci.yml
Normal file
15
.golangci.yml
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
linters:
|
||||||
|
enable:
|
||||||
|
- vet
|
||||||
|
- errcheck
|
||||||
|
- staticcheck
|
||||||
|
# - dupl
|
||||||
|
# - funlen
|
||||||
|
# - goconst
|
||||||
|
# - gocritic
|
||||||
|
- gofmt
|
||||||
|
# - golint
|
||||||
|
# - misspell
|
||||||
|
# - stylecheck
|
||||||
|
- unconvert
|
||||||
|
# - whitespace
|
3
Makefile
3
Makefile
@ -86,6 +86,9 @@ install:
|
|||||||
@echo "${APP} installed into ${INSTALLPATH}"
|
@echo "${APP} installed into ${INSTALLPATH}"
|
||||||
|
|
||||||
## lint: runs a number of code quality checks against the source code
|
## lint: runs a number of code quality checks against the source code
|
||||||
|
cilint:
|
||||||
|
golangci-lint run
|
||||||
|
|
||||||
lint:
|
lint:
|
||||||
@echo "\033[35mhttps://github.com/kisielk/errcheck\033[0m"
|
@echo "\033[35mhttps://github.com/kisielk/errcheck\033[0m"
|
||||||
errcheck ./app
|
errcheck ./app
|
||||||
|
@ -200,7 +200,7 @@ func (tracker *FocusTracker) focusables() []wtf.Wtfable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Sort for deterministic ordering
|
// Sort for deterministic ordering
|
||||||
sort.SliceStable(focusable[:], func(i, j int) bool {
|
sort.SliceStable(focusable, func(i, j int) bool {
|
||||||
iTop := focusable[i].CommonSettings().Top
|
iTop := focusable[i].CommonSettings().Top
|
||||||
jTop := focusable[j].CommonSettings().Top
|
jTop := focusable[j].CommonSettings().Top
|
||||||
|
|
||||||
|
@ -109,6 +109,7 @@ func (wtfApp *WtfApp) keyboardIntercept(event *tcell.EventKey) *tcell.EventKey {
|
|||||||
switch string(event.Rune()) {
|
switch string(event.Rune()) {
|
||||||
case "/":
|
case "/":
|
||||||
return nil
|
return nil
|
||||||
|
default:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ func WtfConfigDir() (string, error) {
|
|||||||
if configDir == "" {
|
if configDir == "" {
|
||||||
configDir = WtfConfigDirV2
|
configDir = WtfConfigDirV2
|
||||||
} else {
|
} else {
|
||||||
configDir = configDir + "/wtf/"
|
configDir += "/wtf/"
|
||||||
}
|
}
|
||||||
configDir, err := expandHomeDir(configDir)
|
configDir, err := expandHomeDir(configDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -73,11 +73,12 @@ func (widget *Widget) generateQueueJobLine(id int64, parameters []sdk.Parameter,
|
|||||||
row[2] = pad(run, 7)
|
row[2] = pad(run, 7)
|
||||||
row[3] = pad(prj+"/"+workflow+"/"+node, 40)
|
row[3] = pad(prj+"/"+workflow+"/"+node, 40)
|
||||||
|
|
||||||
if status == sdk.StatusBuilding {
|
switch {
|
||||||
|
case status == sdk.StatusBuilding:
|
||||||
row[1] = pad(fmt.Sprintf(" %s.%s ", executedJob.WorkerName, executedJob.WorkerID), 27)
|
row[1] = pad(fmt.Sprintf(" %s.%s ", executedJob.WorkerName, executedJob.WorkerID), 27)
|
||||||
} else if bookedBy.ID != 0 {
|
case bookedBy.ID != 0:
|
||||||
row[1] = pad(fmt.Sprintf(" %s.%d ", bookedBy.Name, bookedBy.ID), 27)
|
row[1] = pad(fmt.Sprintf(" %s.%d ", bookedBy.Name, bookedBy.ID), 27)
|
||||||
} else {
|
default:
|
||||||
row[1] = pad("", 27)
|
row[1] = pad("", 27)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,17 +43,18 @@ func (widget *Widget) displayStatus() string {
|
|||||||
)
|
)
|
||||||
|
|
||||||
for _, line := range status.Lines {
|
for _, line := range status.Lines {
|
||||||
if line.Status == sdk.MonitoringStatusWarn && strings.Contains(line.Component, "Global") {
|
switch {
|
||||||
|
case line.Status == sdk.MonitoringStatusWarn && strings.Contains(line.Component, "Global"):
|
||||||
globalWarn = append(globalWarn, line.String())
|
globalWarn = append(globalWarn, line.String())
|
||||||
} else if line.Status != sdk.MonitoringStatusOK && strings.Contains(line.Component, "Global") {
|
case line.Status != sdk.MonitoringStatusOK && strings.Contains(line.Component, "Global"):
|
||||||
globalRed = append(globalRed, line.String())
|
globalRed = append(globalRed, line.String())
|
||||||
} else if strings.Contains(line.Component, "Global") {
|
case strings.Contains(line.Component, "Global"):
|
||||||
global = append(global, line.String())
|
global = append(global, line.String())
|
||||||
} else if line.Status == sdk.MonitoringStatusWarn {
|
case line.Status == sdk.MonitoringStatusWarn:
|
||||||
warn = append(warn, line.String())
|
warn = append(warn, line.String())
|
||||||
} else if line.Status == sdk.MonitoringStatusOK {
|
case line.Status == sdk.MonitoringStatusOK:
|
||||||
ok = append(ok, line.String())
|
ok = append(ok, line.String())
|
||||||
} else {
|
default:
|
||||||
red = append(red, line.String())
|
red = append(red, line.String())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -129,7 +129,6 @@ func (widget *Widget) updateCurrencies() {
|
|||||||
|
|
||||||
setPrices(&jsonResponse, fromCurrency)
|
setPrices(&jsonResponse, fromCurrency)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func makeRequest(currency *fromCurrency) *http.Request {
|
func makeRequest(currency *fromCurrency) *http.Request {
|
||||||
|
@ -13,7 +13,7 @@ const AM = "A"
|
|||||||
const PM = "P"
|
const PM = "P"
|
||||||
const minRowsForBorder = 3
|
const minRowsForBorder = 3
|
||||||
|
|
||||||
// Converts integer to string along with makes sure the lenght of string is > 2
|
// Converts integer to string along with makes sure the length of string is > 2
|
||||||
func intStrConv(val int) string {
|
func intStrConv(val int) string {
|
||||||
valStr := strconv.Itoa(val)
|
valStr := strconv.Itoa(val)
|
||||||
|
|
||||||
@ -39,9 +39,9 @@ func getHourMinute(hourFormat string) string {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
strMintues := intStrConv(time.Now().Minute())
|
strMinutes := intStrConv(time.Now().Minute())
|
||||||
strMintues = strMintues + AMPM
|
strMinutes += AMPM
|
||||||
return strHours + getColon() + strMintues
|
return strHours + getColon() + strMinutes
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns the : with blinking based on the seconds
|
// Returns the : with blinking based on the seconds
|
||||||
|
@ -3,7 +3,7 @@ package digitalclock
|
|||||||
import "strings"
|
import "strings"
|
||||||
|
|
||||||
func mergeLines(outString []string) string {
|
func mergeLines(outString []string) string {
|
||||||
return strings.Join(outString[:], "\n")
|
return strings.Join(outString, "\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
func renderWidget(widgetSettings Settings) string {
|
func renderWidget(widgetSettings Settings) string {
|
||||||
|
@ -147,11 +147,12 @@ func (widget *Widget) timeUntil(calEvent *CalEvent) string {
|
|||||||
untilStr := ""
|
untilStr := ""
|
||||||
|
|
||||||
color := "[lightblue]"
|
color := "[lightblue]"
|
||||||
if days > 0 {
|
switch {
|
||||||
|
case days > 0:
|
||||||
untilStr = fmt.Sprintf("%dd", days)
|
untilStr = fmt.Sprintf("%dd", days)
|
||||||
} else if hours > 0 {
|
case hours > 0:
|
||||||
untilStr = fmt.Sprintf("%dh", hours)
|
untilStr = fmt.Sprintf("%dh", hours)
|
||||||
} else {
|
default:
|
||||||
untilStr = fmt.Sprintf("%dm", mins)
|
untilStr = fmt.Sprintf("%dm", mins)
|
||||||
if mins < 30 {
|
if mins < 30 {
|
||||||
color = "[red]"
|
color = "[red]"
|
||||||
|
@ -90,7 +90,7 @@ func (widget *Widget) getTodos(apiKey string) ([]*gitlab.Todo, error) {
|
|||||||
func (widget *Widget) trimTodoBody(body string) string {
|
func (widget *Widget) trimTodoBody(body string) string {
|
||||||
r := []rune(body)
|
r := []rune(body)
|
||||||
|
|
||||||
// Cut at first occurance of a newline
|
// Cut at first occurence of a newline
|
||||||
for i, a := range r {
|
for i, a := range r {
|
||||||
if a == '\n' {
|
if a == '\n' {
|
||||||
return string(r[:i])
|
return string(r[:i])
|
||||||
|
@ -68,7 +68,7 @@ func (widget *Widget) content() (string, string, bool) {
|
|||||||
return title, widget.err.Error(), true
|
return title, widget.err.Error(), true
|
||||||
}
|
}
|
||||||
|
|
||||||
title = title + widget.sinceDateForTitle()
|
title += widget.sinceDateForTitle()
|
||||||
str := ""
|
str := ""
|
||||||
|
|
||||||
for _, status := range widget.statuses {
|
for _, status := range widget.statuses {
|
||||||
|
@ -82,7 +82,7 @@ func (widget *Widget) content() (string, string, bool) {
|
|||||||
row := fmt.Sprintf(
|
row := fmt.Sprintf(
|
||||||
`[%s] [%s]%-6s[white]`,
|
`[%s] [%s]%-6s[white]`,
|
||||||
widget.RowColor(idx),
|
widget.RowColor(idx),
|
||||||
widget.jobColor(&job),
|
widget.jobColor(job),
|
||||||
jobName,
|
jobName,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -92,7 +92,7 @@ func (widget *Widget) content() (string, string, bool) {
|
|||||||
return title, str, false
|
return title, str, false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (widget *Widget) jobColor(job *Job) string {
|
func (widget *Widget) jobColor(job Job) string {
|
||||||
switch job.Color {
|
switch job.Color {
|
||||||
case "blue":
|
case "blue":
|
||||||
// Override color if successBallColor boolean param provided in config
|
// Override color if successBallColor boolean param provided in config
|
||||||
|
@ -198,11 +198,12 @@ func (client *clientInstance) getNodes() ([]string, error) {
|
|||||||
var nodeStatus string
|
var nodeStatus string
|
||||||
for _, condition := range node.Status.Conditions {
|
for _, condition := range node.Status.Conditions {
|
||||||
if condition.Reason == "KubeletReady" {
|
if condition.Reason == "KubeletReady" {
|
||||||
if condition.Status == "True" {
|
switch {
|
||||||
|
case condition.Status == "True":
|
||||||
nodeStatus = "Ready"
|
nodeStatus = "Ready"
|
||||||
} else if condition.Reason == "False" {
|
case condition.Reason == "False":
|
||||||
nodeStatus = "NotReady"
|
nodeStatus = "NotReady"
|
||||||
} else {
|
default:
|
||||||
nodeStatus = "Unknown"
|
nodeStatus = "Unknown"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -178,7 +178,7 @@ func (client *Client) GetAccessToken(requestToken string) (accessToken string, e
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*LinkState represents links states to be retrived
|
/*LinkState represents link states to be retrieved
|
||||||
According to the api https://getpocket.com/developer/docs/v3/retrieve
|
According to the api https://getpocket.com/developer/docs/v3/retrieve
|
||||||
there are 3 states:
|
there are 3 states:
|
||||||
1-archive
|
1-archive
|
||||||
@ -197,7 +197,7 @@ const (
|
|||||||
Unread LinkState = "unread"
|
Unread LinkState = "unread"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetLinks retrive links of a given states https://getpocket.com/developer/docs/v3/retrieve
|
// GetLinks retrieve links of a given states https://getpocket.com/developer/docs/v3/retrieve
|
||||||
func (client *Client) GetLinks(state LinkState) (response ItemLists, err error) {
|
func (client *Client) GetLinks(state LinkState) (response ItemLists, err error) {
|
||||||
url := fmt.Sprintf("%s/get?sort=newest&state=%s&consumer_key=%s&access_token=%s", client.baseURL, state, client.consumerKey, *client.accessToken)
|
url := fmt.Sprintf("%s/get?sort=newest&state=%s&consumer_key=%s&access_token=%s", client.baseURL, state, client.consumerKey, *client.accessToken)
|
||||||
req := request{
|
req := request{
|
||||||
|
@ -121,7 +121,7 @@ func MakeGraph(widget *Widget) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
widget.BarGraph.BuildBars(stats[:])
|
widget.BarGraph.BuildBars(stats)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,11 +57,12 @@ func (widget *Widget) torrentPercentDone(torrent *transmissionrpc.Torrent) strin
|
|||||||
pctDone := *torrent.PercentDone
|
pctDone := *torrent.PercentDone
|
||||||
str := fmt.Sprintf("%3d%%↓", int(pctDone*100))
|
str := fmt.Sprintf("%3d%%↓", int(pctDone*100))
|
||||||
|
|
||||||
if pctDone == 0.0 {
|
switch pctDone {
|
||||||
|
case 0.0:
|
||||||
str = "[gray::b]" + str
|
str = "[gray::b]" + str
|
||||||
} else if pctDone == 1.0 {
|
case 1.0:
|
||||||
str = "[green::b]" + str
|
str = "[green::b]" + str
|
||||||
} else {
|
default:
|
||||||
str = "[lightblue::b]" + str
|
str = "[lightblue::b]" + str
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ func (widget *Widget) content() (string, string, bool) {
|
|||||||
row := fmt.Sprintf(
|
row := fmt.Sprintf(
|
||||||
rowFormat,
|
rowFormat,
|
||||||
widget.RowColor(idx),
|
widget.RowColor(idx),
|
||||||
buildColor(&build),
|
buildColor(build),
|
||||||
build.Repository.Name,
|
build.Repository.Name,
|
||||||
build.Number,
|
build.Number,
|
||||||
build.Branch.Name,
|
build.Branch.Name,
|
||||||
@ -92,7 +92,7 @@ func (widget *Widget) content() (string, string, bool) {
|
|||||||
return title, str, false
|
return title, str, false
|
||||||
}
|
}
|
||||||
|
|
||||||
func buildColor(build *Build) string {
|
func buildColor(build Build) string {
|
||||||
switch build.State {
|
switch build.State {
|
||||||
case "broken":
|
case "broken":
|
||||||
return "red"
|
return "red"
|
||||||
|
@ -67,7 +67,6 @@ func (widget *Widget) listTickets(pag ...string) (*TicketArray, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return TicketStruct, err
|
return TicketStruct, err
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (widget *Widget) newTickets() (*TicketArray, error) {
|
func (widget *Widget) newTickets() (*TicketArray, error) {
|
||||||
|
@ -70,7 +70,7 @@ func Test_ExecuteCommand(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func Test_FindMatch(t *testing.T) {
|
func Test_FindMatch(t *testing.T) {
|
||||||
expected := [][]string([][]string{[]string{"SSID: 7E5B5C", "7E5B5C"}})
|
expected := [][]string{{"SSID: 7E5B5C", "7E5B5C"}}
|
||||||
result := FindMatch(`s*SSID: (.+)s*`, "SSID: 7E5B5C")
|
result := FindMatch(`s*SSID: (.+)s*`, "SSID: 7E5B5C")
|
||||||
|
|
||||||
assert.Equal(t, expected, result)
|
assert.Equal(t, expected, result)
|
||||||
@ -115,7 +115,7 @@ func Test_ReadFileBytes(t *testing.T) {
|
|||||||
expected []byte
|
expected []byte
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "with non-existant file",
|
name: "with non-existent file",
|
||||||
file: "/tmp/junk-daa6bf613f4c.md",
|
file: "/tmp/junk-daa6bf613f4c.md",
|
||||||
expected: []byte{},
|
expected: []byte{},
|
||||||
},
|
},
|
||||||
|
@ -65,11 +65,12 @@ func (base *Base) ConfigText() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (base *Base) ContextualTitle(defaultStr string) string {
|
func (base *Base) ContextualTitle(defaultStr string) string {
|
||||||
if defaultStr == "" && base.FocusChar() == "" {
|
switch {
|
||||||
|
case defaultStr == "" && base.FocusChar() == "":
|
||||||
return ""
|
return ""
|
||||||
} else if defaultStr != "" && base.FocusChar() == "" {
|
case defaultStr != "" && base.FocusChar() == "":
|
||||||
return fmt.Sprintf(" %s ", defaultStr)
|
return fmt.Sprintf(" %s ", defaultStr)
|
||||||
} else if defaultStr == "" && base.FocusChar() != "" {
|
case defaultStr == "" && base.FocusChar() != "":
|
||||||
return fmt.Sprintf(" [darkgray::u]%s[::-][white] ", base.FocusChar())
|
return fmt.Sprintf(" [darkgray::u]%s[::-][white] ", base.FocusChar())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user