Skip to content

Commit

Permalink
Merge branch 'master' into add-hackernews-module
Browse files Browse the repository at this point in the history
  • Loading branch information
senorprogrammer committed Aug 3, 2018
2 parents 5c52927 + b93952b commit a40e03f
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 17 deletions.
8 changes: 4 additions & 4 deletions .codeclimate.yml
@@ -1,5 +1,5 @@
version: "2"
checks:
similar-code:
config:
threshold: 3
checks:
similar-code:
config:
threshold: 3
4 changes: 4 additions & 0 deletions Makefile
Expand Up @@ -11,6 +11,10 @@ install:
go install -ldflags="-s -w -X main.version=$(shell git describe --always --abbrev=6) -X main.date=$(shell date +%FT%T%z)"
which wtf

lint:
structcheck ./...
varcheck ./...

run: build
bin/wtf

Expand Down
2 changes: 1 addition & 1 deletion clocks/display.go
Expand Up @@ -8,7 +8,7 @@ import (

func (widget *Widget) display(clocks []Clock) {
if len(clocks) == 0 {
fmt.Fprintf(widget.View, "\n%s", " no timezone data available")
widget.View.SetText(fmt.Sprintf("\n%s", " no timezone data available"))
return
}

Expand Down
2 changes: 1 addition & 1 deletion gerrit/display.go
Expand Up @@ -10,7 +10,7 @@ func (widget *Widget) display() {

project := widget.currentGerritProject()
if project == nil {
fmt.Fprintf(widget.View, "%s", " Gerrit project data is unavailable (1)")
widget.View.SetText(fmt.Sprintf("%s", " Gerrit project data is unavailable (1)"))
return
}

Expand Down
14 changes: 8 additions & 6 deletions gitlab/widget.go
Expand Up @@ -32,13 +32,8 @@ type Widget struct {
}

func NewWidget(app *tview.Application, pages *tview.Pages) *Widget {
apiKey := wtf.Config.UString(
"wtf.mods.gitlab.apiKey",
os.Getenv("WTF_GITLAB_TOKEN"),
)

baseURL := wtf.Config.UString("wtf.mods.gitlab.domain")
gitlab := glb.NewClient(nil, apiKey)
gitlab := glb.NewClient(nil, apiKey())

if baseURL != "" {
gitlab.SetBaseURL(baseURL)
Expand Down Expand Up @@ -92,6 +87,13 @@ func (widget *Widget) Prev() {

/* -------------------- Unexported Functions -------------------- */

func apiKey() string {
return wtf.Config.UString(
"wtf.mods.gitlab.apiKey",
os.Getenv("WTF_GITLAB_TOKEN"),
)
}

func (widget *Widget) buildProjectCollection(projectData map[string]interface{}) []*GitlabProject {
gitlabProjects := []*GitlabProject{}

Expand Down
2 changes: 1 addition & 1 deletion logger/log.go
Expand Up @@ -36,7 +36,7 @@ func Log(msg string) {
return
}

f, err := os.OpenFile(logFilePath(), os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666)
f, err := os.OpenFile(logFilePath(), os.O_RDWR|os.O_CREATE|os.O_APPEND, 0600)
if err != nil {
log.Fatalf("error opening file: %v", err)
}
Expand Down
5 changes: 4 additions & 1 deletion main.go
Expand Up @@ -131,7 +131,10 @@ func refreshAllWidgets() {
}

func setTerm() {
os.Setenv("TERM", Config.UString("wtf.term", os.Getenv("TERM")))
err := os.Setenv("TERM", Config.UString("wtf.term", os.Getenv("TERM")))
if err != nil {
return
}
}

func watchForConfigChanges(app *tview.Application, configFilePath string, grid *tview.Grid, pages *tview.Pages) {
Expand Down
4 changes: 1 addition & 3 deletions travisci/client.go
Expand Up @@ -13,8 +13,6 @@ import (
"github.com/senorprogrammer/wtf/wtf"
)

const APIEnvToken = "WTF_TRAVIS_API_TOKEN"

var TRAVIS_HOSTS = map[bool]string{
false: "travis-ci.org",
true: "travis-ci.com",
Expand Down Expand Up @@ -75,7 +73,7 @@ func travisRequest(path string) (*http.Response, error) {
func apiToken() string {
return wtf.Config.UString(
"wtf.mods.travisci.apiKey",
os.Getenv(APIEnvToken),
os.Getenv("WTF_TRAVIS_API_TOKEN"),
)
}

Expand Down

0 comments on commit a40e03f

Please sign in to comment.