-
Notifications
You must be signed in to change notification settings - Fork 345
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
Improve ineffecient module detector method #10
Conversation
package detector | ||
|
||
import ( | ||
"github.com/aws/aws-sdk-go/service/ec2" |
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.
[gometalinter]
- [gotype] could not import github.com/aws/aws-sdk-go/service/ec2 (can't find import: github.com/wata727/tflint/vendor/github.com/aws/aws-sdk-go/service/ec2)
|
||
import ( | ||
"github.com/aws/aws-sdk-go/service/ec2" | ||
"github.com/aws/aws-sdk-go/service/iam" |
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.
[gometalinter]
- [gotype] could not import github.com/aws/aws-sdk-go/service/iam (can't find import: github.com/wata727/tflint/vendor/github.com/aws/aws-sdk-go/service/iam)
import ( | ||
"reflect" | ||
|
||
"github.com/hashicorp/hcl/hcl/ast" |
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.
[gometalinter]
- [gotype] could not import github.com/hashicorp/hcl/hcl/ast (can't find import: github.com/wata727/tflint/vendor/github.com/hashicorp/hcl/hcl/ast)
"reflect" | ||
|
||
"github.com/hashicorp/hcl/hcl/ast" | ||
"github.com/hashicorp/hcl/hcl/parser" |
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.
[gometalinter]
- [gotype] could not import github.com/hashicorp/hcl/hcl/parser (can't find import: github.com/wata727/tflint/vendor/github.com/hashicorp/hcl/hcl/parser)
) | ||
|
||
type ResponseCache struct { | ||
DescribeImagesOutput *ec2.DescribeImagesOutput |
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.
[gometalinter]
- [gotype] undeclared name: ec2
|
||
type ResponseCache struct { | ||
DescribeImagesOutput *ec2.DescribeImagesOutput | ||
ListInstanceProfilesOutput *iam.ListInstanceProfilesOutput |
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.
[gometalinter]
- [gotype] undeclared name: iam
EvalConfig *evaluator.Evaluator | ||
Logger *logger.Logger | ||
Error bool | ||
ListMap map[string]*ast.ObjectList |
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.
[gometalinter]
- [gotype] undeclared name: ast
@@ -14,7 +22,7 @@ func (d *Detector) DetectAwsInstanceDefaultStandardVolume(issues *[]*issue.Issue | |||
} | |||
} | |||
|
|||
func (d *Detector) detectForBlockDevices(issues *[]*issue.Issue, item *ast.ObjectItem, filename string, device string) { | |||
func (d *AwsInstanceDefaultStandardVolumeDetector) detectForBlockDevices(issues *[]*issue.Issue, item *ast.ObjectItem, filename string, device string) { |
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.
[gometalinter]
- [gotype] undeclared name: ast
d.Logger.Error(err) | ||
d.Error = true | ||
if d.ResponseCache.ListInstanceProfilesOutput == nil { | ||
resp, err := d.AwsClient.Iam.ListInstanceProfiles(&iam.ListInstanceProfilesInput{}) |
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.
[gometalinter]
- [gotype] undeclared name: iam
- [gotype] cannot use &(iam.ListInstanceProfilesInput literal) (value of type *invalid type) as *github.com/aws/aws-sdk-go/service/iam.ListInstanceProfilesInput value in argument to d.AwsClient.Iam.ListInstanceProfiles
d.Logger.Error(err) | ||
d.Error = true | ||
} | ||
d.ResponseCache.ListInstanceProfilesOutput = resp |
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.
[gometalinter]
- [gotype] cannot use resp (variable of type *github.com/aws/aws-sdk-go/service/iam.ListInstanceProfilesOutput) as *invalid type value in assignment
} | ||
for _, iamProfile := range resp.InstanceProfiles { | ||
for _, iamProfile := range d.ResponseCache.ListInstanceProfilesOutput.InstanceProfiles { |
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.
[gometalinter]
- [gotype] invalid operation: d.ResponseCache.ListInstanceProfilesOutput (variable of type *invalid type) has no field or method InstanceProfiles
- [gotype] cannot range over d.ResponseCache.ListInstanceProfilesOutput.InstanceProfiles (invalid operand)
d.Logger.Error(err) | ||
d.Error = true | ||
if d.ResponseCache.DescribeImagesOutput == nil { | ||
resp, err := d.AwsClient.Ec2.DescribeImages(&ec2.DescribeImagesInput{}) |
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.
[gometalinter]
- [gotype] undeclared name: ec2
- [gotype] cannot use &(ec2.DescribeImagesInput literal) (value of type *invalid type) as *github.com/aws/aws-sdk-go/service/ec2.DescribeImagesInput value in argument to d.AwsClient.Ec2.DescribeImages
d.Logger.Error(err) | ||
d.Error = true | ||
} | ||
d.ResponseCache.DescribeImagesOutput = resp |
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.
[gometalinter]
- [gotype] cannot use resp (variable of type *github.com/aws/aws-sdk-go/service/ec2.DescribeImagesOutput) as *invalid type value in assignment
} | ||
for _, image := range resp.Images { | ||
for _, image := range d.ResponseCache.DescribeImagesOutput.Images { |
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.
[gometalinter]
- [gotype] invalid operation: d.ResponseCache.DescribeImagesOutput (variable of type *invalid type) has no field or method Images
- [gotype] cannot range over d.ResponseCache.DescribeImagesOutput.Images (invalid operand)
}, | ||
Logger: d.Logger, | ||
Error: false, | ||
moduleDetector, err := NewDetector(m.ListMap, d.Config) |
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.
[gometalinter]
- [gotype] cannot use m.ListMap (variable of type map[string]*github.com/hashicorp/hcl/hcl/ast.ObjectList) as map[string]*invalid type value in argument to NewDetector
} | ||
|
||
func TestDetectByCreatorName(creatorMethod string, src string, c *config.Config, awsClient *config.AwsClient, issues *[]*issue.Issue) { | ||
listMap := make(map[string]*ast.ObjectList) |
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.
[gometalinter]
- [gotype] undeclared name: ast
|
||
func TestDetectByCreatorName(creatorMethod string, src string, c *config.Config, awsClient *config.AwsClient, issues *[]*issue.Issue) { | ||
listMap := make(map[string]*ast.ObjectList) | ||
root, _ := parser.Parse([]byte(src)) |
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.
[gometalinter]
- [gotype] undeclared name: parser
list, _ := root.Node.(*ast.ObjectList) | ||
listMap["test.tf"] = list | ||
|
||
evalConfig, _ := evaluator.NewEvaluator(listMap, c) |
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.
[gometalinter]
- [gotype] cannot use listMap (variable of type map[string]*invalid type) as map[string]*github.com/hashicorp/hcl/hcl/ast.ObjectList value in argument to evaluator.NewEvaluator
@@ -7,7 +7,15 @@ import ( | |||
"github.com/wata727/tflint/issue" | |||
) | |||
|
|||
func (d *Detector) DetectAwsDbInstanceDefaultParameterGroup(issues *[]*issue.Issue) { | |||
type AwsDBInstanceDefaultParameterGroupDetector struct { |
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.
[gometalinter]
- [golint] exported type AwsDBInstanceDefaultParameterGroupDetector should have comment or be unexported
*Detector | ||
} | ||
|
||
func (d *Detector) CreateAwsDBInstanceDefaultParameterGroupDetector() *AwsDBInstanceDefaultParameterGroupDetector { |
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.
[gometalinter]
- [golint] exported method Detector.CreateAwsDBInstanceDefaultParameterGroupDetector should have comment or be unexported
return &AwsDBInstanceDefaultParameterGroupDetector{d} | ||
} | ||
|
||
func (d *AwsDBInstanceDefaultParameterGroupDetector) Detect(issues *[]*issue.Issue) { |
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.
[gometalinter]
- [golint] exported method AwsDBInstanceDefaultParameterGroupDetector.Detect should have comment or be unexported
@@ -7,7 +7,15 @@ import ( | |||
"github.com/wata727/tflint/issue" | |||
) | |||
|
|||
func (d *Detector) DetectAwsElasticacheClusterDefaultParameterGroup(issues *[]*issue.Issue) { | |||
type AwsElastiCacheClusterDefaultParameterGroupDetector struct { |
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.
[gometalinter]
- [golint] exported type AwsElastiCacheClusterDefaultParameterGroupDetector should have comment or be unexported
*Detector | ||
} | ||
|
||
func (d *Detector) CreateAwsElastiCacheClusterDefaultParameterGroupDetector() *AwsElastiCacheClusterDefaultParameterGroupDetector { |
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.
[gometalinter]
- [golint] exported method Detector.CreateAwsElastiCacheClusterDefaultParameterGroupDetector should have comment or be unexported
return &AwsElastiCacheClusterDefaultParameterGroupDetector{d} | ||
} | ||
|
||
func (d *AwsElastiCacheClusterDefaultParameterGroupDetector) Detect(issues *[]*issue.Issue) { |
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.
[gometalinter]
- [golint] exported method AwsElastiCacheClusterDefaultParameterGroupDetector.Detect should have comment or be unexported
@@ -5,7 +5,15 @@ import ( | |||
"github.com/wata727/tflint/issue" | |||
) | |||
|
|||
func (d *Detector) DetectAwsInstanceDefaultStandardVolume(issues *[]*issue.Issue) { | |||
type AwsInstanceDefaultStandardVolumeDetector struct { |
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.
[gometalinter]
- [golint] exported type AwsInstanceDefaultStandardVolumeDetector should have comment or be unexported
*Detector | ||
} | ||
|
||
func (d *Detector) CreateAwsInstanceDefaultStandardVolumeDetector() *AwsInstanceDefaultStandardVolumeDetector { |
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.
[gometalinter]
- [golint] exported method Detector.CreateAwsInstanceDefaultStandardVolumeDetector should have comment or be unexported
return &AwsInstanceDefaultStandardVolumeDetector{d} | ||
} | ||
|
||
func (d *AwsInstanceDefaultStandardVolumeDetector) Detect(issues *[]*issue.Issue) { |
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.
[gometalinter]
- [golint] exported method AwsInstanceDefaultStandardVolumeDetector.Detect should have comment or be unexported
@@ -7,19 +7,30 @@ import ( | |||
"github.com/wata727/tflint/issue" | |||
) | |||
|
|||
func (d *Detector) DetectAwsInstanceInvalidAmi(issues *[]*issue.Issue) { | |||
type AwsInstanceInvalidAMIDetector struct { |
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.
[gometalinter]
- [golint] exported type AwsInstanceInvalidAMIDetector should have comment or be unexported
*Detector | ||
} | ||
|
||
func (d *Detector) CreateAwsInstanceInvalidAMIDetector() *AwsInstanceInvalidAMIDetector { |
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.
[gometalinter]
- [golint] exported method Detector.CreateAwsInstanceInvalidAMIDetector should have comment or be unexported
return &AwsInstanceInvalidAMIDetector{d} | ||
} | ||
|
||
func (d *AwsInstanceInvalidAMIDetector) Detect(issues *[]*issue.Issue) { |
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.
[gometalinter]
- [golint] exported method AwsInstanceInvalidAMIDetector.Detect should have comment or be unexported
@@ -7,19 +7,30 @@ import ( | |||
"github.com/wata727/tflint/issue" | |||
) | |||
|
|||
func (d *Detector) DetectAwsInstanceInvalidIamProfile(issues *[]*issue.Issue) { | |||
type AwsInstanceInvalidIAMProfileDetector struct { |
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.
[gometalinter]
- [golint] exported type AwsInstanceInvalidIAMProfileDetector should have comment or be unexported
*Detector | ||
} | ||
|
||
func (d *Detector) CreateAwsInstanceInvalidIAMProfileDetector() *AwsInstanceInvalidIAMProfileDetector { |
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.
[gometalinter]
- [golint] exported method Detector.CreateAwsInstanceInvalidIAMProfileDetector should have comment or be unexported
return &AwsInstanceInvalidIAMProfileDetector{d} | ||
} | ||
|
||
func (d *AwsInstanceInvalidIAMProfileDetector) Detect(issues *[]*issue.Issue) { |
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.
[gometalinter]
- [golint] exported method AwsInstanceInvalidIAMProfileDetector.Detect should have comment or be unexported
@@ -6,7 +6,15 @@ import ( | |||
"github.com/wata727/tflint/issue" | |||
) | |||
|
|||
func (d *Detector) DetectAwsInstanceInvalidType(issues *[]*issue.Issue) { | |||
type AwsInstanceInvalidTypeDetector struct { |
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.
[gometalinter]
- [golint] exported type AwsInstanceInvalidTypeDetector should have comment or be unexported
*Detector | ||
} | ||
|
||
func (d *Detector) CreateAwsInstanceInvalidTypeDetector() *AwsInstanceInvalidTypeDetector { |
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.
[gometalinter]
- [golint] exported method Detector.CreateAwsInstanceInvalidTypeDetector should have comment or be unexported
return &AwsInstanceInvalidTypeDetector{d} | ||
} | ||
|
||
func (d *AwsInstanceInvalidTypeDetector) Detect(issues *[]*issue.Issue) { |
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.
[gometalinter]
- [golint] exported method AwsInstanceInvalidTypeDetector.Detect should have comment or be unexported
@@ -2,7 +2,15 @@ package detector | |||
|
|||
import "github.com/wata727/tflint/issue" | |||
|
|||
func (d *Detector) DetectAwsInstanceNotSpecifiedIamProfile(issues *[]*issue.Issue) { | |||
type AwsInstanceNotSpecifiedIAMProfileDetector struct { |
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.
[gometalinter]
- [golint] exported type AwsInstanceNotSpecifiedIAMProfileDetector should have comment or be unexported
*Detector | ||
} | ||
|
||
func (d *Detector) CreateAwsInstanceNotSpecifiedIAMProfileDetector() *AwsInstanceNotSpecifiedIAMProfileDetector { |
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.
[gometalinter]
- [golint] exported method Detector.CreateAwsInstanceNotSpecifiedIAMProfileDetector should have comment or be unexported
return &AwsInstanceNotSpecifiedIAMProfileDetector{d} | ||
} | ||
|
||
func (d *AwsInstanceNotSpecifiedIAMProfileDetector) Detect(issues *[]*issue.Issue) { |
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.
[gometalinter]
- [golint] exported method AwsInstanceNotSpecifiedIAMProfileDetector.Detect should have comment or be unexported
@@ -17,3 +25,7 @@ func (d *Detector) DetectAwsInstanceNotSpecifiedIamProfile(issues *[]*issue.Issu | |||
} | |||
} | |||
} | |||
|
|||
func (d *AwsInstanceNotSpecifiedIAMProfileDetector) Inherit(original *AwsInstanceNotSpecifiedIAMProfileDetector) *AwsInstanceNotSpecifiedIAMProfileDetector { |
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.
[gometalinter]
- [golint] exported method AwsInstanceNotSpecifiedIAMProfileDetector.Inherit should have comment or be unexported
@@ -6,7 +6,15 @@ import ( | |||
"github.com/wata727/tflint/issue" | |||
) | |||
|
|||
func (d *Detector) DetectAwsInstancePreviousType(issues *[]*issue.Issue) { | |||
type AwsInstancePreviousTypeDetector struct { |
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.
[gometalinter]
- [golint] exported type AwsInstancePreviousTypeDetector should have comment or be unexported
*Detector | ||
} | ||
|
||
func (d *Detector) CreateAwsInstancePreviousTypeDetector() *AwsInstancePreviousTypeDetector { |
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.
[gometalinter]
- [golint] exported method Detector.CreateAwsInstancePreviousTypeDetector should have comment or be unexported
return &AwsInstancePreviousTypeDetector{d} | ||
} | ||
|
||
func (d *AwsInstancePreviousTypeDetector) Detect(issues *[]*issue.Issue) { |
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.
[gometalinter]
- [golint] exported method AwsInstancePreviousTypeDetector.Detect should have comment or be unexported
"github.com/aws/aws-sdk-go/service/iam" | ||
) | ||
|
||
type ResponseCache struct { |
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.
[gometalinter]
- [golint] exported type ResponseCache should have comment or be unexported
"github.com/wata727/tflint/issue" | ||
) | ||
|
||
type TestDetector struct { |
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.
[gometalinter]
- [golint] exported type TestDetector should have comment or be unexported
*Detector | ||
} | ||
|
||
func (d *Detector) CreateTestDetector() *TestDetector { |
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.
[gometalinter]
- [golint] exported method Detector.CreateTestDetector should have comment or be unexported
return &TestDetector{d} | ||
} | ||
|
||
func (d *TestDetector) Detect(issues *[]*issue.Issue) { |
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.
[gometalinter]
- [golint] exported method TestDetector.Detect should have comment or be unexported
}) | ||
} | ||
|
||
func TestDetectByCreatorName(creatorMethod string, src string, c *config.Config, awsClient *config.AwsClient, issues *[]*issue.Issue) { |
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.
[gometalinter]
- [golint] exported function TestDetectByCreatorName should have comment or be unexported
Umm... It's noisy. I have to review the settings in SideCI... |
Fix #9
Add cache mechanism for core detector. The following is an example of a deep check detecting that contains single module.
Before
After