Skip to content

Commit 5cfb2f2

Browse files
committed
Bump golangci-lint to 1.55.2 and fix issues
Signed-off-by: Khosrow Moossavi <khos2ow@gmail.com>
1 parent 4552242 commit 5cfb2f2

File tree

11 files changed

+122
-125
lines changed

11 files changed

+122
-125
lines changed

.golangci.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
run:
22
timeout: 10m
3-
deadline: 5m
4-
5-
tests: true
3+
tests: false
64

75
output:
86
format: tab
@@ -100,7 +98,7 @@ linters:
10098
- goimports
10199
- gofmt # We enable this as well as goimports for its simplify mode.
102100
- prealloc
103-
- golint
101+
# - golint # deprecated as of upgrading to 1.55.2
104102
- unconvert
105103
- misspell
106104
- nakedret

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ DOCKER_IMAGE := quay.io/$(PROJECT_OWNER)/$(PROJECT_NAME)
3838
DOCKER_TAG ?= $(DEFAULT_TAG)
3939

4040
# Binary versions
41-
GOLANGCI_VERSION := v1.47.2
41+
GOLANGCI_VERSION := v1.55.2
4242

4343
.PHONY: all
4444
all: clean verify checkfmt lint test build

format/doc.go

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,35 +10,35 @@ the root directory of this source tree.
1010

1111
// Package format provides different, out of the box supported, output format types.
1212
//
13-
// Usage
13+
// # Usage
1414
//
1515
// A specific format can be instantiated either with `format.New()` function or
1616
// directly calling its function (e.g. `NewMarkdownTable`, etc)
1717
//
18-
// config := print.DefaultConfig()
19-
// config.Formatter = "markdown table"
18+
// config := print.DefaultConfig()
19+
// config.Formatter = "markdown table"
2020
//
21-
// formatter, err := format.New(config)
22-
// if err != nil {
23-
// return err
24-
// }
21+
// formatter, err := format.New(config)
22+
// if err != nil {
23+
// return err
24+
// }
2525
//
26-
// err := formatter.Generate(tfmodule)
27-
// if err != nil {
28-
// return err
29-
// }
26+
// err := formatter.Generate(tfmodule)
27+
// if err != nil {
28+
// return err
29+
// }
3030
//
31-
// output, err := formatter.Render"")
32-
// if err != nil {
33-
// return err
34-
// }
31+
// output, err := formatter.Render"")
32+
// if err != nil {
33+
// return err
34+
// }
3535
//
3636
// Note: if you don't intend to provide additional template for the generated
3737
// content, or the target format doesn't provide templating (e.g. json, yaml,
3838
// xml, or toml) you can use `Content()` function instead of `Render)`. Note
3939
// that `Content()` returns all the sections combined with predefined order.
4040
//
41-
// output := formatter.Content()
41+
// output := formatter.Content()
4242
//
4343
// Supported formats are:
4444
//
@@ -53,5 +53,4 @@ the root directory of this source tree.
5353
// • `NewTOML`
5454
// • `NewXML`
5555
// • `NewYAML`
56-
//
5756
package format

format/generator.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,8 @@ type generator struct {
135135
// newGenerator returns a generator for specific formatter name and with
136136
// provided sets of GeneratorFunc functions to build and add individual
137137
// sections.
138+
//
139+
//nolint:unparam
138140
func newGenerator(config *print.Config, canRender bool, fns ...generateFunc) *generator {
139141
g := &generator{
140142
config: config,

internal/types/types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ func (l List) Raw() interface{} {
286286
}
287287

288288
type xmllistentry struct {
289-
XMLName xml.Name
289+
XMLName xml.Name `xml:"item"`
290290
Value interface{} `xml:",chardata"`
291291
}
292292

@@ -334,7 +334,7 @@ func (m Map) Length() int {
334334
}
335335

336336
type xmlmapentry struct {
337-
XMLName xml.Name
337+
XMLName xml.Name `xml:","`
338338
Value interface{} `xml:",chardata"`
339339
}
340340

plugin/doc.go

Lines changed: 36 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -19,44 +19,43 @@ the root directory of this source tree.
1919
// Implementation details are hidden in go-plugin. This package is
2020
// essentially a wrapper for go-plugin.
2121
//
22-
// Usage
22+
// # Usage
2323
//
2424
// A simple plugin can look like this:
2525
//
26-
// package main
27-
//
28-
// import (
29-
// _ "embed" //nolint
30-
//
31-
// "github.com/terraform-docs/terraform-docs/plugin"
32-
// "github.com/terraform-docs/terraform-docs/print"
33-
// "github.com/terraform-docs/terraform-docs/template"
34-
// "github.com/terraform-docs/terraform-docs/terraform"
35-
// )
36-
//
37-
// func main() {
38-
// plugin.Serve(&plugin.ServeOpts{
39-
// Name: "template",
40-
// Version: "0.1.0",
41-
// Printer: printerFunc,
42-
// })
43-
// }
44-
//
45-
// //go:embed sections.tmpl
46-
// var tplCustom []byte
47-
//
48-
// // printerFunc the function being executed by the plugin client.
49-
// func printerFunc(config *print.Config, module *terraform.Module) (string, error) {
50-
// tpl := template.New(config,
51-
// &template.Item{Name: "custom", Text: string(tplCustom)},
52-
// )
53-
//
54-
// rendered, err := tpl.Render("custom", module)
55-
// if err != nil {
56-
// return "", err
57-
// }
58-
//
59-
// return rendered, nil
60-
// }
61-
//
26+
// package main
27+
//
28+
// import (
29+
// _ "embed" //nolint
30+
//
31+
// "github.com/terraform-docs/terraform-docs/plugin"
32+
// "github.com/terraform-docs/terraform-docs/print"
33+
// "github.com/terraform-docs/terraform-docs/template"
34+
// "github.com/terraform-docs/terraform-docs/terraform"
35+
// )
36+
//
37+
// func main() {
38+
// plugin.Serve(&plugin.ServeOpts{
39+
// Name: "template",
40+
// Version: "0.1.0",
41+
// Printer: printerFunc,
42+
// })
43+
// }
44+
//
45+
// //go:embed sections.tmpl
46+
// var tplCustom []byte
47+
//
48+
// // printerFunc the function being executed by the plugin client.
49+
// func printerFunc(config *print.Config, module *terraform.Module) (string, error) {
50+
// tpl := template.New(config,
51+
// &template.Item{Name: "custom", Text: string(tplCustom)},
52+
// )
53+
//
54+
// rendered, err := tpl.Render("custom", module)
55+
// if err != nil {
56+
// return "", err
57+
// }
58+
//
59+
// return rendered, nil
60+
// }
6261
package plugin

print/doc.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,21 @@ the root directory of this source tree.
1010

1111
// Package print provides configuration, and a Generator.
1212
//
13-
// Configuration
13+
// # Configuration
1414
//
1515
// `print.Config` is the data structure representation for `.terraform-docs.yml`
1616
// which will be read and extracted upon execution of terraform-docs cli. On the
1717
// other hand it can be used directly if you are using terraform-docs as a library.
1818
//
1919
// This will return an instance of `Config` with default values set:
2020
//
21-
// config := print.DefaultConfig()
21+
// config := print.DefaultConfig()
2222
//
2323
// Alternatively this will return an empty instance of `Config`:
2424
//
25-
// config := print.NewConfig()
25+
// config := print.NewConfig()
2626
//
27-
// Generator
27+
// # Generator
2828
//
2929
// `Generator` is an abstract implementation of `format.Type`. It doesn't implement
3030
// `Generate(*terraform.Module) error` function. It is used directly by different
@@ -46,5 +46,4 @@ the root directory of this source tree.
4646
// • `{{ .Requirements }}`
4747
// • `{{ .Resources }}`
4848
// • `{{ include "path/fo/file" }}`
49-
//
5049
package print

print/util.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ func contains(list []string, name string) bool {
1919
return false
2020
}
2121

22+
// nolint
2223
func index(list []string, name string) int {
2324
for i, v := range list {
2425
if v == name {
@@ -28,6 +29,7 @@ func index(list []string, name string) int {
2829
return -1
2930
}
3031

32+
// nolint
3133
func remove(list []string, name string) []string {
3234
index := index(list, name)
3335
if index < 0 {

scripts/docs/generate.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ func example(ref *reference) error {
200200
if s == "" {
201201
buf.WriteString("\n")
202202
} else {
203-
buf.WriteString(fmt.Sprintf(" %s\n", s))
203+
fmt.Fprintf(buf, " %s\n", s)
204204
}
205205
}
206206
ref.Example = buf.String()

template/doc.go

Lines changed: 38 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -12,43 +12,42 @@ the root directory of this source tree.
1212
//
1313
// Usage
1414
//
15-
// import (
16-
// "fmt"
17-
// gotemplate "text/template"
18-
//
19-
// "github.com/terraform-docs/terraform-docs/print"
20-
// "github.com/terraform-docs/terraform-docs/template"
21-
// "github.com/terraform-docs/terraform-docs/terraform"
22-
// )
23-
//
24-
// const mainTpl =`
25-
// {{- if .Config.Sections.Header -}}
26-
// {{- with .Module.Header -}}
27-
// {{ colorize "\033[90m" . }}
28-
// {{ end -}}
29-
// {{- printf "\n\n" -}}
30-
// {{ end -}}`
31-
//
32-
// func render(config *print.Config, module *terraform.Module) (string, error) {
33-
// tt := template.New(config, &template.Item{
34-
// Name: "main",
35-
// Text: mainTpl,
36-
// TrimSpace: true,
37-
// })
38-
//
39-
// tt := template.New(config, items...)
40-
// tt.CustomFunc(gotemplate.FuncMap{
41-
// "colorize": func(color string, s string) string {
42-
// reset := "\033[0m"
43-
// if !config.Settings.Color {
44-
// color = ""
45-
// reset = ""
46-
// }
47-
// return fmt.Sprintf("%s%s%s", color, s, reset)
48-
// },
49-
// })
50-
//
51-
// return tt.Render("main", module)
52-
// }
53-
//
15+
// import (
16+
// "fmt"
17+
// gotemplate "text/template"
18+
//
19+
// "github.com/terraform-docs/terraform-docs/print"
20+
// "github.com/terraform-docs/terraform-docs/template"
21+
// "github.com/terraform-docs/terraform-docs/terraform"
22+
// )
23+
//
24+
// const mainTpl =`
25+
// {{- if .Config.Sections.Header -}}
26+
// {{- with .Module.Header -}}
27+
// {{ colorize "\033[90m" . }}
28+
// {{ end -}}
29+
// {{- printf "\n\n" -}}
30+
// {{ end -}}`
31+
//
32+
// func render(config *print.Config, module *terraform.Module) (string, error) {
33+
// tt := template.New(config, &template.Item{
34+
// Name: "main",
35+
// Text: mainTpl,
36+
// TrimSpace: true,
37+
// })
38+
//
39+
// tt := template.New(config, items...)
40+
// tt.CustomFunc(gotemplate.FuncMap{
41+
// "colorize": func(color string, s string) string {
42+
// reset := "\033[0m"
43+
// if !config.Settings.Color {
44+
// color = ""
45+
// reset = ""
46+
// }
47+
// return fmt.Sprintf("%s%s%s", color, s, reset)
48+
// },
49+
// })
50+
//
51+
// return tt.Render("main", module)
52+
// }
5453
package template

terraform/doc.go

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -30,23 +30,22 @@ the root directory of this source tree.
3030
//
3131
// Usage
3232
//
33-
// options := &terraform.Options{
34-
// Path: "./examples",
35-
// ShowHeader: true,
36-
// HeaderFromFile: "main.tf",
37-
// ShowFooter: true,
38-
// FooterFromFile: "footer.md",
39-
// SortBy: &terraform.SortBy{
40-
// Name: true,
41-
// },
42-
// ReadComments: true,
43-
// }
44-
//
45-
// tfmodule, err := terraform.LoadWithOptions(options)
46-
// if err != nil {
47-
// log.Fatal(err)
48-
// }
49-
//
50-
// ...
51-
//
33+
// options := &terraform.Options{
34+
// Path: "./examples",
35+
// ShowHeader: true,
36+
// HeaderFromFile: "main.tf",
37+
// ShowFooter: true,
38+
// FooterFromFile: "footer.md",
39+
// SortBy: &terraform.SortBy{
40+
// Name: true,
41+
// },
42+
// ReadComments: true,
43+
// }
44+
//
45+
// tfmodule, err := terraform.LoadWithOptions(options)
46+
// if err != nil {
47+
// log.Fatal(err)
48+
// }
49+
//
50+
// ...
5251
package terraform

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy