R001

ResourcesStandard

check for ResourceData.Set() calls using complex key argument

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.

Examples

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

for idx, key := range keys {
    d.Set(key, values[idx])
}
d.Set("example1", "value1")
d.Set("example2", "value2")

Ignoring reports

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

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

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

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