Bump golangci-lint to 1.55.2 and fix issues

Signed-off-by: Khosrow Moossavi <khos2ow@gmail.com>
This commit is contained in:
Khosrow Moossavi
2023-12-19 12:51:04 -05:00
parent 4552242276
commit 5cfb2f2615
11 changed files with 108 additions and 111 deletions

View File

@@ -1,8 +1,6 @@
run:
timeout: 10m
deadline: 5m
tests: true
tests: false
output:
format: tab
@@ -100,7 +98,7 @@ linters:
- goimports
- gofmt # We enable this as well as goimports for its simplify mode.
- prealloc
- golint
# - golint # deprecated as of upgrading to 1.55.2
- unconvert
- misspell
- nakedret

View File

@@ -38,7 +38,7 @@ DOCKER_IMAGE := quay.io/$(PROJECT_OWNER)/$(PROJECT_NAME)
DOCKER_TAG ?= $(DEFAULT_TAG)
# Binary versions
GOLANGCI_VERSION := v1.47.2
GOLANGCI_VERSION := v1.55.2
.PHONY: all
all: clean verify checkfmt lint test build

View File

@@ -10,35 +10,35 @@ the root directory of this source tree.
// Package format provides different, out of the box supported, output format types.
//
// Usage
// # Usage
//
// A specific format can be instantiated either with `format.New()` function or
// directly calling its function (e.g. `NewMarkdownTable`, etc)
//
// config := print.DefaultConfig()
// config.Formatter = "markdown table"
// config := print.DefaultConfig()
// config.Formatter = "markdown table"
//
// formatter, err := format.New(config)
// if err != nil {
// return err
// }
// formatter, err := format.New(config)
// if err != nil {
// return err
// }
//
// err := formatter.Generate(tfmodule)
// if err != nil {
// return err
// }
// err := formatter.Generate(tfmodule)
// if err != nil {
// return err
// }
//
// output, err := formatter.Render"")
// if err != nil {
// return err
// }
// output, err := formatter.Render"")
// if err != nil {
// return err
// }
//
// Note: if you don't intend to provide additional template for the generated
// content, or the target format doesn't provide templating (e.g. json, yaml,
// xml, or toml) you can use `Content()` function instead of `Render)`. Note
// that `Content()` returns all the sections combined with predefined order.
//
// output := formatter.Content()
// output := formatter.Content()
//
// Supported formats are:
//
@@ -53,5 +53,4 @@ the root directory of this source tree.
// • `NewTOML`
// • `NewXML`
// • `NewYAML`
//
package format

View File

@@ -135,6 +135,8 @@ type generator struct {
// newGenerator returns a generator for specific formatter name and with
// provided sets of GeneratorFunc functions to build and add individual
// sections.
//
//nolint:unparam
func newGenerator(config *print.Config, canRender bool, fns ...generateFunc) *generator {
g := &generator{
config: config,

View File

@@ -286,7 +286,7 @@ func (l List) Raw() interface{} {
}
type xmllistentry struct {
XMLName xml.Name
XMLName xml.Name `xml:"item"`
Value interface{} `xml:",chardata"`
}
@@ -334,7 +334,7 @@ func (m Map) Length() int {
}
type xmlmapentry struct {
XMLName xml.Name
XMLName xml.Name `xml:","`
Value interface{} `xml:",chardata"`
}

View File

@@ -19,44 +19,43 @@ the root directory of this source tree.
// Implementation details are hidden in go-plugin. This package is
// essentially a wrapper for go-plugin.
//
// Usage
// # Usage
//
// A simple plugin can look like this:
//
// package main
// package main
//
// import (
// _ "embed" //nolint
// import (
// _ "embed" //nolint
//
// "github.com/terraform-docs/terraform-docs/plugin"
// "github.com/terraform-docs/terraform-docs/print"
// "github.com/terraform-docs/terraform-docs/template"
// "github.com/terraform-docs/terraform-docs/terraform"
// )
// "github.com/terraform-docs/terraform-docs/plugin"
// "github.com/terraform-docs/terraform-docs/print"
// "github.com/terraform-docs/terraform-docs/template"
// "github.com/terraform-docs/terraform-docs/terraform"
// )
//
// func main() {
// plugin.Serve(&plugin.ServeOpts{
// Name: "template",
// Version: "0.1.0",
// Printer: printerFunc,
// })
// }
// func main() {
// plugin.Serve(&plugin.ServeOpts{
// Name: "template",
// Version: "0.1.0",
// Printer: printerFunc,
// })
// }
//
// //go:embed sections.tmpl
// var tplCustom []byte
// //go:embed sections.tmpl
// var tplCustom []byte
//
// // printerFunc the function being executed by the plugin client.
// func printerFunc(config *print.Config, module *terraform.Module) (string, error) {
// tpl := template.New(config,
// &template.Item{Name: "custom", Text: string(tplCustom)},
// )
// // printerFunc the function being executed by the plugin client.
// func printerFunc(config *print.Config, module *terraform.Module) (string, error) {
// tpl := template.New(config,
// &template.Item{Name: "custom", Text: string(tplCustom)},
// )
//
// rendered, err := tpl.Render("custom", module)
// if err != nil {
// return "", err
// }
//
// return rendered, nil
// }
// rendered, err := tpl.Render("custom", module)
// if err != nil {
// return "", err
// }
//
// return rendered, nil
// }
package plugin

View File

@@ -10,7 +10,7 @@ the root directory of this source tree.
// Package print provides configuration, and a Generator.
//
// Configuration
// # Configuration
//
// `print.Config` is the data structure representation for `.terraform-docs.yml`
// which will be read and extracted upon execution of terraform-docs cli. On the
@@ -18,13 +18,13 @@ the root directory of this source tree.
//
// This will return an instance of `Config` with default values set:
//
// config := print.DefaultConfig()
// config := print.DefaultConfig()
//
// Alternatively this will return an empty instance of `Config`:
//
// config := print.NewConfig()
// config := print.NewConfig()
//
// Generator
// # Generator
//
// `Generator` is an abstract implementation of `format.Type`. It doesn't implement
// `Generate(*terraform.Module) error` function. It is used directly by different
@@ -46,5 +46,4 @@ the root directory of this source tree.
// • `{{ .Requirements }}`
// • `{{ .Resources }}`
// • `{{ include "path/fo/file" }}`
//
package print

View File

@@ -19,6 +19,7 @@ func contains(list []string, name string) bool {
return false
}
// nolint
func index(list []string, name string) int {
for i, v := range list {
if v == name {
@@ -28,6 +29,7 @@ func index(list []string, name string) int {
return -1
}
// nolint
func remove(list []string, name string) []string {
index := index(list, name)
if index < 0 {

View File

@@ -200,7 +200,7 @@ func example(ref *reference) error {
if s == "" {
buf.WriteString("\n")
} else {
buf.WriteString(fmt.Sprintf(" %s\n", s))
fmt.Fprintf(buf, " %s\n", s)
}
}
ref.Example = buf.String()

View File

@@ -12,43 +12,42 @@ the root directory of this source tree.
//
// Usage
//
// import (
// "fmt"
// gotemplate "text/template"
// import (
// "fmt"
// gotemplate "text/template"
//
// "github.com/terraform-docs/terraform-docs/print"
// "github.com/terraform-docs/terraform-docs/template"
// "github.com/terraform-docs/terraform-docs/terraform"
// )
// "github.com/terraform-docs/terraform-docs/print"
// "github.com/terraform-docs/terraform-docs/template"
// "github.com/terraform-docs/terraform-docs/terraform"
// )
//
// const mainTpl =`
// {{- if .Config.Sections.Header -}}
// {{- with .Module.Header -}}
// {{ colorize "\033[90m" . }}
// {{ end -}}
// {{- printf "\n\n" -}}
// {{ end -}}`
// const mainTpl =`
// {{- if .Config.Sections.Header -}}
// {{- with .Module.Header -}}
// {{ colorize "\033[90m" . }}
// {{ end -}}
// {{- printf "\n\n" -}}
// {{ end -}}`
//
// func render(config *print.Config, module *terraform.Module) (string, error) {
// tt := template.New(config, &template.Item{
// Name: "main",
// Text: mainTpl,
// TrimSpace: true,
// })
// func render(config *print.Config, module *terraform.Module) (string, error) {
// tt := template.New(config, &template.Item{
// Name: "main",
// Text: mainTpl,
// TrimSpace: true,
// })
//
// tt := template.New(config, items...)
// tt.CustomFunc(gotemplate.FuncMap{
// "colorize": func(color string, s string) string {
// reset := "\033[0m"
// if !config.Settings.Color {
// color = ""
// reset = ""
// }
// return fmt.Sprintf("%s%s%s", color, s, reset)
// },
// })
//
// return tt.Render("main", module)
// }
// tt := template.New(config, items...)
// tt.CustomFunc(gotemplate.FuncMap{
// "colorize": func(color string, s string) string {
// reset := "\033[0m"
// if !config.Settings.Color {
// color = ""
// reset = ""
// }
// return fmt.Sprintf("%s%s%s", color, s, reset)
// },
// })
//
// return tt.Render("main", module)
// }
package template

View File

@@ -30,23 +30,22 @@ the root directory of this source tree.
//
// Usage
//
// options := &terraform.Options{
// Path: "./examples",
// ShowHeader: true,
// HeaderFromFile: "main.tf",
// ShowFooter: true,
// FooterFromFile: "footer.md",
// SortBy: &terraform.SortBy{
// Name: true,
// },
// ReadComments: true,
// }
// options := &terraform.Options{
// Path: "./examples",
// ShowHeader: true,
// HeaderFromFile: "main.tf",
// ShowFooter: true,
// FooterFromFile: "footer.md",
// SortBy: &terraform.SortBy{
// Name: true,
// },
// ReadComments: true,
// }
//
// tfmodule, err := terraform.LoadWithOptions(options)
// if err != nil {
// log.Fatal(err)
// }
//
// ...
// tfmodule, err := terraform.LoadWithOptions(options)
// if err != nil {
// log.Fatal(err)
// }
//
// ...
package terraform