Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update XS001 and XR005 to allow more ways of setting Description #242

Merged
merged 1 commit into from
Jul 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion xpasses/XR005/XR005.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func run(pass *analysis.Pass) (interface{}, error) {
continue
}

if resourceInfo.Resource.Description != "" {
if resourceInfo.Fields["Description"] != nil {
continue
}

Expand Down
16 changes: 16 additions & 0 deletions xpasses/XR005/testdata/src/a/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{},
Expand Down
16 changes: 16 additions & 0 deletions xpasses/XR005/testdata/src/a/main_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{},
Expand Down
2 changes: 1 addition & 1 deletion xpasses/XS001/XS001.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func run(pass *analysis.Pass) (interface{}, error) {
continue
}

if schemaInfo.Schema.Description != "" {
if schemaInfo.Fields["Description"] != nil {
continue
}

Expand Down
18 changes: 18 additions & 0 deletions xpasses/XS001/testdata/src/a/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
}
}
18 changes: 18 additions & 0 deletions xpasses/XS001/testdata/src/a/main_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
}
}