Documentation
¶
Index ¶
Constants ¶
const ( ImmutableFieldAssignment = "IMM01" ImmutableFieldCompoundAssign = "IMM02" ImmutableFieldIncDec = "IMM03" ImmutableIndexAssignment = "IMM04" ImmutableCategoryPrefix = "IMM" )
Error code constants for immutable violations
const ( ConstructorCompositeLiteral = "CTOR01" ConstructorNewCall = "CTOR02" ConstructorVarDeclaration = "CTOR03" ConstructorCategoryPrefix = "CTOR" )
Error code constants for constructor violations
const ( TestOnlyTypeUsage = "TONL01" TestOnlyFunctionCall = "TONL02" TestOnlyMethodCall = "TONL03" TestOnlyCategoryPrefix = "TONL" )
Error code constants for testonly violations
const ( ImplementsPackageNotFound = "IMPL01" ImplementsInterfaceNotFound = "IMPL02" ImplementsMissingMethods = "IMPL03" ImplementsCategoryPrefix = "IMPL" )
Error code constants for implements violations
const ( PackageOnlyTypeUsage = "PKGO01" PackageOnlyFunctionCall = "PKGO02" PackageOnlyMethodCall = "PKGO03" PackageOnlyCategoryPrefix = "PKGO" )
Error code constants for package-only violations
Variables ¶
var CodesByCategory = map[string][]Code{ ImmutableCategoryPrefix: { {ImmutableFieldAssignment, "Field of immutable type is being assigned"}, {ImmutableFieldCompoundAssign, "Compound assignment to immutable field (e.g., +=, -=)"}, {ImmutableFieldIncDec, "Increment/decrement of immutable field (e.g., ++, --)"}, {ImmutableIndexAssignment, "Index assignment to immutable collection (slice/map element)"}, }, ConstructorCategoryPrefix: { {ConstructorCompositeLiteral, "Composite literal used outside allowed constructor functions"}, {ConstructorNewCall, "new() call used outside allowed constructor functions"}, {ConstructorVarDeclaration, "Variable declaration creates zero-initialized instance outside allowed constructor functions"}, }, TestOnlyCategoryPrefix: { {TestOnlyTypeUsage, "TestOnly type used outside test context"}, {TestOnlyFunctionCall, "TestOnly function called outside test context"}, {TestOnlyMethodCall, "TestOnly method called outside test context"}, }, PackageOnlyCategoryPrefix: { {PackageOnlyTypeUsage, "PackageOnly type used outside allowed packages"}, {PackageOnlyFunctionCall, "PackageOnly function called outside allowed packages"}, {PackageOnlyMethodCall, "PackageOnly method called outside allowed packages"}, }, ImplementsCategoryPrefix: { {ImplementsPackageNotFound, "Package not found in imports"}, {ImplementsInterfaceNotFound, "Interface not found in package"}, {ImplementsMissingMethods, "Type does not implement all required methods"}, }, }
CodesByCategory contains all error codes grouped by their category prefix. This structure is easy to read, format, and validate in tests. Key: category prefix (e.g., "IMM") Value: slice of codes belonging to that category
Functions ¶
func GetCodesForCheck ¶
GetCodesForCheck returns an iterator of all codes that should be checked for ignore directives for the given error code. The iterator yields codes in order: "ALL", category prefix, specific code.
Example: GetCodesForCheck("IMM01") yields: "ALL", "IMM", "IMM01" Example: GetCodesForCheck("CTOR02") yields: "ALL", "CTOR", "CTOR02"
func GetDocumentationURL ¶
GetDocumentationURL returns the documentation URL for the given error code