Skip to content

Commit

Permalink
refactor: replace literal slice declaration with make function
Browse files Browse the repository at this point in the history
  • Loading branch information
nikoksr committed Feb 23, 2020
1 parent fb1c14a commit 53df2c0
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 24 deletions.
8 changes: 4 additions & 4 deletions cmd/proji/cmd/classImport.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,16 @@ var classImportCmd = &cobra.Command{
func init() {
classCmd.AddCommand(classImportCmd)

classImportCmd.Flags().StringSliceVar(&remoteRepos, "remote-repo", []string{}, "create an importable config based on a remote repository")
classImportCmd.Flags().StringSliceVar(&remoteRepos, "remote-repo", make([]string, 0), "create an importable config based on a remote repository")
_ = classImportCmd.MarkFlagDirname("remote-repo")

classImportCmd.Flags().StringSliceVar(&directories, "directory", []string{}, "create an importable config based on a local directory")
classImportCmd.Flags().StringSliceVar(&directories, "directory", make([]string, 0), "create an importable config based on a local directory")
_ = classImportCmd.MarkFlagDirname("directory")

classImportCmd.Flags().StringSliceVar(&configs, "config", []string{}, "import a class from a config file")
classImportCmd.Flags().StringSliceVar(&configs, "config", make([]string, 0), "import a class from a config file")
_ = classImportCmd.MarkFlagFilename("config")

classImportCmd.Flags().StringSliceVar(&excludes, "exclude", []string{}, "folder to exclude from local directory import")
classImportCmd.Flags().StringSliceVar(&excludes, "exclude", make([]string, 0), "folder to exclude from local directory import")
_ = classImportCmd.MarkFlagFilename("exclude")
}

Expand Down
38 changes: 19 additions & 19 deletions pkg/proji/storage/item/class_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ func TestNewClass(t *testing.T) {
Name: "test",
Label: "tst",
IsDefault: false,
Folders: []*Folder{},
Files: []*File{},
Scripts: []*Script{},
Folders: make([]*Folder, 0),
Files: make([]*File, 0),
Scripts: make([]*Script, 0),
}

classAct := NewClass("test", "tst", false)
Expand Down Expand Up @@ -48,14 +48,14 @@ func TestClassImportFromConfig(t *testing.T) {
Type: "post",
ExecNumber: 1,
RunAsSudo: false,
Args: []string{},
Args: make([]string, 0),
},
{
Name: "init_git.sh",
Type: "post",
ExecNumber: 2,
RunAsSudo: false,
Args: []string{},
Args: make([]string, 0),
},
},
},
Expand All @@ -67,9 +67,9 @@ func TestClassImportFromConfig(t *testing.T) {
Name: "",
Label: "",
IsDefault: false,
Folders: []*Folder{},
Files: []*File{},
Scripts: []*Script{},
Folders: make([]*Folder, 0),
Files: make([]*File, 0),
Scripts: make([]*Script, 0),
},
err: errors.New(""),
},
Expand Down Expand Up @@ -122,7 +122,7 @@ func TestClassImportFromDirectory(t *testing.T) {
{Destination: "test/main_test.go", Template: ""},
{Destination: "test.txt", Template: ""},
},
Scripts: []*Script{},
Scripts: make([]*Script, 0),
},
err: nil,
},
Expand All @@ -138,7 +138,7 @@ func TestClassImportFromDirectory(t *testing.T) {
}

c := NewClass("", "", false)
assert.NoError(t, c.ImportFromDirectory(test.baseName, []string{}))
assert.NoError(t, c.ImportFromDirectory(test.baseName, make([]string, 0)))
conf, err := c.Export(".")
assert.NoError(t, err)
assert.NoError(t, c.ImportFromConfig(conf))
Expand Down Expand Up @@ -179,7 +179,7 @@ func TestClassImportFromURL(t *testing.T) {
{Destination: "src/main.cpp", Template: ""},
{Destination: "test/testHelper.cpp", Template: ""},
},
Scripts: []*Script{},
Scripts: make([]*Script, 0),
},
err: nil,
},
Expand Down Expand Up @@ -207,7 +207,7 @@ func TestClassImportFromURL(t *testing.T) {
{Destination: "src/main.cpp", Template: ""},
{Destination: "test/testHelper.cpp", Template: ""},
},
Scripts: []*Script{},
Scripts: make([]*Script, 0),
},
err: nil,
},
Expand All @@ -234,7 +234,7 @@ func TestClassImportFromURL(t *testing.T) {
{Destination: "src/main.cpp", Template: ""},
{Destination: "test/TestHelper.cpp", Template: ""},
},
Scripts: []*Script{},
Scripts: make([]*Script, 0),
},
err: nil,
},
Expand Down Expand Up @@ -266,7 +266,7 @@ func TestClassExport(t *testing.T) {
{Destination: "README.md", Template: "README.md"},
{Destination: "exampleFolder/test.txt", Template: ""},
},
Scripts: []*Script{},
Scripts: make([]*Script, 0),
},
configName: "./proji-example.toml",
err: nil,
Expand Down Expand Up @@ -307,14 +307,14 @@ func TestClassIsEmpty(t *testing.T) {
Type: "post",
ExecNumber: 1,
RunAsSudo: false,
Args: []string{},
Args: make([]string, 0),
},
{
Name: "init_git.sh",
Type: "post",
ExecNumber: 2,
RunAsSudo: false,
Args: []string{},
Args: make([]string, 0),
},
},
},
Expand All @@ -325,9 +325,9 @@ func TestClassIsEmpty(t *testing.T) {
Name: "blabla",
Label: "bl",
IsDefault: false,
Folders: []*Folder{},
Files: []*File{},
Scripts: []*Script{},
Folders: make([]*Folder, 0),
Files: make([]*File, 0),
Scripts: make([]*Script, 0),
},
isEmpty: true,
},
Expand Down
2 changes: 1 addition & 1 deletion pkg/proji/storage/item/project_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func TestProjectCreate(t *testing.T) {
{Destination: "README.md", Template: "README.md"},
{Destination: "exampleFolder/test.txt", Template: ""},
},
Scripts: []*Script{},
Scripts: make([]*Script, 0),
},
Status: &Status{
ID: 1,
Expand Down

0 comments on commit 53df2c0

Please sign in to comment.