Skip to content

Commit db2e85b

Browse files
committed
Prune dead code
1 parent 61145ea commit db2e85b

3 files changed

Lines changed: 14 additions & 19 deletions

File tree

command/clean.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,10 @@ func (c CleanCmd) Run(args []string) int {
6262
}
6363

6464
if confirm {
65-
var (
66-
m string
67-
err error
68-
)
69-
70-
if m, err = project.Clean(util.AfterNow(days), terminalOnly); err != nil {
65+
if err := project.Clean(util.AfterNow(days), terminalOnly); err != nil {
7166
c.Ui.Error(err.Error())
7267
return 1
7368
}
74-
c.Ui.Output(m)
7569
}
7670
return 0
7771
}

project/project.go

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -255,27 +255,25 @@ func Uninitialize() (string, error) {
255255
}
256256

257257
//Clean removes any event or metrics files from project in the current working directory
258-
func Clean(dr util.DateRange, terminalOnly bool) (string, error) {
258+
func Clean(dr util.DateRange, terminalOnly bool) error {
259259
wd, err := os.Getwd()
260260
if err != nil {
261-
return "", err
261+
return err
262262
}
263263

264264
projRoot, err := scm.RootPath(wd)
265265
if err != nil {
266-
return "", fmt.Errorf(
267-
"Unable to clean, Git repository not found in %s", projRoot)
266+
return fmt.Errorf("Unable to clean, Git repository not found in %s", projRoot)
268267
}
269268

270269
gtmPath := filepath.Join(projRoot, GTMDir)
271270
if _, err := os.Stat(gtmPath); os.IsNotExist(err) {
272-
return "", fmt.Errorf(
273-
"Unable to clean GTM data, %s directory not found", gtmPath)
271+
return fmt.Errorf("Unable to clean GTM data, %s directory not found", gtmPath)
274272
}
275273

276274
files, err := ioutil.ReadDir(gtmPath)
277275
if err != nil {
278-
return "", err
276+
return err
279277
}
280278
for _, f := range files {
281279
if !strings.HasSuffix(f.Name(), ".event") &&
@@ -289,18 +287,21 @@ func Clean(dr util.DateRange, terminalOnly bool) (string, error) {
289287
if terminalOnly && strings.HasSuffix(f.Name(), ".event") {
290288
b, err := ioutil.ReadFile(fp)
291289
if err != nil {
292-
return "", err
290+
return err
293291
}
294292
if !strings.Contains(string(b), "terminal.app") {
295293
continue
296294
}
297295
}
298296
if err := os.Remove(fp); err != nil {
299-
return "", err
297+
return err
300298
}
301299
}
300+
return nil
301+
}
302302

303-
return "", nil
303+
func Stash() error {
304+
return nil
304305
}
305306

306307
// Paths returns the root git repo and gtm paths

project/project_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ func TestClean(t *testing.T) {
266266
}
267267

268268
// lets only delete terminal events
269-
_, err = Clean(util.AfterNow(0), true)
269+
err = Clean(util.AfterNow(0), true)
270270
files, err := ioutil.ReadDir(gtmPath)
271271
if err != nil {
272272
t.Fatalf("Want error nil got %s", err)
@@ -278,7 +278,7 @@ func TestClean(t *testing.T) {
278278
}
279279

280280
// lets clean all events
281-
_, err = Clean(util.AfterNow(0), false)
281+
err = Clean(util.AfterNow(0), false)
282282
files, err = ioutil.ReadDir(gtmPath)
283283
if err != nil {
284284
t.Fatalf("Want error nil got %s", err)

0 commit comments

Comments
 (0)