Skip to content

Commit

Permalink
Merge branch 'main' into faddat/copyloopvar2
Browse files Browse the repository at this point in the history
  • Loading branch information
julienrbrt authored Jun 18, 2024
2 parents d40ded9 + 52be059 commit 901f8f0
Show file tree
Hide file tree
Showing 10 changed files with 61 additions and 27 deletions.
6 changes: 1 addition & 5 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ linters:
- depguard
- dogsled
- dupword
# - errcheck
- errcheck
- errchkjson
- errorlint
- exhaustive
Expand All @@ -20,12 +20,10 @@ linters:
- godot
- gofumpt
- revive
# - gosec
- gosimple
- govet
- grouper
- ineffassign
# - interfacer
- misspell
- nakedret
- nolintlint
Expand All @@ -41,8 +39,6 @@ linters:
- unparam
- misspell
- forbidigo
# - wrapcheck
# - wsl

linters-settings:
gci:
Expand Down
5 changes: 3 additions & 2 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@

### Changes

- [#4160](https://github.com/ignite/cli/pull/4160) Enable copyloopvar linter
- [#4159](https://github.com/ignite/cli/pull/4159) Enable gci linter
- [#4157](https://github.com/ignite/cli/pull/4157) Upgrade golang to 1.22
- [#4094](https://github.com/ignite/cli/pull/4094) Scaffolding a multi-index map using `ignite s map foo bar baz --index foobar,foobaz` is no longer supported. Use one index instead of use `collections.IndexedMap`.
- [#4058](https://github.com/ignite/cli/pull/4058) Simplify scaffolded modules by including `ValidateBasic()` logic in message handler.
Expand All @@ -42,6 +40,9 @@
- [#4167](https://github.com/ignite/cli/pull/4167) Scaffold `int64` instead of `int32` when a field type is `int`
- [#4168](https://github.com/ignite/cli/pull/4168) Bump IBC to `v8.3.1`
- [#4178](https://github.com/ignite/cli/pull/4178) Bump cosmos-sdk to `v0.50.7`
- [#4159](https://github.com/ignite/cli/pull/4159) Enable gci linter
- [#4160](https://github.com/ignite/cli/pull/4160) Enable copyloopvar linter
- [#4162](https://github.com/ignite/cli/pull/4162) Enable errcheck linter

### Fixes

Expand Down
21 changes: 15 additions & 6 deletions ignite/cmd/completion.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ignitecmd

import (
"fmt"
"os"

"github.com/spf13/cobra"
Expand All @@ -13,20 +14,28 @@ func NewCompletionCmd() *cobra.Command {
Short: "Generates shell completion script.",
Run: func(cmd *cobra.Command, args []string) {
if len(args) == 0 {
cmd.Help()
if err := cmd.Help(); err != nil {
fmt.Fprintln(os.Stderr, "Error displaying help:", err)
os.Exit(1)
}
os.Exit(0)
}
var err error
switch args[0] {
case "bash":
cmd.Root().GenBashCompletion(os.Stdout)
err = cmd.Root().GenBashCompletion(os.Stdout)
case "zsh":
cmd.Root().GenZshCompletion(os.Stdout)
err = cmd.Root().GenZshCompletion(os.Stdout)
case "fish":
cmd.Root().GenFishCompletion(os.Stdout, true)
err = cmd.Root().GenFishCompletion(os.Stdout, true)
case "powershell":
cmd.Root().GenPowerShellCompletion(os.Stdout)
err = cmd.Root().GenPowerShellCompletion(os.Stdout)
default:
cmd.Help()
err = cmd.Help()
}
if err != nil {
fmt.Fprintln(os.Stderr, "Error generating completion script:", err)
os.Exit(1)
}
},
}
Expand Down
2 changes: 1 addition & 1 deletion ignite/cmd/plugin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func TestLinkPluginCmds(t *testing.T) {
Use: "flaggy",
Flags: []*plugin.Flag{
{Name: "flag1", Type: plugin.FlagTypeString},
{Name: "flag2", Type: plugin.FlagTypeInt, DefaultValue: "0"},
{Name: "flag2", Type: plugin.FlagTypeInt, DefaultValue: "0", Value: "0"},
},
}
)
Expand Down
4 changes: 3 additions & 1 deletion ignite/internal/tools/gen-cli-docs/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ func run() error {
}
defer cleanUp()
cmd.Flags().String(outFlag, ".", ".md file path to place Ignite CLI docs inside")
cmd.Flags().MarkHidden(outFlag)
if err := cmd.Flags().MarkHidden(outFlag); err != nil {
return err
}

// Run ExecuteC so cobra adds the completion command.
cmd, err = cmd.ExecuteC()
Expand Down
3 changes: 1 addition & 2 deletions ignite/pkg/gomodule/gomodule.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,11 +188,10 @@ func FindModule(ctx context.Context, rootDir, path string) (Module, error) {

for dec.More() {
var m Module
if dec.Decode(&m); err != nil {
if err := dec.Decode(&m); err != nil {
if errors.Is(err, io.EOF) {
break
}

return Module{}, err
}

Expand Down
4 changes: 1 addition & 3 deletions ignite/services/chain/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,7 @@ func (c *Chain) IsInitialized() (bool, error) {

if _, err := os.Stat(gentxDir); os.IsNotExist(err) {
return false, nil
}
if err != nil {
// Return error on other error
} else if err != nil {
return false, err
}

Expand Down
28 changes: 21 additions & 7 deletions ignite/services/plugin/grpc/v1/interface_flag.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,46 +42,60 @@ func (f *Flag) exportToFlagSet(fs *pflag.FlagSet) error {
}

fs.BoolP(f.Name, f.Shorthand, v, f.Usage)
fs.Set(f.Name, f.Value)
if err := fs.Set(f.Name, f.Value); err != nil {
return err
}
case Flag_TYPE_FLAG_INT:
v, err := strconv.Atoi(f.DefaultValue)
if err != nil {
return newDefaultFlagValueError(cobraFlagTypeInt, f.DefaultValue)
}

fs.IntP(f.Name, f.Shorthand, v, f.Usage)
fs.Set(f.Name, f.Value)
if err := fs.Set(f.Name, f.Value); err != nil {
return err
}
case Flag_TYPE_FLAG_UINT:
v, err := strconv.ParseUint(f.DefaultValue, 10, 64)
if err != nil {
return newDefaultFlagValueError(cobraFlagTypeUint, f.DefaultValue)
}

fs.UintP(f.Name, f.Shorthand, uint(v), f.Usage)
fs.Set(f.Name, f.Value)
if err := fs.Set(f.Name, f.Value); err != nil {
return err
}
case Flag_TYPE_FLAG_INT64:
v, err := strconv.ParseInt(f.DefaultValue, 10, 64)
if err != nil {
return newDefaultFlagValueError(cobraFlagTypeInt64, f.DefaultValue)
}

fs.Int64P(f.Name, f.Shorthand, v, f.Usage)
fs.Set(f.Name, f.Value)
if err := fs.Set(f.Name, f.Value); err != nil {
return err
}
case Flag_TYPE_FLAG_UINT64:
v, err := strconv.ParseUint(f.DefaultValue, 10, 64)
if err != nil {
return newDefaultFlagValueError(cobraFlagTypeInt64, f.DefaultValue)
}

fs.Uint64P(f.Name, f.Shorthand, v, f.Usage)
fs.Set(f.Name, f.Value)
if err := fs.Set(f.Name, f.Value); err != nil {
return err
}
case Flag_TYPE_FLAG_STRING_SLICE:
s := strings.Trim(f.DefaultValue, "[]")
fs.StringSliceP(f.Name, f.Shorthand, strings.Fields(s), f.Usage)
fs.Set(f.Name, strings.Trim(f.Value, "[]"))
if err := fs.Set(f.Name, strings.Trim(f.Value, "[]")); err != nil {
return err
}
case Flag_TYPE_FLAG_STRING_UNSPECIFIED:
fs.StringP(f.Name, f.Shorthand, f.DefaultValue, f.Usage)
fs.Set(f.Name, f.Value)
if err := fs.Set(f.Name, f.Value); err != nil {
return err
}
}
return nil
}
Expand Down
14 changes: 14 additions & 0 deletions ignite/services/plugin/grpc/v1/types_command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,48 +149,55 @@ func TestExecutedCommandNewFlags(t *testing.T) {
Shorthand: "b",
Usage: "bool usage",
DefaultValue: "false",
Value: "true",
Type: v1.Flag_TYPE_FLAG_BOOL,
},
{
Name: "int",
Shorthand: "i",
Usage: "int usage",
DefaultValue: "0",
Value: "42",
Type: v1.Flag_TYPE_FLAG_INT,
},
{
Name: "uint",
Shorthand: "u",
Usage: "uint usage",
DefaultValue: "0",
Value: "42",
Type: v1.Flag_TYPE_FLAG_UINT,
},
{
Name: "int64",
Shorthand: "j",
Usage: "int64 usage",
DefaultValue: "0",
Value: "42",
Type: v1.Flag_TYPE_FLAG_INT64,
},
{
Name: "uint64",
Shorthand: "k",
Usage: "uint64 usage",
DefaultValue: "0",
Value: "42",
Type: v1.Flag_TYPE_FLAG_UINT64,
},
{
Name: "string",
Shorthand: "s",
Usage: "string usage",
DefaultValue: "",
Value: "hello",
Type: v1.Flag_TYPE_FLAG_STRING_UNSPECIFIED,
},
{
Name: "string-slice",
Shorthand: "l",
Usage: "string slice usage",
DefaultValue: "[]",
Value: "[]",
Type: v1.Flag_TYPE_FLAG_STRING_SLICE,
},
{
Expand Down Expand Up @@ -247,6 +254,7 @@ func TestExecutedCommandNewPersistentFlags(t *testing.T) {
Shorthand: "b",
Usage: "bool usage",
DefaultValue: "false",
Value: "true",
Type: v1.Flag_TYPE_FLAG_BOOL,
Persistent: true,
},
Expand All @@ -255,6 +263,7 @@ func TestExecutedCommandNewPersistentFlags(t *testing.T) {
Shorthand: "i",
Usage: "int usage",
DefaultValue: "0",
Value: "42",
Type: v1.Flag_TYPE_FLAG_INT,
Persistent: true,
},
Expand All @@ -263,6 +272,7 @@ func TestExecutedCommandNewPersistentFlags(t *testing.T) {
Shorthand: "u",
Usage: "uint usage",
DefaultValue: "0",
Value: "42",
Type: v1.Flag_TYPE_FLAG_UINT,
Persistent: true,
},
Expand All @@ -271,6 +281,7 @@ func TestExecutedCommandNewPersistentFlags(t *testing.T) {
Shorthand: "j",
Usage: "int64 usage",
DefaultValue: "0",
Value: "42",
Type: v1.Flag_TYPE_FLAG_INT64,
Persistent: true,
},
Expand All @@ -279,6 +290,7 @@ func TestExecutedCommandNewPersistentFlags(t *testing.T) {
Shorthand: "k",
Usage: "uint64 usage",
DefaultValue: "0",
Value: "42",
Type: v1.Flag_TYPE_FLAG_UINT64,
Persistent: true,
},
Expand All @@ -287,6 +299,7 @@ func TestExecutedCommandNewPersistentFlags(t *testing.T) {
Shorthand: "s",
Usage: "string usage",
DefaultValue: "",
Value: "hello",
Type: v1.Flag_TYPE_FLAG_STRING_UNSPECIFIED,
Persistent: true,
},
Expand All @@ -295,6 +308,7 @@ func TestExecutedCommandNewPersistentFlags(t *testing.T) {
Shorthand: "l",
Usage: "string slice usage",
DefaultValue: "[]",
Value: "[]",
Type: v1.Flag_TYPE_FLAG_STRING_SLICE,
Persistent: true,
},
Expand Down
1 change: 1 addition & 0 deletions integration/cosmosgen/bank_module_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
envtest "github.com/ignite/cli/v29/integration"
)

// TestBankModule tests the bank module by creating accounts, transferring tokens between them, and querying the account balances.
func TestBankModule(t *testing.T) {
t.Skip()

Expand Down

0 comments on commit 901f8f0

Please sign in to comment.