From 82305bf1c8fe9440160f9473a3dad2afbfd5b504 Mon Sep 17 00:00:00 2001 From: James Bardin Date: Tue, 1 Dec 2020 16:37:47 -0500 Subject: [PATCH] configs: staticcheck --- configs/module.go | 12 ++++-------- configs/module_merge_body.go | 4 +--- configs/parser_test.go | 10 ---------- 3 files changed, 5 insertions(+), 21 deletions(-) diff --git a/configs/module.go b/configs/module.go index 9ca4c2b76..126eebbdb 100644 --- a/configs/module.go +++ b/configs/module.go @@ -167,11 +167,9 @@ func (m *Module) ResourceByAddr(addr addrs.Resource) *Resource { func (m *Module) appendFile(file *File) hcl.Diagnostics { var diags hcl.Diagnostics - for _, constraint := range file.CoreVersionConstraints { - // If there are any conflicting requirements then we'll catch them - // when we actually check these constraints. - m.CoreVersionConstraints = append(m.CoreVersionConstraints, constraint) - } + // If there are any conflicting requirements then we'll catch them + // when we actually check these constraints. + m.CoreVersionConstraints = append(m.CoreVersionConstraints, file.CoreVersionConstraints...) m.ActiveExperiments = experiments.SetUnion(m.ActiveExperiments, file.ActiveExperiments) @@ -341,9 +339,7 @@ func (m *Module) mergeFile(file *File) hcl.Diagnostics { // would union together across multiple files anyway, but we'll // allow it and have each override file clobber any existing list. m.CoreVersionConstraints = nil - for _, constraint := range file.CoreVersionConstraints { - m.CoreVersionConstraints = append(m.CoreVersionConstraints, constraint) - } + m.CoreVersionConstraints = append(m.CoreVersionConstraints, file.CoreVersionConstraints...) } if len(file.Backends) != 0 { diff --git a/configs/module_merge_body.go b/configs/module_merge_body.go index 7b51eae85..6ae64a2a9 100644 --- a/configs/module_merge_body.go +++ b/configs/module_merge_body.go @@ -112,9 +112,7 @@ func (b mergeBody) prepareContent(base *hcl.BodyContent, override *hcl.BodyConte } content.Blocks = append(content.Blocks, block) } - for _, block := range override.Blocks { - content.Blocks = append(content.Blocks, block) - } + content.Blocks = append(content.Blocks, override.Blocks...) return content } diff --git a/configs/parser_test.go b/configs/parser_test.go index a87ad68fd..cb2239282 100644 --- a/configs/parser_test.go +++ b/configs/parser_test.go @@ -38,16 +38,6 @@ func testParser(files map[string]string) *Parser { return NewParser(fs) } -// testModuleFromFile reads a single file, wraps it in a module, and returns -// it. This is a helper for use in unit tests. -func testModuleFromFile(filename string) (*Module, hcl.Diagnostics) { - parser := NewParser(nil) - f, diags := parser.LoadConfigFile(filename) - mod, modDiags := NewModule([]*File{f}, nil) - diags = append(diags, modDiags...) - return mod, modDiags -} - // testModuleConfigFrom File reads a single file from the given path as a // module and returns its configuration. This is a helper for use in unit tests. func testModuleConfigFromFile(filename string) (*Config, hcl.Diagnostics) {