-
Notifications
You must be signed in to change notification settings - Fork 242
Enable gosimple linter and fix issues #880
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -93,13 +93,13 @@ func AttributePathToPath(ap *tftypes.AttributePath) cty.Path { | |
| return p | ||
| } | ||
| for _, step := range ap.Steps() { | ||
| switch step.(type) { | ||
| switch step := step.(type) { | ||
| case tftypes.AttributeName: | ||
| p = p.GetAttr(string(step.(tftypes.AttributeName))) | ||
| p = p.GetAttr(string(step)) | ||
| case tftypes.ElementKeyString: | ||
| p = p.Index(cty.StringVal(string(step.(tftypes.ElementKeyString)))) | ||
| p = p.Index(cty.StringVal(string(step))) | ||
| case tftypes.ElementKeyInt: | ||
| p = p.Index(cty.NumberIntVal(int64(step.(tftypes.ElementKeyInt)))) | ||
|
Comment on lines
-96
to
-102
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So, to understand: here we are getting rid of a "double casting". Before it was going (for example) from
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correction: it's not
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here's the original issue reported in the linter: There is a fun feature in the Go specification that allows
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yep yep: essentially, by the time we are in any of the specific cases of the switch, the assertion has already happened and we can avoid doing it again. Makes sense. |
||
| p = p.Index(cty.NumberIntVal(int64(step))) | ||
| } | ||
| } | ||
| return p | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1023,7 +1023,7 @@ func (m *ModuleState) String() string { | |
| } | ||
|
|
||
| if len(rs.Dependencies) > 0 { | ||
| buf.WriteString(fmt.Sprintf("\n Dependencies:\n")) | ||
| buf.WriteString("\n Dependencies:\n") | ||
| for _, dep := range rs.Dependencies { | ||
| buf.WriteString(fmt.Sprintf(" %s\n", dep)) | ||
| } | ||
|
|
@@ -1237,11 +1237,7 @@ func (s *ResourceState) Equal(other *ResourceState) bool { | |
| } | ||
|
|
||
| // States must be equal | ||
| if !s.Primary.Equal(other.Primary) { | ||
| return false | ||
| } | ||
|
|
||
| return true | ||
|
Comment on lines
-1240
to
-1244
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another one. |
||
| return s.Primary.Equal(other.Primary) | ||
| } | ||
|
|
||
| // Taint marks a resource as tainted. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I this is funny :)