linter fixes

code cleanup
changing some test code to ensure uniformity
This commit is contained in:
Ajitem Sahasrabuddhe
2019-08-07 20:14:50 +05:30
parent 521735b760
commit fdba7e0f8c
13 changed files with 303 additions and 324 deletions

44
flag.go
View File

@@ -126,7 +126,7 @@ type Generic interface {
// provided by the user for parsing by the flag
// Ignores parsing errors
func (f GenericFlag) Apply(set *flag.FlagSet) {
f.ApplyWithError(set)
_ = f.ApplyWithError(set)
}
// ApplyWithError takes the flagset and calls Set on the generic flag with the value
@@ -173,7 +173,7 @@ func (f *StringSlice) Get() interface{} {
// Apply populates the flag given the flag set and environment
// Ignores errors
func (f StringSliceFlag) Apply(set *flag.FlagSet) {
f.ApplyWithError(set)
_ = f.ApplyWithError(set)
}
// ApplyWithError populates the flag given the flag set and environment
@@ -234,7 +234,7 @@ func (f *IntSlice) Get() interface{} {
// Apply populates the flag given the flag set and environment
// Ignores errors
func (f IntSliceFlag) Apply(set *flag.FlagSet) {
f.ApplyWithError(set)
_ = f.ApplyWithError(set)
}
// ApplyWithError populates the flag given the flag set and environment
@@ -295,7 +295,7 @@ func (f *Int64Slice) Get() interface{} {
// Apply populates the flag given the flag set and environment
// Ignores errors
func (f Int64SliceFlag) Apply(set *flag.FlagSet) {
f.ApplyWithError(set)
_ = f.ApplyWithError(set)
}
// ApplyWithError populates the flag given the flag set and environment
@@ -327,7 +327,7 @@ func (f Int64SliceFlag) ApplyWithError(set *flag.FlagSet) error {
// Apply populates the flag given the flag set and environment
// Ignores errors
func (f BoolFlag) Apply(set *flag.FlagSet) {
f.ApplyWithError(set)
_ = f.ApplyWithError(set)
}
// ApplyWithError populates the flag given the flag set and environment
@@ -359,7 +359,7 @@ func (f BoolFlag) ApplyWithError(set *flag.FlagSet) error {
// Apply populates the flag given the flag set and environment
// Ignores errors
func (f BoolTFlag) Apply(set *flag.FlagSet) {
f.ApplyWithError(set)
_ = f.ApplyWithError(set)
}
// ApplyWithError populates the flag given the flag set and environment
@@ -392,7 +392,7 @@ func (f BoolTFlag) ApplyWithError(set *flag.FlagSet) error {
// Apply populates the flag given the flag set and environment
// Ignores errors
func (f StringFlag) Apply(set *flag.FlagSet) {
f.ApplyWithError(set)
_ = f.ApplyWithError(set)
}
// ApplyWithError populates the flag given the flag set and environment
@@ -415,7 +415,7 @@ func (f StringFlag) ApplyWithError(set *flag.FlagSet) error {
// Apply populates the flag given the flag set and environment
// Ignores errors
func (f IntFlag) Apply(set *flag.FlagSet) {
f.ApplyWithError(set)
_ = f.ApplyWithError(set)
}
// ApplyWithError populates the flag given the flag set and environment
@@ -442,7 +442,7 @@ func (f IntFlag) ApplyWithError(set *flag.FlagSet) error {
// Apply populates the flag given the flag set and environment
// Ignores errors
func (f Int64Flag) Apply(set *flag.FlagSet) {
f.ApplyWithError(set)
_ = f.ApplyWithError(set)
}
// ApplyWithError populates the flag given the flag set and environment
@@ -470,7 +470,7 @@ func (f Int64Flag) ApplyWithError(set *flag.FlagSet) error {
// Apply populates the flag given the flag set and environment
// Ignores errors
func (f UintFlag) Apply(set *flag.FlagSet) {
f.ApplyWithError(set)
_ = f.ApplyWithError(set)
}
// ApplyWithError populates the flag given the flag set and environment
@@ -498,7 +498,7 @@ func (f UintFlag) ApplyWithError(set *flag.FlagSet) error {
// Apply populates the flag given the flag set and environment
// Ignores errors
func (f Uint64Flag) Apply(set *flag.FlagSet) {
f.ApplyWithError(set)
_ = f.ApplyWithError(set)
}
// ApplyWithError populates the flag given the flag set and environment
@@ -509,7 +509,7 @@ func (f Uint64Flag) ApplyWithError(set *flag.FlagSet) error {
return fmt.Errorf("could not parse %s as uint64 value for flag %s: %s", envVal, f.Name, err)
}
f.Value = uint64(envValInt)
f.Value = envValInt
}
eachName(f.Name, func(name string) {
@@ -526,7 +526,7 @@ func (f Uint64Flag) ApplyWithError(set *flag.FlagSet) error {
// Apply populates the flag given the flag set and environment
// Ignores errors
func (f DurationFlag) Apply(set *flag.FlagSet) {
f.ApplyWithError(set)
_ = f.ApplyWithError(set)
}
// ApplyWithError populates the flag given the flag set and environment
@@ -554,7 +554,7 @@ func (f DurationFlag) ApplyWithError(set *flag.FlagSet) error {
// Apply populates the flag given the flag set and environment
// Ignores errors
func (f Float64Flag) Apply(set *flag.FlagSet) {
f.ApplyWithError(set)
_ = f.ApplyWithError(set)
}
// ApplyWithError populates the flag given the flag set and environment
@@ -565,7 +565,7 @@ func (f Float64Flag) ApplyWithError(set *flag.FlagSet) error {
return fmt.Errorf("could not parse %s as float64 value for flag %s: %s", envVal, f.Name, err)
}
f.Value = float64(envValFloat)
f.Value = envValFloat
}
eachName(f.Name, func(name string) {
@@ -580,11 +580,11 @@ func (f Float64Flag) ApplyWithError(set *flag.FlagSet) error {
}
func visibleFlags(fl []Flag) []Flag {
visible := []Flag{}
for _, flag := range fl {
field := flagValue(flag).FieldByName("Hidden")
var visible []Flag
for _, f := range fl {
field := flagValue(f).FieldByName("Hidden")
if !field.IsValid() || !field.Bool() {
visible = append(visible, flag)
visible = append(visible, f)
}
}
return visible
@@ -729,7 +729,7 @@ func stringifyFlag(f Flag) string {
}
func stringifyIntSliceFlag(f IntSliceFlag) string {
defaultVals := []string{}
var defaultVals []string
if f.Value != nil && len(f.Value.Value()) > 0 {
for _, i := range f.Value.Value() {
defaultVals = append(defaultVals, strconv.Itoa(i))
@@ -740,7 +740,7 @@ func stringifyIntSliceFlag(f IntSliceFlag) string {
}
func stringifyInt64SliceFlag(f Int64SliceFlag) string {
defaultVals := []string{}
var defaultVals []string
if f.Value != nil && len(f.Value.Value()) > 0 {
for _, i := range f.Value.Value() {
defaultVals = append(defaultVals, strconv.FormatInt(i, 10))
@@ -751,7 +751,7 @@ func stringifyInt64SliceFlag(f Int64SliceFlag) string {
}
func stringifyStringSliceFlag(f StringSliceFlag) string {
defaultVals := []string{}
var defaultVals []string
if f.Value != nil && len(f.Value.Value()) > 0 {
for _, s := range f.Value.Value() {
if len(s) > 0 {