1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00

golangci-lint configuration file

golangci-lint can run all the currently enabled linters, and as far as I
can tell, does it in under 5 seconds as opposed to over 180 seconds
(compare `time make cilint` and `time make lint`).

Some of the linters that are listed in the "enabled" section but
commented out looked like a good idea to me, and fairly low hanging
fruit to fix, but they are not passing at the moment.

All the linters covered in the current Makefile are run.

TODO:
- replace lint target in Makefile with golangci-lint
- remove .github/workflow/errcheck.yml
This commit is contained in:
Sam Roberts
2020-05-16 11:59:24 -07:00
parent e43c37cc07
commit 4bb725db9e
23 changed files with 84 additions and 41 deletions

View File

@@ -73,11 +73,12 @@ func (widget *Widget) generateQueueJobLine(id int64, parameters []sdk.Parameter,
row[2] = pad(run, 7)
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)
} else if bookedBy.ID != 0 {
case bookedBy.ID != 0:
row[1] = pad(fmt.Sprintf(" %s.%d ", bookedBy.Name, bookedBy.ID), 27)
} else {
default:
row[1] = pad("", 27)
}

View File

@@ -43,17 +43,18 @@ func (widget *Widget) displayStatus() string {
)
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())
} 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())
} else if strings.Contains(line.Component, "Global") {
case strings.Contains(line.Component, "Global"):
global = append(global, line.String())
} else if line.Status == sdk.MonitoringStatusWarn {
case line.Status == sdk.MonitoringStatusWarn:
warn = append(warn, line.String())
} else if line.Status == sdk.MonitoringStatusOK {
case line.Status == sdk.MonitoringStatusOK:
ok = append(ok, line.String())
} else {
default:
red = append(red, line.String())
}
}

View File

@@ -129,7 +129,6 @@ func (widget *Widget) updateCurrencies() {
setPrices(&jsonResponse, fromCurrency)
}
}
func makeRequest(currency *fromCurrency) *http.Request {

View File

@@ -13,7 +13,7 @@ const AM = "A"
const PM = "P"
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 {
valStr := strconv.Itoa(val)
@@ -39,9 +39,9 @@ func getHourMinute(hourFormat string) string {
}
strMintues := intStrConv(time.Now().Minute())
strMintues = strMintues + AMPM
return strHours + getColon() + strMintues
strMinutes := intStrConv(time.Now().Minute())
strMinutes += AMPM
return strHours + getColon() + strMinutes
}
// Returns the : with blinking based on the seconds

View File

@@ -3,7 +3,7 @@ package digitalclock
import "strings"
func mergeLines(outString []string) string {
return strings.Join(outString[:], "\n")
return strings.Join(outString, "\n")
}
func renderWidget(widgetSettings Settings) string {

View File

@@ -147,11 +147,12 @@ func (widget *Widget) timeUntil(calEvent *CalEvent) string {
untilStr := ""
color := "[lightblue]"
if days > 0 {
switch {
case days > 0:
untilStr = fmt.Sprintf("%dd", days)
} else if hours > 0 {
case hours > 0:
untilStr = fmt.Sprintf("%dh", hours)
} else {
default:
untilStr = fmt.Sprintf("%dm", mins)
if mins < 30 {
color = "[red]"

View File

@@ -90,7 +90,7 @@ func (widget *Widget) getTodos(apiKey string) ([]*gitlab.Todo, error) {
func (widget *Widget) trimTodoBody(body string) string {
r := []rune(body)
// Cut at first occurance of a newline
// Cut at first occurence of a newline
for i, a := range r {
if a == '\n' {
return string(r[:i])

View File

@@ -68,7 +68,7 @@ func (widget *Widget) content() (string, string, bool) {
return title, widget.err.Error(), true
}
title = title + widget.sinceDateForTitle()
title += widget.sinceDateForTitle()
str := ""
for _, status := range widget.statuses {

View File

@@ -82,7 +82,7 @@ func (widget *Widget) content() (string, string, bool) {
row := fmt.Sprintf(
`[%s] [%s]%-6s[white]`,
widget.RowColor(idx),
widget.jobColor(&job),
widget.jobColor(job),
jobName,
)
@@ -92,7 +92,7 @@ func (widget *Widget) content() (string, string, bool) {
return title, str, false
}
func (widget *Widget) jobColor(job *Job) string {
func (widget *Widget) jobColor(job Job) string {
switch job.Color {
case "blue":
// Override color if successBallColor boolean param provided in config

View File

@@ -198,11 +198,12 @@ func (client *clientInstance) getNodes() ([]string, error) {
var nodeStatus string
for _, condition := range node.Status.Conditions {
if condition.Reason == "KubeletReady" {
if condition.Status == "True" {
switch {
case condition.Status == "True":
nodeStatus = "Ready"
} else if condition.Reason == "False" {
case condition.Reason == "False":
nodeStatus = "NotReady"
} else {
default:
nodeStatus = "Unknown"
}
}

View File

@@ -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
there are 3 states:
1-archive
@@ -197,7 +197,7 @@ const (
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) {
url := fmt.Sprintf("%s/get?sort=newest&state=%s&consumer_key=%s&access_token=%s", client.baseURL, state, client.consumerKey, *client.accessToken)
req := request{

View File

@@ -121,7 +121,7 @@ func MakeGraph(widget *Widget) {
}
}
widget.BarGraph.BuildBars(stats[:])
widget.BarGraph.BuildBars(stats)
}

View File

@@ -57,11 +57,12 @@ func (widget *Widget) torrentPercentDone(torrent *transmissionrpc.Torrent) strin
pctDone := *torrent.PercentDone
str := fmt.Sprintf("%3d%%↓", int(pctDone*100))
if pctDone == 0.0 {
switch pctDone {
case 0.0:
str = "[gray::b]" + str
} else if pctDone == 1.0 {
case 1.0:
str = "[green::b]" + str
} else {
default:
str = "[lightblue::b]" + str
}

View File

@@ -77,7 +77,7 @@ func (widget *Widget) content() (string, string, bool) {
row := fmt.Sprintf(
rowFormat,
widget.RowColor(idx),
buildColor(&build),
buildColor(build),
build.Repository.Name,
build.Number,
build.Branch.Name,
@@ -92,7 +92,7 @@ func (widget *Widget) content() (string, string, bool) {
return title, str, false
}
func buildColor(build *Build) string {
func buildColor(build Build) string {
switch build.State {
case "broken":
return "red"

View File

@@ -67,7 +67,6 @@ func (widget *Widget) listTickets(pag ...string) (*TicketArray, error) {
}
return TicketStruct, err
}
func (widget *Widget) newTickets() (*TicketArray, error) {