From b659d62ef712a401091fa7320d9fd6ed56f48c2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20L=C3=A9one?= Date: Mon, 17 Nov 2025 15:56:46 +0100 Subject: [PATCH] qa: add support for missing see also error --- internal/qa/qa.go | 1 + internal/qa/seealso.go | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/internal/qa/qa.go b/internal/qa/qa.go index 78cd6eeab5..fa673b8d4c 100644 --- a/internal/qa/qa.go +++ b/internal/qa/qa.go @@ -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) diff --git a/internal/qa/seealso.go b/internal/qa/seealso.go index 40ff4a467b..3259584a3b 100644 --- a/internal/qa/seealso.go +++ b/internal/qa/seealso.go @@ -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 +}