Skip to content

Commit 5abbf31

Browse files
committed
Linting cleanup
1 parent 77bca1b commit 5abbf31

4 files changed

Lines changed: 37 additions & 24 deletions

File tree

command/record.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ type RecordCmd struct {
2828
Out *bytes.Buffer
2929
}
3030

31-
func (c RecordCmd) Output(s string) {
31+
func (c RecordCmd) output(s string) {
3232
if c.Out != nil {
3333
fmt.Fprint(c.Out, s)
3434
} else {
@@ -113,7 +113,7 @@ func (c RecordCmd) Run(args []string) int {
113113
c.Ui.Error(err.Error())
114114
return 1
115115
}
116-
c.Output(out)
116+
c.output(out)
117117
}
118118

119119
return 0

command/verify.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ type VerifyCmd struct {
2222
Out *bytes.Buffer
2323
}
2424

25-
func (c VerifyCmd) Output(s string) {
25+
func (c VerifyCmd) output(s string) {
2626
if c.Out != nil {
2727
fmt.Fprint(c.Out, s)
2828
} else {
@@ -59,7 +59,7 @@ func (c VerifyCmd) Run(args []string) int {
5959
return 1
6060
}
6161

62-
c.Output(fmt.Sprintf("%t", valid))
62+
c.output(fmt.Sprintf("%t", valid))
6363
return 0
6464
}
6565

report/report.go

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ func Status(n note.CommitNote, options OutputOptions, projPath ...string) (strin
7373

7474
b := new(bytes.Buffer)
7575
t := template.Must(template.New("Status").Funcs(funcMap).Parse(statusTpl))
76-
cf := ColorFormater{color: options.Color}
76+
cf := colorFormater{color: options.Color}
7777
err := t.Execute(
7878
b,
7979
struct {
@@ -86,7 +86,7 @@ func Status(n note.CommitNote, options OutputOptions, projPath ...string) (strin
8686
projPath,
8787
projName,
8888
commitNoteDetail{Note: n},
89-
cf.White(true),
89+
cf.white(true),
9090
tags,
9191
})
9292

@@ -107,7 +107,7 @@ func CommitSummary(projects []ProjectCommits, options OutputOptions) (string, er
107107

108108
b := new(bytes.Buffer)
109109
t := template.Must(template.New("Commits").Funcs(funcMap).Parse(commitSummaryTpl))
110-
cf := ColorFormater{color: options.Color}
110+
cf := colorFormater{color: options.Color}
111111
err := t.Execute(
112112
b,
113113
struct {
@@ -116,8 +116,8 @@ func CommitSummary(projects []ProjectCommits, options OutputOptions) (string, er
116116
GreenFormat string
117117
}{
118118
lines,
119-
cf.White(true),
120-
cf.Green(false),
119+
cf.white(true),
120+
cf.green(false),
121121
})
122122
if err != nil {
123123
return "", err
@@ -134,7 +134,7 @@ func Commits(projects []ProjectCommits, options OutputOptions) (string, error) {
134134

135135
b := new(bytes.Buffer)
136136
t := template.Must(template.New("CommitSummary").Funcs(funcMap).Parse(commitsTpl))
137-
cf := ColorFormater{color: options.Color}
137+
cf := colorFormater{color: options.Color}
138138
err := t.Execute(
139139
b,
140140
struct {
@@ -145,8 +145,8 @@ func Commits(projects []ProjectCommits, options OutputOptions) (string, error) {
145145
}{
146146
options.FullMessage,
147147
notes,
148-
cf.White(true),
149-
cf.Green(false),
148+
cf.white(true),
149+
cf.green(false),
150150
})
151151
if err != nil {
152152
return "", err
@@ -169,7 +169,7 @@ func Timeline(projects []ProjectCommits, options OutputOptions) (string, error)
169169

170170
b := new(bytes.Buffer)
171171
t := template.Must(template.New("Timeline").Funcs(funcMap).Parse(timelineTpl))
172-
cf := ColorFormater{color: options.Color}
172+
cf := colorFormater{color: options.Color}
173173
err = t.Execute(
174174
b,
175175
struct {
@@ -178,8 +178,8 @@ func Timeline(projects []ProjectCommits, options OutputOptions) (string, error)
178178
GreenFormat string
179179
}{
180180
timeline,
181-
cf.White(true),
182-
cf.Green(false),
181+
cf.white(true),
182+
cf.green(false),
183183
})
184184
if err != nil {
185185
return "", err
@@ -202,7 +202,7 @@ func TimelineCommits(projects []ProjectCommits, options OutputOptions) (string,
202202

203203
b := new(bytes.Buffer)
204204
t := template.Must(template.New("Timeline").Funcs(funcMap).Parse(timelineCommitTpl))
205-
cf := ColorFormater{color: options.Color}
205+
cf := colorFormater{color: options.Color}
206206
err = t.Execute(
207207
b,
208208
struct {
@@ -211,8 +211,8 @@ func TimelineCommits(projects []ProjectCommits, options OutputOptions) (string,
211211
GreenFormat string
212212
}{
213213
timeline,
214-
cf.White(true),
215-
cf.Green(false),
214+
cf.white(true),
215+
cf.green(false),
216216
})
217217
if err != nil {
218218
return "", err
@@ -244,31 +244,31 @@ func Files(projects []ProjectCommits, options OutputOptions) (string, error) {
244244

245245
}
246246

247-
type ColorFormater struct {
247+
type colorFormater struct {
248248
color bool
249249
}
250250

251-
func (c ColorFormater) HasColor() bool {
251+
func (c colorFormater) hasColor() bool {
252252
return (c.color || isatty.IsTerminal(os.Stdout.Fd())) && runtime.GOOS != "windows"
253253
}
254254

255-
func (c ColorFormater) White(bold bool) string {
255+
func (c colorFormater) white(bold bool) string {
256256
var attrBold int
257257
if bold {
258258
attrBold = 1
259259
}
260-
if c.HasColor() {
260+
if c.hasColor() {
261261
return fmt.Sprintf("\033[%d;%dm%%s\033[0m", attrBold, 97)
262262
}
263263
return "%s"
264264
}
265265

266-
func (c ColorFormater) Green(bold bool) string {
266+
func (c colorFormater) green(bold bool) string {
267267
var attrBold int
268268
if bold {
269269
attrBold = 1
270270
}
271-
if c.HasColor() {
271+
if c.hasColor() {
272272
return fmt.Sprintf("\033[%d;%dm%%s\033[0m", attrBold, 32)
273273
}
274274
return "%s"

util/date.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,23 @@ import (
1515
// This allows for manipulating system time during testing
1616
var Now = func() time.Time { return time.Now() }
1717

18+
// DataRange creates predefined date ranges and validates if dates are within the range
1819
type DateRange struct {
1920
Start time.Time
2021
End time.Time
2122
}
2223

24+
// IsSet returns true if the date range has a starting and/or ending date
2325
func (d DateRange) IsSet() bool {
2426
return !d.Start.IsZero() || !d.End.IsZero()
2527
}
2628

29+
// String returns a date range as a string
2730
func (d DateRange) String() string {
2831
return fmt.Sprintf("%s - %s", d.Start.Format(time.UnixDate), d.End.Format(time.UnixDate))
2932
}
3033

34+
// Within determines if a date is within the date range
3135
func (r DateRange) Within(t time.Time) bool {
3236
switch {
3337
case !r.Start.IsZero() && !r.End.IsZero():
@@ -42,11 +46,13 @@ func (r DateRange) Within(t time.Time) bool {
4246

4347
}
4448

49+
// AfterNow returns a date range ending n days in the past
4550
func AfterNow(n int) DateRange {
4651
end := now.New(Now()).EndOfDay().AddDate(0, 0, -n)
4752
return DateRange{End: end}
4853
}
4954

55+
// TodayRange returns a date range for today
5056
func TodayRange() DateRange {
5157
now := now.New(Now())
5258

@@ -56,6 +62,7 @@ func TodayRange() DateRange {
5662
return DateRange{Start: start, End: end}
5763
}
5864

65+
// YesterdayRange returns a date range for yesterday
5966
func YesterdayRange() DateRange {
6067
now := now.New(Now())
6168

@@ -65,6 +72,7 @@ func YesterdayRange() DateRange {
6572
return DateRange{Start: start, End: end}
6673
}
6774

75+
// ThisWeekRange returns a date range for this week
6876
func ThisWeekRange() DateRange {
6977
now := now.New(Now())
7078

@@ -74,6 +82,7 @@ func ThisWeekRange() DateRange {
7482
return DateRange{End: end, Start: start}
7583
}
7684

85+
// LastWeekRange returns a date for last week
7786
func LastWeekRange() DateRange {
7887
now := now.New(Now())
7988

@@ -83,6 +92,7 @@ func LastWeekRange() DateRange {
8392
return DateRange{End: end, Start: start}
8493
}
8594

95+
// ThisMonthRange returns a date range for this month
8696
func ThisMonthRange() DateRange {
8797
now := now.New(Now())
8898

@@ -92,6 +102,7 @@ func ThisMonthRange() DateRange {
92102
return DateRange{End: end, Start: start}
93103
}
94104

105+
// LastMonthRange returns a date range for last month
95106
func LastMonthRange() DateRange {
96107
now := now.New(Now())
97108

@@ -101,6 +112,7 @@ func LastMonthRange() DateRange {
101112
return DateRange{End: end, Start: start}
102113
}
103114

115+
// ThisYearRange returns a date range for this year
104116
func ThisYearRange() DateRange {
105117
now := now.New(Now())
106118

@@ -110,6 +122,7 @@ func ThisYearRange() DateRange {
110122
return DateRange{End: end, Start: start}
111123
}
112124

125+
// LastYearRange returns a date range for last year
113126
func LastYearRange() DateRange {
114127
now := now.New(Now())
115128

0 commit comments

Comments
 (0)