XR004

package
v0.30.0 Latest Latest
Warning

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

Go to latest
Published: May 19, 2024 License: MPL-2.0 Imports: 7 Imported by: 2

README

XR004

The XR004 analyzer reports Set() calls that receive a complex value type, but do not perform error checking. This error checking is to prevent issues where the code is not able to properly set the Terraform state for drift detection. Addition details are available in the Extending Terraform documentation.

Flagged Code

d.Set("example", []interface{}{})

d.Set("example", map[string]interface{}{})

d.Set("example", schema.NewSet(/* ... */))

Passing Code

if err := d.Set("example", []interface{}{}); err != nil {
    return fmt.Errorf("error setting example: %s", err)
}

if err := d.Set("example", map[string]interface{}{}); err != nil {
    return fmt.Errorf("error setting example: %s", err)
}

if err := d.Set("example", schema.NewSet(/* ... */)); err != nil {
    return fmt.Errorf("error setting example: %s", err)
}

Ignoring Reports

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

//lintignore:XR004
d.Set("example", []interface{}{})

Documentation

Overview

Package XR004 defines an Analyzer that checks for ResourceData.Set() calls missing error checking with complex types

Index

Constants

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

Variables

View Source
var Analyzer = &analysis.Analyzer{
	Name: analyzerName,
	Doc:  Doc,
	Requires: []*analysis.Analyzer{
		inspect.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