R001

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

R001

The R001 analyzer reports a complex key argument for a Set() call. It is preferred to explicitly use a string literal as the key argument.

Flagged Code

keys := []string{"example1", "example2"}
values := []string{"value1", "value2"}

for idx, key := range keys {
    d.Set(key, values[idx])
}

Passing Code

d.Set("example1", "value1")
d.Set("example2", "value2")

Ignoring Reports

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

keys := []string{"example1", "example2"}
values := []string{"value1", "value2"}

for idx, key := range keys {
    //lintignore:R001
    d.Set(key, values[idx])
}

Documentation

Overview

Package R001 defines an Analyzer that checks for ResourceData.Set() calls using complex key argument

Index

Constants

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

Variables

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