S017

SchemasStandard

check for Schema that MaxItems and MinItems are only configured for TypeList, TypeMap, or TypeSet

The S017 analyzer reports cases of schemas including MaxItems or MinItems without TypeList, TypeMap, or TypeSet, which will fail schema validation.

Examples

&schema.Schema{
    MaxItems: 1,
    Type:     schema.TypeString,
}

&schema.Schema{
    MinItems: 1,
    Type:     schema.TypeString,
}
&schema.Schema{
    Type: schema.TypeString,
}

Ignoring reports

Singular reports can be ignored by adding a //lintignore:S017 Go code comment at the end of the offending line or on the line immediately preceding, e.g.

//lintignore:S017
&schema.Schema{
    MaxItems: 1,
    Type:     schema.TypeString,
}

This page is generated from passes/S017/README.md, which lives beside the analyzer.