Skip to content

missing-doc-comment

Reports a type, member, field or enum item that needs documentation and has no /// comment before it: public, protected or internal ones, in types that are too. Members of an interface, explicit interface implementations and enum items count as public. Partial declarations are not reported, and private members are not either. No fix.

Documentation of the public interface is what the users of a library read, in the IDE and in the generated reference. An element without a comment shows only its name and signature, and the caller has to read the code to learn what it does and what it expects.

To fix, add a comment that says what the element is for.

Reported
...
func Run() {}
...
func Detached() {}
...
func Pragma() {}
...
func Old() {}
...
type T struct{}
...
func (T) Method() {}
...
const A, b = 1, 2
...
C = 1
...
X = 1
...
type S []int
...
csharp:
lint:
rules:
missing-doc-comment: warn # off (default), warn, error
go:
lint:
rules:
missing-doc-comment: warn # off (default), warn, error
java:
lint:
rules:
missing-doc-comment: warn # off (default), warn, error

Enabled by the presets: go/revive, java/google, csharp/stylecop.

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

The same check in other tools. full: Sudsy reports what the upstream rule reports; partial: only part of it, as the last column says.

Tool Rule Match What differs
checkstyle MissingJavadocMethod partial Only methods and constructors, no minimum line count.
checkstyle MissingJavadocType partial Only types, no scope option.
revive exported partial No stuttering check (a name that starts with the package name), no own-declaration check for var a, B; a method that is sortable through methods in another file of the package is reported
StyleCop SA1600 full
StyleCop SA1602 full