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

Provide abstract HCL access #112

Merged
merged 1 commit into from
Jun 18, 2017
Merged

Provide abstract HCL access #112

merged 1 commit into from
Jun 18, 2017

Conversation

wata727
Copy link
Member

@wata727 wata727 commented May 28, 2017

Fix #103

Currently, TFLint takes a direct reference to the interface provided by hashicorp/hcl. But, In this approach, handling of override is very difficult.

As a countermeasure for this problem, introduce schema package. In this approach, all access to HCL is through this package. So, override implementation is in this package.

schema/schema.go Outdated
Resources: []*Resource{},
}
var ret map[string]map[string]interface{}
root, _ := parser.Parse(body)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[gometalinter]

  • [gas] Errors unhandled.,LOW,HIGH

schema/schema.go Outdated
}
var ret map[string]map[string]interface{}
root, _ := parser.Parse(body)
hcl.DecodeObject(&ret, root)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[gometalinter]

  • [gas] Errors unhandled.,LOW,HIGH

}

for _, template := range templates {
sort.Slice(template.Resources, func(i, j int) bool {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[gometalinter]

  • [gosimple] Slice not declared by package sort
  • [staticcheck] Slice not declared by package sort
  • [varcheck] unused variable or constant Slice not declared by package sort

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm... sort.Slice is valid function 🤔

}
}

func appendTemplates(templates []*Template, files map[string][]byte, override bool) ([]*Template, error) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[gometalinter]

  • [gocyclo] cyclomatic complexity 16 of function appendTemplates() is high (> 15)

}

for _, template := range templates {
sort.Slice(template.Resources, func(i, j int) bool {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[gometalinter]

  • [staticcheck] Slice not declared by package sort
  • [gosimple] Slice not declared by package sort
  • [varcheck] unused variable or constant Slice not declared by package sort

fmt.Fprintln(cli.errStream, fmt.Errorf("ERROR: Parse error: %s", err))
return ExitCodeError
}
cli.detector, err = detector.NewDetector(templates, schema, state, tfvars, c)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[gometalinter]

  • [ineffassign] ineffectual assignment to err

}
}

func appendTemplates(templates []*Template, files map[string][]byte, override bool) ([]*Template, error) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[gometalinter]

  • [gocyclo] cyclomatic complexity 17 of function appendTemplates() is high (> 15)

}

for _, template := range templates {
sort.Slice(template.Resources, func(i, j int) bool {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[gometalinter]

  • [varcheck] unused variable or constant Slice not declared by package sort
  • [gosimple] Slice not declared by package sort
  • [staticcheck] Slice not declared by package sort

fmt.Fprintln(cli.errStream, fmt.Errorf("ERROR: Parse error: %s", err))
return ExitCodeError
}
cli.detector, err = detector.NewDetector(templates, schema, state, tfvars, c)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[gometalinter]

  • [ineffassign] ineffectual assignment to err
  • [staticcheck] this value of err is never used (SA4006)

}

for _, template := range templates {
sort.Slice(template.Resources, func(i, j int) bool {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[gometalinter]

  • [gosimple] Slice not declared by package sort
  • [staticcheck] Slice not declared by package sort
  • [varcheck] unused variable or constant Slice not declared by package sort

@wata727 wata727 changed the title [WIP] Provide abstract HCL access Provide abstract HCL access Jun 18, 2017
}

for _, template := range templates {
sort.Slice(template.Resources, func(i, j int) bool {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[gometalinter]

  • [staticcheck] Slice not declared by package sort
  • [varcheck] unused variable or constant Slice not declared by package sort
  • [gosimple] Slice not declared by package sort

@wata727 wata727 merged commit 2ad0bc6 into master Jun 18, 2017
@wata727 wata727 deleted the abstract_hcl_access branch June 18, 2017 12:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant