Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions internal/qa/qa.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ func LintCommands(commands *core.Commands) []error {
errors = append(errors, testArgSpecMissingError(commands)...)
errors = append(errors, testCommandInvalidJSONExampleError(commands)...)
errors = append(errors, testCommandInvalidSeeAlsoError(commands)...)
errors = append(errors, testAtLeastOneSeeAlsoIsPresentError(commands)...)

errors = filterIgnore(errors)

Expand Down
25 changes: 25 additions & 0 deletions internal/qa/seealso.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,28 @@ func testCommandInvalidSeeAlsoError(commands *core.Commands) []error {

return errors
}

type MissingSeeAlsoError struct {
Command *core.Command
}

func (err MissingSeeAlsoError) Error() string {
return fmt.Sprintf("command has no see_also commands '%s'",
err.Command.GetCommandLine("scw"),
)
}

// testAtLeastOneSeeAlsoIsPresentError testes that there is at least one SeeAlso defined by command
func testAtLeastOneSeeAlsoIsPresentError(commands *core.Commands) []error {
errors := []error(nil)

for _, command := range commands.GetAll() {
if len(command.SeeAlsos) == 0 {
errors = append(errors, &MissingSeeAlsoError{Command: command})

continue
}
}

return errors
}
Loading