Skip to content

Commit 395b62c

Browse files
committed
use noArgs instead of manual checks
Signed-off-by: Arsh Sharma <[email protected]>
1 parent 34e8a61 commit 395b62c

File tree

3 files changed

+3
-14
lines changed

3 files changed

+3
-14
lines changed

cmd/cycles.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,8 @@ var cyclesCmd = &cobra.Command{
3030
Use: "cycles",
3131
Short: "Prints cycles in dependency chains.",
3232
Long: `Will show all the cycles in the dependencies of the project.`,
33+
Args: cobra.NoArgs,
3334
RunE: func(cmd *cobra.Command, args []string) error {
34-
35-
if len(args) != 0 {
36-
return fmt.Errorf("cycles does not take any arguments")
37-
}
38-
3935
overview := getDepInfo(nil)
4036
var cycleChains []Chain
4137
var temp Chain

cmd/list.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,8 @@ var listCmd = &cobra.Command{
2828
Short: "Lists all project dependencies",
2929
Long: `Gives a list of all the dependencies of the project.
3030
These include both direct as well as transitive dependencies.`,
31+
Args: cobra.NoArgs,
3132
RunE: func(cmd *cobra.Command, args []string) error {
32-
33-
if len(args) != 0 {
34-
return fmt.Errorf("list does not take any arguments")
35-
}
36-
3733
depGraph := getDepInfo(nil)
3834
fmt.Println("List of all dependencies:")
3935
allDeps := getAllDeps(depGraph.DirectDepList, depGraph.TransDepList)

cmd/stats.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,10 @@ var statsCmd = &cobra.Command{
4040
2. Transitive Dependencies: Total number of transitive dependencies (dependencies which are further needed by direct dependencies of the project)
4141
3. Total Dependencies: Total number of dependencies of the mainModule(s)
4242
4. Max Depth of Dependencies: Length of the longest chain starting from the first mainModule; defaults to length from the first module encountered in "go mod graph" output`,
43+
Args: cobra.NoArgs,
4344
RunE: func(cmd *cobra.Command, args []string) error {
4445
depGraph := getDepInfo(mainModules)
4546

46-
if len(args) != 0 {
47-
return fmt.Errorf("stats does not take any arguments")
48-
}
49-
5047
// get the longest chain
5148
var temp Chain
5249
longestChain := getLongestChain(depGraph.MainModules[0], depGraph.Graph, temp, map[string]Chain{})

0 commit comments

Comments
 (0)