Skip to content

documented-command

all languagesstyleno fixdefault: offcmake/cmake-lint

Reports a command listed in the option commands (for example function and macro in CMake, compared ignoring case) that has no comment on the line right before it, or whose comment has no text (# alone). A comment further up with a blank line between, or code in between, does not count. The option doc_kinds limits which comment kinds document (all by default); a comment of another kind counts as an empty one.

A function or macro is called from other files, so a reader meets the name far from its definition. A comment right above it is the place where tools and readers look for what it takes and does.

To fix, write the comment on the line before the definition.

Reported
...
# Detached.
function(b)
endfunction()
#
macro(c)
endmacro()
set(d 1)
#[[ block ]]
function(e)
endfunction()
# Text.
#
...
lint:
rules:
documented-command:
level: warn # off (default), warn, error
options:
commands: []
doc_kinds: []
Option Type Default Description
commands list [] The commands that need a comment (case ignored).
doc_kinds list [] The kinds of comment token that document (none listed: every comment does); a comment of another kind counts as one with no text.

Enabled by the presets: cmake/cmake-lint.

Suppress one line with sudsy-disable-next-line documented-command in a comment of the file’s language.

The same check in other tools; Sudsy reports what each upstream rule reports.

Tool Rule Match
cmake-lint C0111 full
cmake-lint C0112 full