Skip to content

Latest commit

 

History

History
63 lines (51 loc) · 1.29 KB

README.md

File metadata and controls

63 lines (51 loc) · 1.29 KB

S009

The S009 analyzer reports cases of TypeList or TypeSet schemas configuring ValidateFunc, which will fail schema validation.

Flagged Code

&schema.Schema{
    Type:         schema.TypeList,
    Elem:         &schema.Schema{Type: schema.TypeString},
    ValidateFunc: /* ... */,
}

&schema.Schema{
    Type:         schema.TypeSet,
    Elem:         &schema.Schema{Type: schema.TypeString},
    ValidateFunc: /* ... */,
}

Passing Code

&schema.Schema{
    Type: schema.TypeList,
    Elem: &schema.Schema{Type: schema.TypeString},
}

&schema.Schema{
    Type: schema.TypeSet,
    Elem: &schema.Schema{Type: schema.TypeString},
}

&schema.Schema{
    Type: schema.TypeList,
    Elem: &schema.Schema{
      Type:         schema.TypeString,
      ValidateFunc: /* ... */,
    },
}

&schema.Schema{
    Type: schema.TypeSet,
    Elem: &schema.Schema{
      Type:         schema.TypeString,
      ValidateFunc: /* ... */,
    },
}

Ignoring Reports

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

//lintignore:S009
&schema.Schema{
    Type:         schema.TypeList,
    Elem:         &schema.Schema{Type: schema.TypeString},
    ValidateFunc: /* ... */,
}