Skip to content

Commit cb62914

Browse files
committed
golint cleanup
1 parent fa291c0 commit cb62914

29 files changed

Lines changed: 154 additions & 140 deletions

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ lint:
3838
gosimple --tests=false --tags '$(BUILD_TAGS)' $(PKGS)
3939
-@$(call color_echo, 4, "\nUnused"); \
4040
unused --tests=false --tags '$(BUILD_TAGS)' $(PKGS)
41+
-@$(call color_echo, 4, "\nGo Lint"); \
42+
golint $(PKGS)
4143
-@$(call color_echo, 4, "\nGo Format"); \
4244
go fmt $(PKGS)
4345
-@$(call color_echo, 4, "\nLicense Check"); \

command/clean.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515

1616
// CleanCmd contains method for clean method
1717
type CleanCmd struct {
18-
Ui cli.Ui
18+
UI cli.Ui
1919
}
2020

2121
// NewClean returns a new CleanCmd struct
@@ -47,14 +47,14 @@ func (c CleanCmd) Run(args []string) int {
4747
cmdFlags.BoolVar(&yes, "yes", false, "")
4848
cmdFlags.BoolVar(&terminalOnly, "terminal-only", false, "")
4949
cmdFlags.IntVar(&days, "days", 0, "")
50-
cmdFlags.Usage = func() { c.Ui.Output(c.Help()) }
50+
cmdFlags.Usage = func() { c.UI.Output(c.Help()) }
5151
if err := cmdFlags.Parse(args); err != nil {
5252
return 1
5353
}
5454

5555
confirm := yes
5656
if !confirm {
57-
response, err := c.Ui.Ask("Delete pending time data (y/n)?")
57+
response, err := c.UI.Ask("Delete pending time data (y/n)?")
5858
if err != nil {
5959
return 0
6060
}
@@ -63,7 +63,7 @@ func (c CleanCmd) Run(args []string) int {
6363

6464
if confirm {
6565
if err := project.Clean(util.AfterNow(days), terminalOnly); err != nil {
66-
c.Ui.Error(err.Error())
66+
c.UI.Error(err.Error())
6767
return 1
6868
}
6969
}

command/clean_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ func TestCleanYes(t *testing.T) {
1919
repo.Seed()
2020
os.Chdir(repo.Workdir())
2121

22-
(InitCmd{Ui: new(cli.MockUi)}).Run([]string{})
22+
(InitCmd{UI: new(cli.MockUi)}).Run([]string{})
2323

2424
ui := new(cli.MockUi)
25-
c := CleanCmd{Ui: ui}
25+
c := CleanCmd{UI: ui}
2626

2727
args := []string{"-yes"}
2828
rc := c.Run(args)
@@ -38,10 +38,10 @@ func TestTerminalOnly(t *testing.T) {
3838
repo.Seed()
3939
os.Chdir(repo.Workdir())
4040

41-
(InitCmd{Ui: new(cli.MockUi)}).Run([]string{})
41+
(InitCmd{UI: new(cli.MockUi)}).Run([]string{})
4242

4343
ui := new(cli.MockUi)
44-
c := CleanCmd{Ui: ui}
44+
c := CleanCmd{UI: ui}
4545

4646
args := []string{"-terminal-only", "-yes"}
4747
rc := c.Run(args)
@@ -53,7 +53,7 @@ func TestTerminalOnly(t *testing.T) {
5353

5454
func TestCleanInvalidOption(t *testing.T) {
5555
ui := new(cli.MockUi)
56-
c := CleanCmd{Ui: ui}
56+
c := CleanCmd{UI: ui}
5757

5858
args := []string{"-invalid"}
5959
rc := c.Run(args)

command/commit.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414

1515
// CommitCmd struct contain methods for commit command
1616
type CommitCmd struct {
17-
Ui cli.Ui
17+
UI cli.Ui
1818
}
1919

2020
// NewCommit returns new CommitCmd struct
@@ -42,14 +42,14 @@ func (c CommitCmd) Run(args []string) int {
4242
var yes bool
4343
cmdFlags := flag.NewFlagSet("commit", flag.ContinueOnError)
4444
cmdFlags.BoolVar(&yes, "yes", false, "")
45-
cmdFlags.Usage = func() { c.Ui.Output(c.Help()) }
45+
cmdFlags.Usage = func() { c.UI.Output(c.Help()) }
4646
if err := cmdFlags.Parse(args); err != nil {
4747
return 1
4848
}
4949

5050
confirm := yes
5151
if !confirm {
52-
response, err := c.Ui.Ask("Save time for last commit (y/n)?")
52+
response, err := c.UI.Ask("Save time for last commit (y/n)?")
5353
if err != nil {
5454
return 0
5555
}
@@ -58,7 +58,7 @@ func (c CommitCmd) Run(args []string) int {
5858

5959
if confirm {
6060
if _, err := metric.Process(false); err != nil {
61-
c.Ui.Error(err.Error())
61+
c.UI.Error(err.Error())
6262
return 1
6363
}
6464
}

command/commit_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ func TestCommitDefaultOptions(t *testing.T) {
1919
repo.Seed()
2020
os.Chdir(repo.Workdir())
2121

22-
(InitCmd{Ui: new(cli.MockUi)}).Run([]string{})
22+
(InitCmd{UI: new(cli.MockUi)}).Run([]string{})
2323

2424
ui := new(cli.MockUi)
25-
c := CommitCmd{Ui: ui}
25+
c := CommitCmd{UI: ui}
2626

2727
args := []string{"-yes"}
2828
rc := c.Run(args)
@@ -34,7 +34,7 @@ func TestCommitDefaultOptions(t *testing.T) {
3434

3535
func TestCommitInvalidOption(t *testing.T) {
3636
ui := new(cli.MockUi)
37-
c := CommitCmd{Ui: ui}
37+
c := CommitCmd{UI: ui}
3838

3939
args := []string{"-invalid"}
4040
rc := c.Run(args)

command/init.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616

1717
// InitCmd contains methods for init command
1818
type InitCmd struct {
19-
Ui cli.Ui
19+
UI cli.Ui
2020
}
2121

2222
// NewInit returns new InitCmd struct
@@ -29,7 +29,7 @@ func (c InitCmd) Help() string {
2929
helpText := `
3030
Usage: gtm init [options]
3131
32-
Initialize a git repository for time tracking.
32+
Initialize a git repository for time tracking.
3333
3434
Options:
3535
@@ -50,16 +50,16 @@ func (c InitCmd) Run(args []string) int {
5050
cmdFlags.BoolVar(&terminal, "terminal", true, "")
5151
cmdFlags.BoolVar(&clearTags, "clear-tags", false, "")
5252
cmdFlags.StringVar(&tags, "tags", "", "")
53-
cmdFlags.Usage = func() { c.Ui.Output(c.Help()) }
53+
cmdFlags.Usage = func() { c.UI.Output(c.Help()) }
5454
if err := cmdFlags.Parse(args); err != nil {
5555
return 1
5656
}
5757
m, err := project.Initialize(terminal, util.Map(strings.Split(tags, ","), strings.TrimSpace), clearTags)
5858
if err != nil {
59-
c.Ui.Error(err.Error())
59+
c.UI.Error(err.Error())
6060
return 1
6161
}
62-
c.Ui.Output(m + "\n")
62+
c.UI.Output(m + "\n")
6363
return 0
6464
}
6565

command/init_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ func TestInitNoGitRepo(t *testing.T) {
1919
repo.Remove()
2020

2121
ui := new(cli.MockUi)
22-
c := InitCmd{Ui: ui}
22+
c := InitCmd{UI: ui}
2323

2424
args := []string{}
2525
rc := c.Run(args)
@@ -36,7 +36,7 @@ func TestInitDefaultOptions(t *testing.T) {
3636
os.Chdir(repo.Workdir())
3737

3838
ui := new(cli.MockUi)
39-
c := InitCmd{Ui: ui}
39+
c := InitCmd{UI: ui}
4040

4141
args := []string{}
4242
rc := c.Run(args)
@@ -65,7 +65,7 @@ func TestInitTerminalFalse(t *testing.T) {
6565
os.Chdir(repo.Workdir())
6666

6767
ui := new(cli.MockUi)
68-
c := InitCmd{Ui: ui}
68+
c := InitCmd{UI: ui}
6969

7070
args := []string{"-terminal=false"}
7171
rc := c.Run(args)
@@ -87,7 +87,7 @@ func TestInitTags(t *testing.T) {
8787
os.Chdir(repo.Workdir())
8888

8989
ui := new(cli.MockUi)
90-
c := InitCmd{Ui: ui}
90+
c := InitCmd{UI: ui}
9191

9292
args := []string{"-tags=t1,t2"}
9393
rc := c.Run(args)
@@ -109,7 +109,7 @@ func TestClearTags(t *testing.T) {
109109
os.Chdir(repo.Workdir())
110110

111111
ui := new(cli.MockUi)
112-
c := InitCmd{Ui: ui}
112+
c := InitCmd{UI: ui}
113113

114114
args := []string{"-clear-tags"}
115115
rc := c.Run(args)
@@ -126,7 +126,7 @@ func TestClearTags(t *testing.T) {
126126

127127
func TestInitInvalidOption(t *testing.T) {
128128
ui := new(cli.MockUi)
129-
c := InitCmd{Ui: ui}
129+
c := InitCmd{UI: ui}
130130

131131
args := []string{"-invalid"}
132132
rc := c.Run(args)

command/record.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424

2525
// RecordCmd contains method for record command
2626
type RecordCmd struct {
27-
Ui cli.Ui
27+
UI cli.Ui
2828
Out *bytes.Buffer
2929
}
3030

@@ -70,13 +70,13 @@ func (c RecordCmd) Run(args []string) int {
7070
cmdFlags.BoolVar(&status, "status", false, "")
7171
cmdFlags.BoolVar(&terminal, "terminal", false, "")
7272
cmdFlags.BoolVar(&longDuration, "long-duration", false, "")
73-
cmdFlags.Usage = func() { c.Ui.Output(c.Help()) }
73+
cmdFlags.Usage = func() { c.UI.Output(c.Help()) }
7474
if err := cmdFlags.Parse(args); err != nil {
7575
return 1
7676
}
7777

7878
if !terminal && len(cmdFlags.Args()) == 0 {
79-
c.Ui.Error("Unable to record, file not provided")
79+
c.UI.Error("Unable to record, file not provided")
8080
return 1
8181
}
8282

@@ -109,7 +109,7 @@ func (c RecordCmd) Run(args []string) int {
109109

110110
wd, err = os.Getwd()
111111
if err != nil {
112-
c.Ui.Error(err.Error())
112+
c.UI.Error(err.Error())
113113
return 1
114114
}
115115
defer func() {
@@ -120,17 +120,17 @@ func (c RecordCmd) Run(args []string) int {
120120

121121
err = os.Chdir(filepath.Dir(fileToRecord))
122122
if err != nil {
123-
c.Ui.Error(err.Error())
123+
c.UI.Error(err.Error())
124124
return 1
125125
}
126126

127127
if commitNote, err = metric.Process(true); err != nil {
128-
c.Ui.Error(err.Error())
128+
c.UI.Error(err.Error())
129129
return 1
130130
}
131131
out, err = report.Status(commitNote, report.OutputOptions{TotalOnly: true, LongDuration: longDuration})
132132
if err != nil {
133-
c.Ui.Error(err.Error())
133+
c.UI.Error(err.Error())
134134
return 1
135135
}
136136
c.output(out)

command/record_test.go

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ func TestRecordInvalidFile(t *testing.T) {
2222
repo.Seed()
2323
os.Chdir(repo.Workdir())
2424

25-
(InitCmd{Ui: new(cli.MockUi)}).Run([]string{})
25+
(InitCmd{UI: new(cli.MockUi)}).Run([]string{})
2626

2727
ui := new(cli.MockUi)
28-
c := RecordCmd{Ui: ui}
28+
c := RecordCmd{UI: ui}
2929

3030
args := []string{"nofile.txt"}
3131
rc := c.Run(args)
@@ -41,10 +41,10 @@ func TestRecordNoFile(t *testing.T) {
4141
repo.Seed()
4242
os.Chdir(repo.Workdir())
4343

44-
(InitCmd{Ui: new(cli.MockUi)}).Run([]string{})
44+
(InitCmd{UI: new(cli.MockUi)}).Run([]string{})
4545

4646
ui := new(cli.MockUi)
47-
c := RecordCmd{Ui: ui}
47+
c := RecordCmd{UI: ui}
4848

4949
args := []string{""}
5050
rc := c.Run(args)
@@ -61,10 +61,10 @@ func TestRecordFile(t *testing.T) {
6161
workdir := repo.Workdir()
6262
os.Chdir(workdir)
6363

64-
(InitCmd{Ui: new(cli.MockUi)}).Run([]string{})
64+
(InitCmd{UI: new(cli.MockUi)}).Run([]string{})
6565

6666
ui := new(cli.MockUi)
67-
c := RecordCmd{Ui: ui}
67+
c := RecordCmd{UI: ui}
6868

6969
args := []string{filepath.Join(workdir, "README")}
7070
rc := c.Run(args)
@@ -95,10 +95,10 @@ func TestRecordFileWithStatus(t *testing.T) {
9595
workdir := repo.Workdir()
9696
os.Chdir(workdir)
9797

98-
(InitCmd{Ui: new(cli.MockUi)}).Run([]string{})
98+
(InitCmd{UI: new(cli.MockUi)}).Run([]string{})
9999

100100
ui := new(cli.MockUi)
101-
c := RecordCmd{Ui: ui, Out: new(bytes.Buffer)}
101+
c := RecordCmd{UI: ui, Out: new(bytes.Buffer)}
102102

103103
args := []string{"-status", filepath.Join(workdir, "README")}
104104
rc := c.Run(args)
@@ -133,10 +133,10 @@ func TestRecordFileWithStatusLongDuration(t *testing.T) {
133133
workdir := repo.Workdir()
134134
os.Chdir(workdir)
135135

136-
(InitCmd{Ui: new(cli.MockUi)}).Run([]string{})
136+
(InitCmd{UI: new(cli.MockUi)}).Run([]string{})
137137

138138
ui := new(cli.MockUi)
139-
c := RecordCmd{Ui: ui, Out: new(bytes.Buffer)}
139+
c := RecordCmd{UI: ui, Out: new(bytes.Buffer)}
140140

141141
args := []string{"-status", "-long-duration", filepath.Join(workdir, "README")}
142142
rc := c.Run(args)
@@ -171,10 +171,10 @@ func TestRecordTerminal(t *testing.T) {
171171
workdir := repo.Workdir()
172172
os.Chdir(workdir)
173173

174-
(InitCmd{Ui: new(cli.MockUi)}).Run([]string{})
174+
(InitCmd{UI: new(cli.MockUi)}).Run([]string{})
175175

176176
ui := new(cli.MockUi)
177-
c := RecordCmd{Ui: ui}
177+
c := RecordCmd{UI: ui}
178178

179179
args := []string{"-terminal"}
180180
rc := c.Run(args)
@@ -205,10 +205,10 @@ func TestRecordTerminalWithStatus(t *testing.T) {
205205
workdir := repo.Workdir()
206206
os.Chdir(workdir)
207207

208-
(InitCmd{Ui: new(cli.MockUi)}).Run([]string{})
208+
(InitCmd{UI: new(cli.MockUi)}).Run([]string{})
209209

210210
ui := new(cli.MockUi)
211-
c := RecordCmd{Ui: ui, Out: new(bytes.Buffer)}
211+
c := RecordCmd{UI: ui, Out: new(bytes.Buffer)}
212212

213213
args := []string{"-terminal", "-status"}
214214
rc := c.Run(args)
@@ -237,7 +237,7 @@ func TestRecordTerminalWithStatus(t *testing.T) {
237237
}
238238
func TestRecordInvalidOption(t *testing.T) {
239239
ui := new(cli.MockUi)
240-
c := RecordCmd{Ui: ui}
240+
c := RecordCmd{UI: ui}
241241

242242
args := []string{"-invalid"}
243243
rc := c.Run(args)

0 commit comments

Comments
 (0)