Skip to content

Commit

Permalink
Update XS001 and XR005 to allow more ways of setting the Description …
Browse files Browse the repository at this point in the history
…field (#242)
  • Loading branch information
armsnyder authored Jul 20, 2021
1 parent 292d5e6 commit c322e1e
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 2 deletions.
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,
},
}
}

0 comments on commit c322e1e

Please sign in to comment.