diff --git a/xpasses/XR005/XR005.go b/xpasses/XR005/XR005.go index 07829bfb..c93f3314 100644 --- a/xpasses/XR005/XR005.go +++ b/xpasses/XR005/XR005.go @@ -40,7 +40,7 @@ func run(pass *analysis.Pass) (interface{}, error) { continue } - if resourceInfo.Resource.Description != "" { + if resourceInfo.Fields["Description"] != nil { continue } diff --git a/xpasses/XR005/testdata/src/a/main.go b/xpasses/XR005/testdata/src/a/main.go index a947280a..0dc9448e 100644 --- a/xpasses/XR005/testdata/src/a/main.go +++ b/xpasses/XR005/testdata/src/a/main.go @@ -25,6 +25,22 @@ func f() { Schema: map[string]*schema.Schema{}, } + _ = schema.Resource{ + Create: createFunc, + Description: "Line one.\n\n" + + "Line two", + Read: readFunc, + Schema: map[string]*schema.Schema{}, + } + + descriptions := map[string]string{"name": "test"} + _ = schema.Resource{ + Create: createFunc, + Description: descriptions["name"], + Read: readFunc, + Schema: map[string]*schema.Schema{}, + } + _ = schema.Resource{ // want "resource should configure Description" Read: readFunc, Schema: map[string]*schema.Schema{}, diff --git a/xpasses/XR005/testdata/src/a/main_v2.go b/xpasses/XR005/testdata/src/a/main_v2.go index 6a87b465..33001630 100644 --- a/xpasses/XR005/testdata/src/a/main_v2.go +++ b/xpasses/XR005/testdata/src/a/main_v2.go @@ -25,6 +25,22 @@ func f_v2() { Schema: map[string]*schema.Schema{}, } + _ = schema.Resource{ + Create: createFunc_v2, + Description: "Line one.\n\n" + + "Line two", + Read: readFunc_v2, + Schema: map[string]*schema.Schema{}, + } + + descriptions := map[string]string{"name": "test"} + _ = schema.Resource{ + Create: createFunc_v2, + Description: descriptions["name"], + Read: readFunc_v2, + Schema: map[string]*schema.Schema{}, + } + _ = schema.Resource{ // want "resource should configure Description" Read: readFunc_v2, Schema: map[string]*schema.Schema{}, diff --git a/xpasses/XS001/XS001.go b/xpasses/XS001/XS001.go index 0ae6a9f8..5262dcb4 100644 --- a/xpasses/XS001/XS001.go +++ b/xpasses/XS001/XS001.go @@ -41,7 +41,7 @@ func run(pass *analysis.Pass) (interface{}, error) { continue } - if schemaInfo.Schema.Description != "" { + if schemaInfo.Fields["Description"] != nil { continue } diff --git a/xpasses/XS001/testdata/src/a/main.go b/xpasses/XS001/testdata/src/a/main.go index 944f811b..744d622e 100644 --- a/xpasses/XS001/testdata/src/a/main.go +++ b/xpasses/XS001/testdata/src/a/main.go @@ -26,4 +26,22 @@ func f() { Type: schema.TypeString, }, } + + _ = map[string]*schema.Schema{ + "name": { + Description: "Line one.\n\n" + + "Line two.", + Optional: true, + Type: schema.TypeString, + }, + } + + descriptions := map[string]string{"name": "test"} + _ = map[string]*schema.Schema{ + "name": { + Description: descriptions["name"], + Optional: true, + Type: schema.TypeString, + }, + } } diff --git a/xpasses/XS001/testdata/src/a/main_v2.go b/xpasses/XS001/testdata/src/a/main_v2.go index 5a744b3a..8b7ac557 100644 --- a/xpasses/XS001/testdata/src/a/main_v2.go +++ b/xpasses/XS001/testdata/src/a/main_v2.go @@ -26,4 +26,22 @@ func f_v2() { Type: schema.TypeString, }, } + + _ = map[string]*schema.Schema{ + "name": { + Description: "Line one.\n\n" + + "Line two.", + Optional: true, + Type: schema.TypeString, + }, + } + + descriptions := map[string]string{"name": "test"} + _ = map[string]*schema.Schema{ + "name": { + Description: descriptions["name"], + Optional: true, + Type: schema.TypeString, + }, + } }