File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ func LintCommands(commands *core.Commands) []error {
2323 errors = append (errors , testArgSpecMissingError (commands )... )
2424 errors = append (errors , testCommandInvalidJSONExampleError (commands )... )
2525 errors = append (errors , testCommandInvalidSeeAlsoError (commands )... )
26+ errors = append (errors , testAtLeastOneSeeAlsoIsPresentError (commands )... )
2627
2728 errors = filterIgnore (errors )
2829
Original file line number Diff line number Diff line change @@ -44,3 +44,28 @@ func testCommandInvalidSeeAlsoError(commands *core.Commands) []error {
4444
4545 return errors
4646}
47+
48+ type MissingSeeAlsoError struct {
49+ Command * core.Command
50+ }
51+
52+ func (err MissingSeeAlsoError ) Error () string {
53+ return fmt .Sprintf ("command has no see_also commands '%s'" ,
54+ err .Command .GetCommandLine ("scw" ),
55+ )
56+ }
57+
58+ // testAtLeastOneSeeAlsoIsPresentError testes that there is at least one SeeAlso defined by command
59+ func testAtLeastOneSeeAlsoIsPresentError (commands * core.Commands ) []error {
60+ errors := []error (nil )
61+
62+ for _ , command := range commands .GetAll () {
63+ if len (command .SeeAlsos ) == 0 {
64+ errors = append (errors , & MissingSeeAlsoError {Command : command })
65+
66+ continue
67+ }
68+ }
69+
70+ return errors
71+ }
You can’t perform that action at this time.
0 commit comments