R003

package
v0.0.0-...-9d70a79 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 20, 2022 License: MPL-2.0 Imports: 4 Imported by: 0

README

R003

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.

Flagged Code

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

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

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

Passing Code

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

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

Ignoring Reports

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

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

Documentation

Overview

Package R003 defines an Analyzer that checks for Resource having Exists functions

Index

Constants

View Source
const Doc = `` /* 211-byte string literal not displayed */

Variables

View Source
var Analyzer = &analysis.Analyzer{
	Name: analyzerName,
	Doc:  Doc,
	Requires: []*analysis.Analyzer{
		resourceinfo.Analyzer,
		commentignore.Analyzer,
	},
	Run: run,
}

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL