Skip to content

Commit

Permalink
refactor: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
maxwelbm committed Oct 21, 2024
1 parent 679e2f7 commit 06e9aff
Show file tree
Hide file tree
Showing 11 changed files with 29 additions and 21 deletions.
10 changes: 7 additions & 3 deletions pkg/cmd/create/personal_token/expiration_date.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,16 @@ func ParseExpirationDate(currentDate time.Time, expirationString string) (time.T
}

// If the string contains a suffix, it is a range format
lastChar := expirationString[len(expirationString) - 1]
lastChar := expirationString[len(expirationString)-1]
if interval, ok := suffixMapping[lastChar]; ok {
intervalValue := 0
fmt.Sscanf(string(expirationString[0]), "%d", &intervalValue)
_, err := fmt.Sscanf(string(expirationString[0]), "%d", &intervalValue)
if err != nil {
return time.Now(), err
}

expirationDate := currentDate.Add(time.Duration(intervalValue) * interval)
return time.Parse(constants.FORMAT_DATE, expirationDate.Format(constants.FORMAT_DATE))
return time.Parse(constants.FORMAT_DATE, expirationDate.Format(constants.FORMAT_DATE))
}

// Try to analyze as full date (yyyy-mm-dd) or (dd/mm/yyyy)
Expand Down
4 changes: 2 additions & 2 deletions pkg/cmd/delete/domain/domain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func TestDeleteWithAskInput(t *testing.T) {
expectedOutput: "",
expectError: true,
mockInputs: mockInvalid,
mockError: fmt.Errorf(msg.ErrorConvertId.Error()),
mockError: msg.ErrorConvertId,
},
{
name: "error - parse answer",
Expand All @@ -112,7 +112,7 @@ func TestDeleteWithAskInput(t *testing.T) {
expectedOutput: "",
expectError: true,
mockInputs: mockParseError,
mockError: fmt.Errorf(utils.ErrorParseResponse.Error()),
mockError: utils.ErrorParseResponse,
},
}

Expand Down
5 changes: 4 additions & 1 deletion pkg/cmd/delete/edge_application/cascade.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ func CascadeDelete(ctx context.Context, del *DeleteCmd) error {
}

if azionJson.Function.ID == 0 {
fmt.Fprintf(del.f.IOStreams.Out, msg.MissingFunction)
_, err := fmt.Fprintf(del.f.IOStreams.Out, "%s", msg.MissingFunction)
if err != nil {
return err
}
} else {
err = clientfunc.Delete(ctx, azionJson.Function.ID)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/delete/edge_application/edge_application_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func TestDeleteWithAskInput(t *testing.T) {
expectedOutput: "",
expectError: true,
mockInputs: mockInvalid,
mockError: fmt.Errorf(msg.ErrorConvertId.Error()),
mockError: msg.ErrorConvertId,
},
{
name: "error - parse answer",
Expand Down
4 changes: 2 additions & 2 deletions pkg/cmd/delete/edge_function/edge_function_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func TestDeleteWithAskInput(t *testing.T) {
expectedOutput: "",
expectError: true,
mockInputs: mockInvalidFunctionID,
mockError: fmt.Errorf(msg.ErrorConvertIdFunction.Error()),
mockError: msg.ErrorConvertIdFunction,
},
{
name: "error - parse answer",
Expand All @@ -112,7 +112,7 @@ func TestDeleteWithAskInput(t *testing.T) {
expectedOutput: "",
expectError: true,
mockInputs: mockParseErrorFunctionID,
mockError: fmt.Errorf(utils.ErrorParseResponse.Error()),
mockError: utils.ErrorParseResponse,
},
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/delete/personal_token/personal_token_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func TestDeleteCmd(t *testing.T) {
expectedOutput: "",
expectError: true,
mockInputs: mockInvalid,
mockError: fmt.Errorf(utils.ErrorParseResponse.Error()),
mockError: utils.ErrorParseResponse,
},
}

Expand Down
6 changes: 3 additions & 3 deletions pkg/cmd/deploy/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ type CustomEndpointResolver struct {
}

// ResolveEndpoint is the method that defines the custom endpoint
func (e *CustomEndpointResolver) ResolveEndpoint(service, region string) (aws.Endpoint, error) {
return aws.Endpoint{
func (e *CustomEndpointResolver) ResolveEndpoint(service, region string) (aws.Endpoint, error) { // nolint
return aws.Endpoint{ //nolint
URL: e.URL,
SigningRegion: e.SigningRegion,
}, nil
Expand Down Expand Up @@ -234,7 +234,7 @@ func uploadFiles(f *cmdutil.Factory, msgs *[]string, pathStatic string, settings
cfg, err := config.LoadDefaultConfig(context.TODO(),
config.WithRegion(region),
config.WithCredentialsProvider(credentials.NewStaticCredentialsProvider(settings.S3AccessKey, settings.S3SecreKey, "")),
config.WithEndpointResolver(endpointResolver),
config.WithEndpointResolver(endpointResolver), // nolint
)
if err != nil {
return errors.New("unable to load SDK config, " + err.Error())
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/unlink/unlink.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func (cmd *UnlinkCmd) run() error {
if err != nil {
return err
}
fmt.Fprintf(cmd.F.IOStreams.Out, msg.UnlinkSuccess)
fmt.Fprintf(cmd.F.IOStreams.Out, "%s", msg.UnlinkSuccess)
}
return nil
}
4 changes: 1 addition & 3 deletions pkg/cmd/whoami/whoami.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package whoami

import (
"fmt"

"github.com/MakeNowJust/heredoc"
msg "github.com/aziontech/azion-cli/messages/whoami"
"github.com/aziontech/azion-cli/pkg/cmdutil"
Expand Down Expand Up @@ -60,7 +58,7 @@ func (cmd *WhoamiCmd) run() error {
}

whoamiOut := output.GeneralOutput{
Msg: fmt.Sprintf(settings.Email + "\n"),
Msg: settings.Email + "\n",
Out: cmd.Io.Out,
Flags: cmd.F.Flags,
}
Expand Down
5 changes: 4 additions & 1 deletion pkg/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ func checkNode(str string) error {
majorVersion := versionParts[0]

var major int
fmt.Sscanf(majorVersion, "%d", &major)
_, err := fmt.Sscanf(majorVersion, "%d", &major)
if err != nil {
return err
}

if major < 18 {
return errors.New(NODE_OLDER_VERSION)
Expand Down
6 changes: 3 additions & 3 deletions pkg/node/node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ func Test_checkNode(t *testing.T) {
name: "case 03",
args: "v",
wantErr: true,
err: NODE_OLDER_VERSION,
err: "EOF",
},
{
name: "case 04",
args: "",
wantErr: true,
err: NODE_OLDER_VERSION,
err: "EOF",
},
{
name: "case 05",
Expand All @@ -55,7 +55,7 @@ func Test_checkNode(t *testing.T) {
name: "case 08",
args: "vX.Y.Z",
wantErr: true,
err: NODE_OLDER_VERSION,
err: "expected integer",
},
{
name: "case 09",
Expand Down

0 comments on commit 06e9aff

Please sign in to comment.