Skip to content

Commit

Permalink
chore: add new linters (#3631)
Browse files Browse the repository at this point in the history
  • Loading branch information
remyleone authored Feb 1, 2024
1 parent f6a0013 commit e34c5c7
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 10 deletions.
6 changes: 6 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ linters:
# Run golangci-lint linters to see the list of all linters
# Please keep them sorted alphabetically
enable:
- asasalint
- bidichk
- bodyclose
- decorder
- dogsled
- errcheck
- goconst
Expand All @@ -26,10 +29,13 @@ linters:
- misspell
- nakedret
- nolintlint
- prealloc
- predeclared
- revive
- rowserrcheck
- staticcheck
- stylecheck
- tenv
- typecheck
- unconvert
- unparam
Expand Down
2 changes: 1 addition & 1 deletion internal/core/cobra_usage_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func _buildArgShort(as *ArgSpec) string {
// This string will be used by cobra usage template.
func buildExamples(binaryName string, cmd *Command) string {
// Build the examples array.
var examples []string
examples := make([]string, 0, len(cmd.Examples))

for _, cmdExample := range cmd.Examples {
// Build title.
Expand Down
2 changes: 1 addition & 1 deletion internal/core/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ func (c *Command) GetUsage(binaryName string, commands *Commands) string {

// seeAlsosAsStr returns all See Alsos as a single string
func (c *Command) seeAlsosAsStr() string {
var seeAlsos []string
seeAlsos := make([]string, 0, len(c.SeeAlsos))

for _, cmdSeeAlso := range c.SeeAlsos {
short := fmt.Sprintf(" # %s", cmdSeeAlso.Short)
Expand Down
4 changes: 2 additions & 2 deletions internal/interactive/print.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ func RemoveIndent(str string) string {
return strings.Trim(regexp.MustCompile("\n[ \t]*").ReplaceAllString(str, "\n"), "\n")
}

func makeStr(char string, len int) string {
func makeStr(char string, length int) string {
str := ""
for i := 0; i < len; i++ {
for i := 0; i < length; i++ {
str += char
}
return str
Expand Down
3 changes: 2 additions & 1 deletion internal/namespaces/instance/v1/custom_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ func orderVolumes(v map[string]*instance.VolumeServer) []*instance.VolumeServer
indexes = append(indexes, index)
}
sort.Strings(indexes)
var orderedVolumes []*instance.VolumeServer

orderedVolumes := make([]*instance.VolumeServer, 0, len(indexes))
for _, index := range indexes {
orderedVolumes = append(orderedVolumes, v[index])
}
Expand Down
2 changes: 1 addition & 1 deletion internal/namespaces/object/v1/s3configfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func (c s3tool) String() string {
type supportedTool []s3tool

func (s supportedTool) ToStringArray() []string {
var res []string
res := make([]string, 0, len(s))
for _, x := range s {
res = append(res, x.String())
}
Expand Down
2 changes: 1 addition & 1 deletion internal/namespaces/registry/v1/custom_docker_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func registrySetupDockerHelperRun(ctx context.Context, argsI interface{}) (i int
return nil, fmt.Errorf("failed to write helper script: %s", err)
}

var registries []string
registries := make([]string, 0, len(scw.AllRegions))
for _, region := range scw.AllRegions {
registries = append(registries, getRegistryEndpoint(region))
}
Expand Down
2 changes: 1 addition & 1 deletion internal/namespaces/registry/v1/helpers_login_logout.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ var (
)

func (p programs) StringArray() []string {
var res []string
res := make([]string, 0, len(p))
for _, prog := range p {
res = append(res, string(prog))
}
Expand Down
4 changes: 2 additions & 2 deletions internal/passwordgenerator/password_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ func GeneratePassword(length, minNumbers, minLower, minUpper, minSymbol int) (st
return string(inRune), nil
}

func randInt(len int) (int, error) {
i, err := crypto.Int(crypto.Reader, big.NewInt(int64(len)))
func randInt(length int) (int, error) {
i, err := crypto.Int(crypto.Reader, big.NewInt(int64(length)))
if err != nil {
return 0, err
}
Expand Down

0 comments on commit e34c5c7

Please sign in to comment.