Skip to content

Commit 2b800f2

Browse files
authored
Add go report card (#88)
1 parent 6def595 commit 2b800f2

File tree

2 files changed

+32
-16
lines changed

2 files changed

+32
-16
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
![version](https://img.shields.io/github/v/release/CodeReaper/lane)
22
![tests](https://github.com/CodeReaper/lane/actions/workflows/tests.yaml/badge.svg)
3+
[![Go Report Card](https://goreportcard.com/badge/github.com/codereaper/lane)](https://goreportcard.com/report/github.com/codereaper/lane)
34
![license](https://img.shields.io/github/license/CodeReaper/lane.svg)
45

56
# lane

internal/translations/flags.go

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,29 +18,50 @@ type Flags struct {
1818
}
1919

2020
func (f *Flags) validate() error {
21+
if err := f.checkRequiredFields(); err != nil {
22+
return err
23+
}
24+
25+
isIOS := strings.ToLower(f.Kind) == "ios"
26+
27+
if err := f.checkRequiredFiles(isIOS); err != nil {
28+
return err
29+
}
30+
31+
if isIOS || f.FillIn {
32+
if f.DefaultValueIndex <= 0 {
33+
return fmt.Errorf("main index not provided")
34+
}
35+
}
36+
37+
return nil
38+
}
39+
40+
func (f *Flags) checkRequiredFields() error {
2141
if len(f.Input) == 0 {
2242
return fmt.Errorf("input not provided")
2343
}
24-
if len(f.Kind) == 0 {
25-
return fmt.Errorf("kind not provided")
26-
}
2744
if f.KeyIndex <= 0 {
2845
return fmt.Errorf("index not provided")
2946
}
47+
if len(f.Kind) == 0 {
48+
return fmt.Errorf("kind not provided")
49+
}
3050

31-
isIOS := false
32-
33-
validKind := false
51+
valid := false
3452
for _, v := range validKinds {
35-
if !validKind && v == strings.ToLower(f.Kind) {
36-
validKind = true
53+
if v == strings.ToLower(f.Kind) {
54+
valid = true
3755
}
38-
isIOS = isIOS || strings.ToLower(f.Kind) == "ios"
3956
}
40-
if !validKind {
57+
if !valid {
4158
return fmt.Errorf("invalid kind: %s. Valid kinds are %v", f.Kind, validKinds)
4259
}
4360

61+
return nil
62+
}
63+
64+
func (f *Flags) checkRequiredFiles(isIOS bool) error {
4465
if _, err := os.Stat(f.Input); err != nil {
4566
return err
4667
}
@@ -60,11 +81,5 @@ func (f *Flags) validate() error {
6081
}
6182
}
6283

63-
if isIOS || f.FillIn {
64-
if f.DefaultValueIndex <= 0 {
65-
return fmt.Errorf("main index not provided")
66-
}
67-
}
68-
6984
return nil
7085
}

0 commit comments

Comments
 (0)