Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ linters:
checks:
- all
- '-ST1005' # disable rule 'Incorrectly formatted error string'
- '-ST1008' # disable rule 'Function’s error value should be its last return value'
- '-ST1023' # disable rule 'Redundant type in variable declaration'
- '-QF1001' # disable rule 'Apply De Morgan’s law'
- '-QF1012' # disable rule 'Use fmt.Fprintf instead of x.Write(fmt.Sprintf(...))'
Expand Down
2 changes: 1 addition & 1 deletion cmd/auth/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ func printAuthSuccess(cmd *cobra.Command, IO iostreams.IOStreamer, credentialsPa

// printAuthNextSteps suggests possible commands to run after logging in
func printAuthNextSteps(ctx context.Context, clients *shared.ClientFactory) {
_, project := clients.SDKConfig.Exists()
project, _ := clients.SDKConfig.Exists()
if !project {
clients.IO.PrintInfo(ctx, false, style.Sectionf(style.TextSection{
Emoji: "bulb",
Expand Down
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ func ExecuteContext(ctx context.Context, rootCmd *cobra.Command, clients *shared
func cleanup(ctx context.Context, clients *shared.ClientFactory) {
clients.IO.PrintDebug(ctx, "Starting root command cleanup routine")
// clean up any json in project .slack folder if needed
if _, sdkConfigExists := clients.SDKConfig.Exists(); sdkConfigExists {
if sdkConfigExists, _ := clients.SDKConfig.Exists(); sdkConfigExists {
clients.AppClient().CleanUp()
}
}
8 changes: 4 additions & 4 deletions cmd/root_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,15 +236,15 @@ func Test_Aliases(t *testing.T) {
}
for name, tt := range tests {
t.Run(name, func(t *testing.T) {
err, output := testExecCmd(ctx, strings.Fields(tt.args))
output, err := testExecCmd(ctx, strings.Fields(tt.args))
require.NoError(t, err)
require.Contains(t, output, tt.expected)
})
}
}

// testExecCmd will execute the root cobra command with args and return the output
func testExecCmd(ctx context.Context, args []string) (error, string) {
func testExecCmd(ctx context.Context, args []string) (string, error) {
// Get command
cmd, clients := Init(ctx)

Expand All @@ -257,7 +257,7 @@ func testExecCmd(ctx context.Context, args []string) (error, string) {
cmd.SetArgs(args)
err := cmd.ExecuteContext(ctx)
if err != nil {
return err, ""
return "", err
}
return nil, clientsMock.GetCombinedOutput()
return clientsMock.GetCombinedOutput(), nil
}
2 changes: 1 addition & 1 deletion internal/cmdutil/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func IsSlackHostedProject(ctx context.Context, clients *shared.ClientFactory) er

// IsValidProjectDirectory verifies that a command is run in a valid project directory and returns nil, otherwise returns an error
func IsValidProjectDirectory(clients *shared.ClientFactory) error {
if err, _ := clients.SDKConfig.Exists(); err != nil {
if _, err := clients.SDKConfig.Exists(); err != nil {
return slackerror.New(slackerror.ErrInvalidAppDirectory)
}
return nil
Expand Down
6 changes: 3 additions & 3 deletions internal/hooks/sdk_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ type SDKCLIConfig struct {
}

// Exists returns true when the SDKCLIConfig was successfully loaded, otherwise false with an error
func (s *SDKCLIConfig) Exists() (error, bool) {
func (s *SDKCLIConfig) Exists() (bool, error) {
if strings.TrimSpace(s.WorkingDirectory) == "" {
return slackerror.New(slackerror.ErrInvalidSlackProjectDirectory), false
return false, slackerror.New(slackerror.ErrInvalidSlackProjectDirectory)
}
return nil, true
return true, nil
}

type ProtocolVersions []Protocol
Expand Down
2 changes: 1 addition & 1 deletion internal/hooks/sdk_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func Test_SDKCLIConfig_Exists(t *testing.T) {
}
for name, tt := range tests {
t.Run(name, func(t *testing.T) {
err, exists := tt.sdkCLIConfig.Exists()
exists, err := tt.sdkCLIConfig.Exists()
require.Equal(t, tt.expectedError, err)
require.Equal(t, tt.exists, exists)
})
Expand Down
Loading