R003

ResourcesStandard

check for Resource having Exists functions

The R003 analyzer reports likely extraneous uses of Exists functions for a resource. Exists logic can be handled inside the Read function to prevent logic duplication.

Examples

func resourceExampleThingExists(d *schema.ResourceData, meta interface{}) (bool, error) { /* ... */ }

func resourceExampleThingRead(d *schema.ResourceData, meta interface{}) error { /* ... */ }

&schema.Resource{
    Exists: resourceExampleThingExists,
    Read:   resourceExampleThingRead,
    /* ... */
}
func resourceExampleThingRead(d *schema.ResourceData, meta interface{}) error { /* ... */ }

&schema.Resource{
    Read: resourceExampleThingRead,
    /* ... */
}

Ignoring reports

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

&schema.Resource{
    //lintignore:R003
    Exists: resourceExampleThingExists,
    Read:   resourceExampleThingRead,
    /* ... */
}

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