Skip to content

Commit 11f134e

Browse files
committed
Tidy up
1 parent 8fa3005 commit 11f134e

38 files changed

+84
-201
lines changed

.golangci.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@ disable-all = true
66
enable = [
77
"deadcode",
88
"goconst",
9+
"gocritic",
910
"gofmt",
1011
"goimports",
12+
"gosimple",
1113
"ineffassign",
1214
"scopelint",
1315
"staticcheck",
1416
"stylecheck",
1517
"unconvert",
1618
"unused",
17-
# "maligned",
18-
# "lll",
19-
# "prealloc",
19+
"whitespace",
2020
]
2121

2222
[linter-settings]

alfred.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ type Alfred struct {
5252
// It accepts one optional Env argument. If an Env is passed, Alfred
5353
// is initialised from that instead of the system environment.
5454
func NewAlfred(env ...Env) *Alfred {
55-
5655
var e Env
5756

5857
if len(env) > 0 {
@@ -71,7 +70,6 @@ func (a *Alfred) Search(query string) error {
7170

7271
// Browse tells Alfred to open path in navigation mode.
7372
func (a *Alfred) Browse(path string) error {
74-
7573
var err error
7674

7775
if path, err = filepath.Abs(path); err != nil {
@@ -88,15 +86,13 @@ func (a *Alfred) SetTheme(name string) error {
8886

8987
// Action tells Alfred to show File Actions for path(s).
9088
func (a *Alfred) Action(path ...string) error {
91-
9289
if len(path) == 0 {
9390
return nil
9491
}
9592

9693
var paths []string
9794

9895
for _, p := range path {
99-
10096
p, err := filepath.Abs(p)
10197
if err != nil {
10298
return fmt.Errorf("[action] couldn't make path absolute (%s): %v", p, err)
@@ -114,7 +110,6 @@ func (a *Alfred) Action(path ...string) error {
114110
// workflow whose trigger should be run.
115111
// If not specified, it defaults to the current workflow's.
116112
func (a *Alfred) RunTrigger(name, query string, bundleID ...string) error {
117-
118113
var bid string
119114
if len(bundleID) > 0 {
120115
bid = bundleID[0]

azure-pipelines.yml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
1-
# Go
2-
# Build your Go project.
3-
# Add steps that test, save build artifacts, deploy, and more:
41
# https://docs.microsoft.com/azure/devops/pipelines/languages/go
52

63
trigger:
7-
- master
4+
batch: true
5+
paths:
6+
exclude:
7+
- README.md
8+
- LICENCE
9+
- TODO
10+
- icon.*
11+
- env
12+
- bench.py
13+
- modd.conf
14+
- .gitignore
15+
- .travis.yml
16+
- bin/*
817

918
pool:
1019
vmImage: 'macOS-10.13'

background_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ func TestWorkflow_RunInBackground(t *testing.T) {
2121
t.Parallel()
2222

2323
withTestWf(func(wf *Workflow) {
24-
2524
jobName := "sleep"
2625

2726
cmd := exec.Command("sleep", "5")

cache.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,9 @@ func (c Cache) Age(name string) (time.Duration, error) {
185185
p := c.path(name)
186186
fi, err := os.Stat(p)
187187
if err != nil {
188-
return time.Duration(0), err
188+
return 0, err
189189
}
190-
return time.Now().Sub(fi.ModTime()), nil
190+
return time.Since(fi.ModTime()), nil
191191
}
192192

193193
// path returns the path to a named file within cache directory.

cache_examples_test.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
)
1212

1313
func ExampleCache() {
14-
1514
var (
1615
// Cache "key" (filename) and the value to store
1716
name = "LastOpened"
@@ -62,7 +61,6 @@ func ExampleCache() {
6261
// LoadOrStore loads data from cache if they're fresh enough, otherwise it calls
6362
// the reload function for new data (which it caches).
6463
func ExampleCache_LoadOrStore() {
65-
6664
var (
6765
name = "Expiring"
6866
data = []byte("test")
@@ -83,7 +81,6 @@ func ExampleCache_LoadOrStore() {
8381

8482
// Called by LoadOrStore when cache is empty or has expired
8583
reload := func() ([]byte, error) {
86-
8784
// Log call count
8885
reloadCount++
8986
fmt.Printf("reload #%d\n", reloadCount)
@@ -115,7 +112,7 @@ func ExampleCache_LoadOrStore() {
115112
fmt.Println(string(out) == string(data)) // -> true
116113

117114
// Wait for cache to expire, then try again
118-
time.Sleep(time.Millisecond + maxAge - time.Now().Sub(start))
115+
time.Sleep(time.Millisecond + maxAge - time.Since(start))
119116

120117
// reload is called again
121118
out, err = c.LoadOrStore(name, maxAge, reload)
@@ -138,7 +135,6 @@ func ExampleCache_LoadOrStore() {
138135

139136
// LoadOrStoreJSON marshals JSON to/from the cache.
140137
func ExampleCache_LoadOrStoreJSON() {
141-
142138
var (
143139
name = "Host"
144140
maxAge = time.Second * 5
@@ -161,7 +157,6 @@ func ExampleCache_LoadOrStoreJSON() {
161157
// Normally, this function would do something that takes some time, like
162158
// fetch data from the web or an application.
163159
reload := func() (interface{}, error) {
164-
165160
fmt.Println("reload")
166161

167162
return &host{

config.go

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ type Config struct {
8484
// It accepts one optional Env argument. If an Env is passed, Config
8585
// is initialised from that instead of the system environment.
8686
func NewConfig(env ...Env) *Config {
87-
8887
var e Env
8988
if len(env) > 0 {
9089
e = env[0]
@@ -103,7 +102,6 @@ func NewConfig(env ...Env) *Config {
103102
//
104103
// If a variable is set, but empty, its value is used.
105104
func (cfg *Config) Get(key string, fallback ...string) string {
106-
107105
var fb string
108106

109107
if len(fallback) > 0 {
@@ -129,7 +127,6 @@ func (cfg *Config) GetString(key string, fallback ...string) string {
129127
// tries to parse the number with strconv.ParseFloat() and truncate it to an
130128
// int.
131129
func (cfg *Config) GetInt(key string, fallback ...int) int {
132-
133130
var fb int
134131

135132
if len(fallback) > 0 {
@@ -154,7 +151,6 @@ func (cfg *Config) GetInt(key string, fallback ...int) int {
154151
//
155152
// Values are parsed with strconv.ParseFloat().
156153
func (cfg *Config) GetFloat(key string, fallback ...float64) float64 {
157-
158154
var fb float64
159155

160156
if len(fallback) > 0 {
@@ -179,7 +175,6 @@ func (cfg *Config) GetFloat(key string, fallback ...float64) float64 {
179175
//
180176
// Values are parsed with time.ParseDuration().
181177
func (cfg *Config) GetDuration(key string, fallback ...time.Duration) time.Duration {
182-
183178
var fb time.Duration
184179

185180
if len(fallback) > 0 {
@@ -204,7 +199,6 @@ func (cfg *Config) GetDuration(key string, fallback ...time.Duration) time.Durat
204199
//
205200
// Values are parsed with strconv.ParseBool().
206201
func (cfg *Config) GetBool(key string, fallback ...bool) bool {
207-
208202
var fb bool
209203

210204
if len(fallback) > 0 {
@@ -229,7 +223,6 @@ func (cfg *Config) GetBool(key string, fallback ...bool) bool {
229223
// workflow whose configuration should be changed.
230224
// If not specified, it defaults to the current workflow's.
231225
func (cfg *Config) Set(key, value string, export bool, bundleID ...string) *Config {
232-
233226
bid := cfg.getBundleID(bundleID...)
234227
opts := map[string]interface{}{
235228
"toValue": value,
@@ -246,7 +239,6 @@ func (cfg *Config) Set(key, value string, export bool, bundleID ...string) *Conf
246239
// workflow whose configuration should be changed.
247240
// If not specified, it defaults to the current workflow's.
248241
func (cfg *Config) Unset(key string, bundleID ...string) *Config {
249-
250242
bid := cfg.getBundleID(bundleID...)
251243
opts := map[string]interface{}{
252244
"inWorkflow": bid,
@@ -261,7 +253,6 @@ func (cfg *Config) Unset(key string, bundleID ...string) *Config {
261253
// Succeed or fail, any accumulated scripts and errors are cleared when Do()
262254
// is called.
263255
func (cfg *Config) Do() error {
264-
265256
if len(cfg.scripts) == 0 {
266257
return errors.New("no commands to run")
267258
}
@@ -275,7 +266,6 @@ func (cfg *Config) Do() error {
275266

276267
// Extract bundle ID from argument or default.
277268
func (cfg *Config) getBundleID(bundleID ...string) string {
278-
279269
if len(bundleID) > 0 {
280270
return bundleID[0]
281271
}
@@ -286,7 +276,6 @@ func (cfg *Config) getBundleID(bundleID ...string) string {
286276

287277
// Add a JavaScript that takes two arguments, a string and an object.
288278
func (cfg *Config) addScript(script, name string, opts map[string]interface{}) *Config {
289-
290279
script = fmt.Sprintf(script, util.QuoteJS(scriptAppName()), util.QuoteJS(name), util.QuoteJS(opts))
291280
cfg.scripts = append(cfg.scripts, script)
292281

0 commit comments

Comments
 (0)