From f0ca3b8a589a6d78754c42ddcd0d95425906fa6b Mon Sep 17 00:00:00 2001 From: Chris Cummer Date: Sat, 9 May 2020 12:51:08 -0700 Subject: [PATCH] Another actions test (#889) * Another actions test Signed-off-by: Chris Cummer * Add BuildTest action Signed-off-by: Chris Cummer * Remove lint check for the time being (so many issues) Signed-off-by: Chris Cummer * Fix issues found by errcheck Signed-off-by: Chris Cummer * Fix errors found by staticcheck Signed-off-by: Chris Cummer * Fix issues found by goimports Signed-off-by: Chris Cummer * Comment out the action for the time being Signed-off-by: Chris Cummer * Fix shadowed variables Signed-off-by: Chris Cummer * go mod tidy Signed-off-by: Chris Cummer * Remove buildtest.yml Signed-off-by: Chris Cummer * go mod tidy Signed-off-by: Chris Cummer --- .github/workflows/staticcheck.yml | 70 +++++++++++++++++++ app/widget_maker.go | 6 +- checklist/checklist_item.go | 2 - generator/textwidget.go | 10 +-- go.mod | 1 - go.sum | 18 +++-- modules/buildkite/settings.go | 3 +- modules/buildkite/widget.go | 1 + modules/cds/status/display.go | 18 ----- modules/cmdrunner/widget.go | 4 +- modules/gcal/client.go | 4 +- modules/gcal/display.go | 2 +- modules/github/github_repo.go | 3 +- modules/gitlab/gitlab_project.go | 4 +- modules/gitlabtodo/widget.go | 6 +- modules/gspreadsheets/client.go | 13 ++-- modules/ipaddresses/ipinfo/widget.go | 2 +- modules/jenkins/client.go | 2 +- modules/jenkins/view.go | 10 +-- modules/jenkins/widget.go | 3 +- modules/jira/issues.go | 8 +-- modules/pihole/client.go | 16 ++--- modules/spacex/client.go | 3 +- modules/spacex/widget.go | 4 +- modules/spotifyweb/widget.go | 5 +- modules/subreddit/widget.go | 20 +++--- modules/twitch/client.go | 1 + modules/twitch/settings.go | 3 +- modules/twitch/widget.go | 1 + .../weatherservices/arpansagovau/widget.go | 1 + utils/text.go | 5 +- 31 files changed, 155 insertions(+), 94 deletions(-) create mode 100644 .github/workflows/staticcheck.yml diff --git a/.github/workflows/staticcheck.yml b/.github/workflows/staticcheck.yml new file mode 100644 index 00000000..a9529aea --- /dev/null +++ b/.github/workflows/staticcheck.yml @@ -0,0 +1,70 @@ +name: static check +on: pull_request + +jobs: + imports: + name: Imports + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + - name: check + uses: grandcolline/golang-github-actions@v1.1.0 + with: + run: imports + token: ${{ secrets.GITHUB_TOKEN }} + + errcheck: + name: Errcheck + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + - name: check + uses: grandcolline/golang-github-actions@v1.1.0 + with: + run: errcheck + token: ${{ secrets.GITHUB_TOKEN }} + + #lint: + #name: Lint + #runs-on: ubuntu-latest + #steps: + #- uses: actions/checkout@master + #- name: check + #uses: grandcolline/golang-github-actions@v1.1.0 + #with: + #run: lint + #token: ${{ secrets.GITHUB_TOKEN }} + + shadow: + name: Shadow + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + - name: check + uses: grandcolline/golang-github-actions@v1.1.0 + with: + run: shadow + token: ${{ secrets.GITHUB_TOKEN }} + + staticcheck: + name: StaticCheck + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + - name: check + uses: grandcolline/golang-github-actions@v1.1.0 + with: + run: staticcheck + token: ${{ secrets.GITHUB_TOKEN }} + + #sec: + #name: Sec + #runs-on: ubuntu-latest + #steps: + #- uses: actions/checkout@master + #- name: check + #uses: grandcolline/golang-github-actions@v1.1.0 + #with: + #run: sec + #token: ${{ secrets.GITHUB_TOKEN }} + #flags: "-exclude=G104" diff --git a/app/widget_maker.go b/app/widget_maker.go index 44210ce4..9b9d9766 100644 --- a/app/widget_maker.go +++ b/app/widget_maker.go @@ -7,9 +7,9 @@ import ( "github.com/wtfutil/wtf/modules/bamboohr" "github.com/wtfutil/wtf/modules/bargraph" "github.com/wtfutil/wtf/modules/buildkite" - "github.com/wtfutil/wtf/modules/cds/favorites" - "github.com/wtfutil/wtf/modules/cds/queue" - "github.com/wtfutil/wtf/modules/cds/status" + cdsfavorites "github.com/wtfutil/wtf/modules/cds/favorites" + cdsqueue "github.com/wtfutil/wtf/modules/cds/queue" + cdsstatus "github.com/wtfutil/wtf/modules/cds/status" "github.com/wtfutil/wtf/modules/circleci" "github.com/wtfutil/wtf/modules/clocks" "github.com/wtfutil/wtf/modules/cmdrunner" diff --git a/checklist/checklist_item.go b/checklist/checklist_item.go index 40cfafb8..b4b2943c 100644 --- a/checklist/checklist_item.go +++ b/checklist/checklist_item.go @@ -1,7 +1,5 @@ package checklist -import () - // ChecklistItem is a module for creating generic checklist implementations // See 'Todo' for an implementation example type ChecklistItem struct { diff --git a/generator/textwidget.go b/generator/textwidget.go index 3e3fd34f..dabb68e8 100644 --- a/generator/textwidget.go +++ b/generator/textwidget.go @@ -46,14 +46,14 @@ func main() { /* -------------------- Unexported Functions -------------------- */ -func createModuleDirectory(data struct { Name string }) { +func createModuleDirectory(data struct{ Name string }) { err := os.MkdirAll(strings.ToLower(fmt.Sprintf("modules/%s", data.Name)), os.ModePerm) if err != nil { fmt.Println(err.Error()) } } -func generateWidgetFile(data struct { Name string }) { +func generateWidgetFile(data struct{ Name string }) { tpl, _ := template.New("textwidget.tpl").Funcs(template.FuncMap{ "Lower": strings.ToLower, }).ParseFiles("generator/textwidget.tpl") @@ -67,8 +67,8 @@ func generateWidgetFile(data struct { Name string }) { tpl.Execute(out, data) } -func generateSettingsFile(data struct { Name string }) { - tpl, _ := template.New("settings.tpl").Funcs(template.FuncMap{ +func generateSettingsFile(data struct{ Name string }) { + tpl, _ := template.New("settings.tpl").Funcs(template.FuncMap{ "Lower": strings.ToLower, }).ParseFiles("generator/settings.tpl") @@ -79,4 +79,4 @@ func generateSettingsFile(data struct { Name string }) { defer out.Close() tpl.Execute(out, data) -} \ No newline at end of file +} diff --git a/go.mod b/go.mod index f6347a8d..4ccbf037 100644 --- a/go.mod +++ b/go.mod @@ -55,7 +55,6 @@ require ( github.com/xanzy/go-gitlab v0.31.0 github.com/zmb3/spotify v0.0.0-20191010212056-e12fb981aacb github.com/zorkian/go-datadog-api v2.29.0+incompatible - golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550 // indirect golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d golang.org/x/text v0.3.2 google.golang.org/api v0.23.0 diff --git a/go.sum b/go.sum index 8682d2d0..2f8679d1 100644 --- a/go.sum +++ b/go.sum @@ -11,17 +11,22 @@ cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg cloud.google.com/go v0.50.0/go.mod h1:r9sluTvynVuxRIOHXQEHMFffphuXHOMZMycpNR5e6To= cloud.google.com/go v0.52.0/go.mod h1:pXajvRH/6o3+F9jDHZWQ5PbGhn+o8w9qiu/CffaVdO4= cloud.google.com/go v0.53.0/go.mod h1:fp/UouUEsRkN6ryDKNW/Upv/JBKnv6WDthjR6+vze6M= +cloud.google.com/go v0.56.0 h1:WRz29PgAsVEyPSDHyk+0fpEkwEFyfhHn+JbksT6gIL4= cloud.google.com/go v0.56.0/go.mod h1:jr7tqZxxKOVYizybht9+26Z/gUq7tiRzu+ACVAMbKVk= cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE= +cloud.google.com/go/bigquery v1.4.0 h1:xE3CPsOgttP4ACBePh79zTKALtXwn/Edhcr16R5hMWU= cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc= cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= +cloud.google.com/go/datastore v1.1.0 h1:/May9ojXjRkPBNVrq+oWLqmWCkr4OU5uRY29bu0mRyQ= cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk= cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw= +cloud.google.com/go/pubsub v1.2.0 h1:Lpy6hKgdcl7a3WGSfJIFmxmcdjSpP6OmBEfcOv1Y680= cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA= cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw= cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos= +cloud.google.com/go/storage v1.6.0 h1:UDpwYIwla4jHGzZJaEJYx1tOejbgSoNqsAfHAUYe2r8= cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk= code.cloudfoundry.org/bytefmt v0.0.0-20190819182555-854d396b647c h1:2RuXx1+tSNWRjxhY0Bx52kjV2odJQ0a6MTbfTPhGAkg= code.cloudfoundry.org/bytefmt v0.0.0-20190819182555-854d396b647c/go.mod h1:wN/zk7mhREp/oviagqUXY3EwuHhWyOvAdsn5Y4CzOrc= @@ -252,6 +257,7 @@ github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef h1:veQD95Isof8w9 github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e h1:1r7pUrabqp18hOBcwBwiTsbnFeTZHV9eER/QT5JVZxY= github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= @@ -394,6 +400,7 @@ github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCV github.com/json-iterator/go v1.1.7 h1:KfgG9LzI+pYjr4xvmz/5H4FXjokeP+rlHLhv3iH62Fo= github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= +github.com/jstemmer/go-junit-report v0.9.1 h1:6QPYqodiu3GuPL+7mfx+NwDdp2eTkp9IfEUpgAwUN0o= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= github.com/jtolds/gls v4.2.1+incompatible h1:fSuqC+Gmlu6l/ZYAoZzx2pyucC8Xza35fpRVWLVmUEE= github.com/jtolds/gls v4.2.1+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= @@ -623,8 +630,6 @@ github.com/sethgrid/pester v0.0.0-20171127025028-760f8913c048/go.mod h1:Ad7IjTpv github.com/sguiheux/go-coverage v0.0.0-20190710153556-287b082a7197 h1:qu90yDtRE5WEfRT5mn9v0Xz9RaopLguhbPwZKx4dHq8= github.com/sguiheux/go-coverage v0.0.0-20190710153556-287b082a7197/go.mod h1:0hhKrsUsoT7yvxwNGKa+TSYNA26DNWMqReeZEQq/9FI= github.com/shirou/gopsutil v0.0.0-20170406131756-e49a95f3d5f8/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= -github.com/shirou/gopsutil v2.20.3+incompatible h1:0JVooMPsT7A7HqEYdydp/OfjSOYSjhXV7w1hkKj/NPQ= -github.com/shirou/gopsutil v2.20.3+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= github.com/shirou/gopsutil v2.20.4+incompatible h1:cMT4rxS55zx9NVUnCkrmXCsEB/RNfG9SwHY9evtX8Ng= github.com/shirou/gopsutil v2.20.4+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= github.com/sirupsen/logrus v1.0.6/go.mod h1:pMByvHTf9Beacp5x1UXfOR9xyW/9antXMhjMPG0dEzc= @@ -703,8 +708,6 @@ github.com/zmb3/spotify v0.0.0-20191010212056-e12fb981aacb h1:uWB0RGxBo7AToSJ3rv github.com/zmb3/spotify v0.0.0-20191010212056-e12fb981aacb h1:uWB0RGxBo7AToSJ3rvoCZhXtLw4U7XISXSezPewmfic= github.com/zmb3/spotify v0.0.0-20191010212056-e12fb981aacb/go.mod h1:pHsWAmY9PfX7i/uwPZkmWrebc8JbK8FppKbvyevwzSU= github.com/zmb3/spotify v0.0.0-20191010212056-e12fb981aacb/go.mod h1:pHsWAmY9PfX7i/uwPZkmWrebc8JbK8FppKbvyevwzSU= -github.com/zorkian/go-datadog-api v2.28.0+incompatible h1:bh/2jIkDFCZRjkuQKBFdmB+sScAMXf8fctKTT0ae+wE= -github.com/zorkian/go-datadog-api v2.28.0+incompatible/go.mod h1:PkXwHX9CUQa/FpB9ZwAD45N1uhCW4MT/Wj7m36PbKss= github.com/zorkian/go-datadog-api v2.29.0+incompatible h1:uZZg0POZ6tLmVFtjUSaTZYwR6Q6RrHx6f/blTEDn8dA= github.com/zorkian/go-datadog-api v2.29.0+incompatible/go.mod h1:PkXwHX9CUQa/FpB9ZwAD45N1uhCW4MT/Wj7m36PbKss= go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= @@ -716,6 +719,7 @@ go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= go.opencensus.io v0.22.0 h1:C9hSCOW830chIVkdja34wa6Ky+IzWllkUinR+BtRZd4= go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= +go.opencensus.io v0.22.3 h1:8sGtKOrtQqkN1bp2AtX+misvLIlOmsEsNd+9NIcPEm8= go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.uber.org/atomic v1.4.0 h1:cxzIVoETapQEqDhQu3QfnvXAV4AlzcvUCxkVUFw3+EU= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= @@ -807,6 +811,7 @@ golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20190423024810-112230192c58 h1:8gQV6CLnAEikrhgkHFbMAEhagSSnXWGV915qUMm9mrU= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a h1:WXEvlFVvvGxCJLG6REjsT03iWnKLEWinaScsxF2Vm2o= golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180828065106-d99a578cf41b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -843,6 +848,7 @@ golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd h1:xhmwyvizuTgC2qz7ZlMluP20uW+C3Rm0FD/WLDX8884= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200331124033-c3d80250170d h1:nc5K6ox/4lTFbMVSL9WRR81ixkcwXThoiF6yf+R9scA= golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -907,8 +913,6 @@ google.golang.org/api v0.15.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsb google.golang.org/api v0.17.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= google.golang.org/api v0.18.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= google.golang.org/api v0.20.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.22.0 h1:J1Pl9P2lnmYFSJvgs70DKELqHNh8CNWXPbud4njEE2s= -google.golang.org/api v0.22.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= google.golang.org/api v0.23.0 h1:YlvGEOq2NA2my8cZ/9V8BcEO9okD48FlJcdqN0xJL3s= google.golang.org/api v0.23.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= @@ -941,6 +945,7 @@ google.golang.org/genproto v0.0.0-20200122232147-0452cf42e150/go.mod h1:n3cpQtvx google.golang.org/genproto v0.0.0-20200204135345-fa8e72b47b90/go.mod h1:GmwEX6Z4W5gMy59cAlVYjN9JhxgbQH6Gn+gFDQe2lzA= google.golang.org/genproto v0.0.0-20200212174721-66ed5ce911ce/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200224152610-e50cd9704f63/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940 h1:MRHtG0U6SnaUb+s+LhNE1qt1FQ1wlhqr5E4usBKC0uA= google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= @@ -957,6 +962,7 @@ google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8 google.golang.org/grpc v1.27.0 h1:rRYRFMVgRv6E0D70Skyfsr28tDXIuuPZyWGMPdMcnXg= google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.28.0 h1:bO/TA4OxCOummhSf10siHuG7vJOiwh7SpRpFZDkOgl4= google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60= gopkg.in/AlecAivazis/survey.v1 v1.7.1 h1:mzQIVyOPSXJaQWi1m6AFCjrCEPIwQBSOn48Ri8ZpzAg= gopkg.in/AlecAivazis/survey.v1 v1.7.1/go.mod h1:2Ehl7OqkBl3Xb8VmC4oFW2bItAhnUfzIjrOzwRxCrOU= diff --git a/modules/buildkite/settings.go b/modules/buildkite/settings.go index 6a0c67ad..61abc82d 100644 --- a/modules/buildkite/settings.go +++ b/modules/buildkite/settings.go @@ -1,10 +1,11 @@ package buildkite import ( + "os" + "github.com/olebedev/config" "github.com/wtfutil/wtf/cfg" "github.com/wtfutil/wtf/utils" - "os" ) const ( diff --git a/modules/buildkite/widget.go b/modules/buildkite/widget.go index c51f0d6f..0d3ca075 100644 --- a/modules/buildkite/widget.go +++ b/modules/buildkite/widget.go @@ -2,6 +2,7 @@ package buildkite import ( "fmt" + "github.com/rivo/tview" "github.com/wtfutil/wtf/view" ) diff --git a/modules/cds/status/display.go b/modules/cds/status/display.go index ccf97c90..8e01707a 100644 --- a/modules/cds/status/display.go +++ b/modules/cds/status/display.go @@ -85,21 +85,3 @@ func (widget *Widget) displayStatus() string { } return content } - -func getStatusColor(status string) string { - switch status { - case sdk.StatusSuccess: - return "green" - case sdk.StatusBuilding, sdk.StatusWaiting: - return "blue" - case sdk.StatusFail: - return "red" - case sdk.StatusStopped: - return "red" - case sdk.StatusSkipped: - return "grey" - case sdk.StatusDisabled: - return "grey" - } - return "red" -} diff --git a/modules/cmdrunner/widget.go b/modules/cmdrunner/widget.go index d0b900af..aa733e6b 100644 --- a/modules/cmdrunner/widget.go +++ b/modules/cmdrunner/widget.go @@ -128,8 +128,8 @@ func runCommandLoop(widget *Widget) { // The command has exited, print any error messages if err != nil { widget.m.Lock() - _, err := widget.buffer.WriteString(err.Error()) - if err != nil { + _, writeErr := widget.buffer.WriteString(err.Error()) + if writeErr != nil { return } widget.m.Unlock() diff --git a/modules/gcal/client.go b/modules/gcal/client.go index 7fe08d90..8cfb4639 100644 --- a/modules/gcal/client.go +++ b/modules/gcal/client.go @@ -60,8 +60,8 @@ func (widget *Widget) Fetch() ([]*CalEvent, error) { calendarIDs, err := widget.getCalendarIdList(srv) for _, calendarID := range calendarIDs { - calendarEvents, err := srv.Events.List(calendarID).TimeZone(timezone).ShowDeleted(false).TimeMin(startTime).MaxResults(eventLimit).SingleEvents(true).OrderBy("startTime").Do() - if err != nil { + calendarEvents, listErr := srv.Events.List(calendarID).TimeZone(timezone).ShowDeleted(false).TimeMin(startTime).MaxResults(eventLimit).SingleEvents(true).OrderBy("startTime").Do() + if listErr != nil { break } events.Items = append(events.Items, calendarEvents.Items...) diff --git a/modules/gcal/display.go b/modules/gcal/display.go index effb5f15..4973a888 100644 --- a/modules/gcal/display.go +++ b/modules/gcal/display.go @@ -43,7 +43,7 @@ func (widget *Widget) content() (string, string, bool) { timestamp = "" } - title := fmt.Sprintf("[%s]%s", + title = fmt.Sprintf("[%s]%s", widget.titleColor(calEvent), widget.eventSummary(calEvent, calEvent.ConflictsWith(calEvents)), ) diff --git a/modules/github/github_repo.go b/modules/github/github_repo.go index be0bfadc..fb147f0a 100644 --- a/modules/github/github_repo.go +++ b/modules/github/github_repo.go @@ -12,10 +12,9 @@ import ( const ( pullRequestsPath = "/pulls" - issuesPath = "/issues" + issuesPath = "/issues" ) - // GithubRepo defines a new GithubRepo structure type GithubRepo struct { apiKey string diff --git a/modules/gitlab/gitlab_project.go b/modules/gitlab/gitlab_project.go index 332f77ea..01da02f7 100644 --- a/modules/gitlab/gitlab_project.go +++ b/modules/gitlab/gitlab_project.go @@ -19,12 +19,12 @@ func newContext(settings *Settings) (*context, error) { return nil, err } - context := context{ + ctx := &context{ client: gitlabClient, user: user, } - return &context, nil + return ctx, nil } type GitlabProject struct { diff --git a/modules/gitlabtodo/widget.go b/modules/gitlabtodo/widget.go index e6f1c16e..54102c98 100644 --- a/modules/gitlabtodo/widget.go +++ b/modules/gitlabtodo/widget.go @@ -125,8 +125,10 @@ func (widget *Widget) markAsDone() { sel := widget.GetSelected() if sel >= 0 && widget.todos != nil && sel < len(widget.todos) { todo := widget.todos[sel] - widget.gitlabClient.Todos.MarkTodoAsDone(todo.ID) - widget.Refresh() + _, err := widget.gitlabClient.Todos.MarkTodoAsDone(todo.ID) + if err == nil { + widget.Refresh() + } } } diff --git a/modules/gspreadsheets/client.go b/modules/gspreadsheets/client.go index 8ce4cf99..7b7aaa19 100644 --- a/modules/gspreadsheets/client.go +++ b/modules/gspreadsheets/client.go @@ -16,7 +16,6 @@ import ( "os" "os/user" "path/filepath" - "strings" "github.com/wtfutil/wtf/utils" "golang.org/x/oauth2" @@ -39,29 +38,25 @@ func (widget *Widget) Fetch() ([]*sheets.ValueRange, error) { } config, err := google.ConfigFromJSON(b, "https://www.googleapis.com/auth/spreadsheets.readonly") - if err != nil { - log.Fatalf("Unable to get config from JSON. %v", err) return nil, err } + client := getClient(ctx, config) srv, err := sheets.NewService(context.Background(), option.WithHTTPClient(client)) if err != nil { - log.Fatalf("Unable to get create server. %v", err) return nil, err } cells := utils.ToStrs(widget.settings.cellAddresses) - addresses := strings.Join(cells[:], ";") responses := make([]*sheets.ValueRange, len(cells)) for i := 0; i < len(cells); i++ { - resp, err := srv.Spreadsheets.Values.Get(widget.settings.sheetID, cells[i]).Do() - if err != nil { - log.Fatalf("Error fetching cells %s", addresses) - return nil, err + resp, getErr := srv.Spreadsheets.Values.Get(widget.settings.sheetID, cells[i]).Do() + if getErr != nil { + return nil, getErr } responses[i] = resp } diff --git a/modules/ipaddresses/ipinfo/widget.go b/modules/ipaddresses/ipinfo/widget.go index c162e50b..ce6fdf01 100644 --- a/modules/ipaddresses/ipinfo/widget.go +++ b/modules/ipaddresses/ipinfo/widget.go @@ -128,7 +128,7 @@ func getMyIP() (ip net.IP, v6 bool) { if err != nil { return } - defer conn.Close() + defer func() { _ = conn.Close() }() addr := conn.LocalAddr().(*net.TCPAddr) ip = addr.IP diff --git a/modules/jenkins/client.go b/modules/jenkins/client.go index 327ea07d..5fcbb6da 100644 --- a/modules/jenkins/client.go +++ b/modules/jenkins/client.go @@ -45,7 +45,7 @@ func (widget *Widget) Create(jenkinsURL string, username string, apiKey string) return view, err } - respJobs := make([]Job, 0, len(view.Jobs) + len(view.ActiveConfigurations)) + respJobs := make([]Job, 0, len(view.Jobs)+len(view.ActiveConfigurations)) respJobs = append(append(respJobs, view.Jobs...), view.ActiveConfigurations...) jobs := make([]Job, 0) diff --git a/modules/jenkins/view.go b/modules/jenkins/view.go index 65f525ca..e83b3328 100644 --- a/modules/jenkins/view.go +++ b/modules/jenkins/view.go @@ -1,9 +1,9 @@ package jenkins type View struct { - Description string `json:"description"` - Jobs []Job `json:"jobs"` - ActiveConfigurations []Job `json:"activeConfigurations"` - Name string `json:"name"` - Url string `json:"url"` + Description string `json:"description"` + Jobs []Job `json:"jobs"` + ActiveConfigurations []Job `json:"activeConfigurations"` + Name string `json:"name"` + Url string `json:"url"` } diff --git a/modules/jenkins/widget.go b/modules/jenkins/widget.go index 782a9808..8a6d0cd7 100644 --- a/modules/jenkins/widget.go +++ b/modules/jenkins/widget.go @@ -2,10 +2,11 @@ package jenkins import ( "fmt" + "net/url" + "github.com/rivo/tview" "github.com/wtfutil/wtf/utils" "github.com/wtfutil/wtf/view" - "net/url" ) type Widget struct { diff --git a/modules/jira/issues.go b/modules/jira/issues.go index 35bedde1..9c6fd9c5 100644 --- a/modules/jira/issues.go +++ b/modules/jira/issues.go @@ -12,7 +12,7 @@ type Issue struct { type IssueFields struct { Summary string `json:"summary"` - IssueType *IssueType `json:"issuetype"` + IssueType *IssueType `json:"issuetype"` IssueStatus *IssueStatus `json:"status"` } @@ -26,7 +26,7 @@ type IssueType struct { } type IssueStatus struct { - ISelf string `json:"self"` - IDescription string `json:"description"` - IName string `json:"name"` + ISelf string `json:"self"` + IDescription string `json:"description"` + IName string `json:"name"` } diff --git a/modules/pihole/client.go b/modules/pihole/client.go index 4a1de2bb..a5515dca 100644 --- a/modules/pihole/client.go +++ b/modules/pihole/client.go @@ -59,7 +59,7 @@ func getStatus(c http.Client, apiURL string) (status Status, err error) { } defer func() { - if err := resp.Body.Close(); err != nil { + if closeErr := resp.Body.Close(); closeErr != nil { return } }() @@ -72,7 +72,7 @@ func getStatus(c http.Client, apiURL string) (status Status, err error) { var rBody []byte if rBody, err = ioutil.ReadAll(resp.Body); err != nil { - return status, fmt.Errorf(" failed to read status response\n") + return status, fmt.Errorf(" failed to read status response") } if err = json.Unmarshal(rBody, &status); err != nil { @@ -120,7 +120,7 @@ func getTopItems(c http.Client, settings *Settings) (ti TopItems, err error) { } defer func() { - if err := resp.Body.Close(); err != nil { + if closeErr := resp.Body.Close(); closeErr != nil { return } }() @@ -186,7 +186,7 @@ func getTopClients(c http.Client, settings *Settings) (tc TopClients, err error) } defer func() { - if err := resp.Body.Close(); err != nil { + if closeErr := resp.Body.Close(); closeErr != nil { return } }() @@ -220,13 +220,13 @@ func getQueryTypes(c http.Client, settings *Settings) (qt QueryTypes, err error) var url *url2.URL if url, err = url2.Parse(settings.apiUrl); err != nil { - return qt, fmt.Errorf(" failed to parse API URL\n %s\n", parseError(err)) + return qt, fmt.Errorf(" failed to parse API URL\n %s", parseError(err)) } var query url2.Values if query, err = url2.ParseQuery(url.RawQuery); err != nil { - return qt, fmt.Errorf(" failed to parse query\n %s\n", parseError(err)) + return qt, fmt.Errorf(" failed to parse query\n %s", parseError(err)) } query.Add("getQueryTypes", strconv.Itoa(settings.showTopClients)) @@ -245,7 +245,7 @@ func getQueryTypes(c http.Client, settings *Settings) (qt QueryTypes, err error) } defer func() { - if err := resp.Body.Close(); err != nil { + if closeErr := resp.Body.Close(); closeErr != nil { return } }() @@ -285,7 +285,7 @@ func checkServer(c http.Client, apiURL string) error { if req, err = http.NewRequest("GET", fmt.Sprintf("%s?version", url.String()), nil); err != nil { - return fmt.Errorf("invalid request: %s\n", parseError(err)) + return fmt.Errorf("invalid request: %s", parseError(err)) } var resp *http.Response diff --git a/modules/spacex/client.go b/modules/spacex/client.go index 632906da..b6a2ab71 100644 --- a/modules/spacex/client.go +++ b/modules/spacex/client.go @@ -1,8 +1,9 @@ package spacex import ( - "github.com/wtfutil/wtf/utils" "net/http" + + "github.com/wtfutil/wtf/utils" ) const ( diff --git a/modules/spacex/widget.go b/modules/spacex/widget.go index 61e9367f..492cf512 100644 --- a/modules/spacex/widget.go +++ b/modules/spacex/widget.go @@ -2,17 +2,17 @@ package spacex import ( "fmt" + "time" + "github.com/rivo/tview" "github.com/wtfutil/wtf/view" "github.com/wtfutil/wtf/wtf" - "time" ) type Widget struct { view.TextWidget settings *Settings err error - launch Launch } func NewWidget(app *tview.Application, settings *Settings) *Widget { diff --git a/modules/spotifyweb/widget.go b/modules/spotifyweb/widget.go index 9c71a69b..5c166f44 100644 --- a/modules/spotifyweb/widget.go +++ b/modules/spotifyweb/widget.go @@ -170,12 +170,13 @@ func (widget *Widget) HelpText() string { } func (w *Widget) createOutput() (string, string, bool) { - err := w.refreshSpotifyInfos() var output string + + err := w.refreshSpotifyInfos() if err != nil { output = err.Error() } else { - output := utils.CenterText(fmt.Sprintf("[green]Now %v [white]\n", w.Info.Status), w.CommonSettings().Width) + output += utils.CenterText(fmt.Sprintf("[green]Now %v [white]\n", w.Info.Status), w.CommonSettings().Width) output += utils.CenterText(fmt.Sprintf("[green]Title:[white] %v\n", w.Info.Title), w.CommonSettings().Width) output += utils.CenterText(fmt.Sprintf("[green]Artist:[white] %v\n", w.Info.Artists), w.CommonSettings().Width) output += utils.CenterText(fmt.Sprintf("[green]Album:[white] %v\n", w.Info.Album), w.CommonSettings().Width) diff --git a/modules/subreddit/widget.go b/modules/subreddit/widget.go index 2a7756df..e9fc7762 100644 --- a/modules/subreddit/widget.go +++ b/modules/subreddit/widget.go @@ -44,16 +44,16 @@ func (widget *Widget) Refresh() { widget.links = nil widget.SetItemCount(0) } else { - if len(links) <= widget.settings.numberOfPosts { - widget.links = links - widget.SetItemCount(len(widget.links)) - widget.err = nil - } else { - widget.links = links[:widget.settings.numberOfPosts] - widget.SetItemCount(len(widget.links)) - widget.err = nil - } - } + if len(links) <= widget.settings.numberOfPosts { + widget.links = links + widget.SetItemCount(len(widget.links)) + widget.err = nil + } else { + widget.links = links[:widget.settings.numberOfPosts] + widget.SetItemCount(len(widget.links)) + widget.err = nil + } + } widget.Render() } diff --git a/modules/twitch/client.go b/modules/twitch/client.go index 1c478ba4..ed3a0097 100644 --- a/modules/twitch/client.go +++ b/modules/twitch/client.go @@ -2,6 +2,7 @@ package twitch import ( "fmt" + "github.com/nicklaw5/helix" ) diff --git a/modules/twitch/settings.go b/modules/twitch/settings.go index 612c49d5..60096c68 100644 --- a/modules/twitch/settings.go +++ b/modules/twitch/settings.go @@ -1,10 +1,11 @@ package twitch import ( + "os" + "github.com/olebedev/config" "github.com/wtfutil/wtf/cfg" "github.com/wtfutil/wtf/utils" - "os" ) const ( diff --git a/modules/twitch/widget.go b/modules/twitch/widget.go index fc948534..2cbaa63d 100644 --- a/modules/twitch/widget.go +++ b/modules/twitch/widget.go @@ -3,6 +3,7 @@ package twitch import ( "errors" "fmt" + "github.com/nicklaw5/helix" "github.com/rivo/tview" "github.com/wtfutil/wtf/utils" diff --git a/modules/weatherservices/arpansagovau/widget.go b/modules/weatherservices/arpansagovau/widget.go index 64ee8d34..3d29c220 100644 --- a/modules/weatherservices/arpansagovau/widget.go +++ b/modules/weatherservices/arpansagovau/widget.go @@ -2,6 +2,7 @@ package arpansagovau import ( "fmt" + "github.com/rivo/tview" "github.com/wtfutil/wtf/view" ) diff --git a/utils/text.go b/utils/text.go index 0c694a38..83d22b05 100644 --- a/utils/text.go +++ b/utils/text.go @@ -2,11 +2,12 @@ package utils import ( "fmt" - "golang.org/x/text/language" - "golang.org/x/text/message" "math" "strings" + "golang.org/x/text/language" + "golang.org/x/text/message" + "github.com/rivo/tview" )