Skip to content

Commit 8ae4fef

Browse files
authored
Merge branch 'master' into v1.7326.0
2 parents 98f843a + a42f9f4 commit 8ae4fef

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

internal/qa/qa.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff 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

internal/qa/seealso.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff 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+
}

0 commit comments

Comments
 (0)