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

Introduce more stringent golangci-lint checks & address issues raised #538

Merged
merged 12 commits into from
Oct 4, 2021

Conversation

tstromberg
Copy link
Contributor

Description

This introduces a more stringent golangci-lint configuration from the lint-install tool, as well as adds some Makefile rules to run lint locally in a way that matches CI.

Detailed Changes

This PR includes fixes for the following lint changes, as well as some basic reformatting (gofumpt for Go, and prettier for YAML). This PR does not enforce the Dockerfile lint checks yet, but does warn about them.

This PR does add some //nolint directives for issues that require substantial future refactoring work.

client/main.go:20:16: Comment should end in a period (godot)
// gRPC clients
               ^
client/main.go:27:79: Comment should end in a period (godot)
// FullClient aggregates all the gRPC clients available from Tinkerbell Server
                                                                              ^
client/main.go:56:67: Comment should end in a period (godot)
// instead of NewFullClientFromGlobal that will be deprecated soon
                                                                  ^
client/main.go:101:50: Comment should end in a period (godot)
// GetConnection returns a gRPC client connection
                                                 ^
client/main.go:140:41: Comment should end in a period (godot)
// Setup : create a connection to server
                                        ^
client/main.go:152:52: Comment should end in a period (godot)
// TinkHardwareClient creates a new hardware client
                                                   ^
client/main.go:161:52: Comment should end in a period (godot)
// TinkWorkflowClient creates a new workflow client
                                                   ^
cmd/tink-cli/cmd/completion.go:11:45: Comment should end in a period (godot)
// bash or zsh completion script for the CLI
                                            ^
cmd/tink-cli/cmd/completion.go:12:20: unused-parameter: parameter 'name' seems to be unused, consider removing or renaming it as _ (revive)
func completionCmd(name string) *cobra.Command {
                   ^
cmd/tink-cli/cmd/delete/delete.go:1:9: package name delete has same name as predeclared identifier (predeclared)
package delete
        ^
cmd/tink-cli/cmd/delete/delete.go:101:23: error-strings: error strings should not be capitalized or end with punctuation or a newline (revive)
				return errors.New("DeleteByID is not implemented for this resource yet. Please have a look at the issue in GitHub or open a new one.")
				                  ^
cmd/tink-cli/cmd/delete/delete.go:109:13: superfluous-else: if block ends with a continue statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary) (revive)
					} else {
						return err
					}
cmd/tink-cli/cmd/delete/delete_test.go:1:9: package name delete has same name as predeclared identifier (predeclared)
package delete
        ^
cmd/tink-cli/cmd/delete/doc.go:4:9: package name delete has same name as predeclared identifier (predeclared)
package delete
        ^
cmd/tink-cli/cmd/docs.go:10: File is not `gofumpt`-ed (gofumpt)
var (
	docsPath string
)
cmd/tink-cli/cmd/docs.go:15:17: Comment should end in a period (godot)
// documentation
                ^
cmd/tink-cli/cmd/docs_test.go:33:13: test helper function should start from t.Helper() (thelper)
			cmdFunc: func(t *testing.T, c *cobra.Command) {
			         ^
cmd/tink-cli/cmd/docs_test.go:45:13: test helper function should start from t.Helper() (thelper)
			cmdFunc: func(t *testing.T, c *cobra.Command) {
			         ^
cmd/tink-cli/cmd/docs_test.go:62:13: test helper function should start from t.Helper() (thelper)
			cmdFunc: func(t *testing.T, c *cobra.Command) {
			         ^
cmd/tink-cli/cmd/docs_test.go:92:13: test helper function should start from t.Helper() (thelper)
			cmdFunc: func(t *testing.T, c *cobra.Command) {
			         ^
cmd/tink-cli/cmd/docs_test.go:122:13: test helper function should start from t.Helper() (thelper)
			cmdFunc: func(t *testing.T, c *cobra.Command) {
			         ^
cmd/tink-cli/cmd/get/get.go:100:24: error-strings: error strings should not be capitalized or end with punctuation or a newline (revive)
					return errors.New("Get by ID is not implemented for this resource yet. Please have a look at the issue in GitHub or open a new one.")
					                  ^
cmd/tink-cli/cmd/get/get_test.go:17:2: import-shadowing: The name 'table' shadows an import name (revive)
	table := []struct {
	^
cmd/tink-cli/cmd/hardware/commands.go:18:45: Comment should end in a period (godot)
// Example: tinkerbell template [subcommand]
                                            ^
cmd/tink-cli/cmd/hardware/get.go:42:19: comparing with != will fail on wrapped errors. Use errors.Is to check for a specific error (errorlint)
	if err != nil && err != io.EOF {
	                 ^
cmd/tink-cli/cmd/hardware/get.go:56: File is not `gofumpt`-ed (gofumpt)
				t.AppendRow(table.Row{hw.Id,
cmd/tink-cli/cmd/hardware/get.go:59: File is not `gofumpt`-ed (gofumpt)
					iface.Dhcp.Hostname})
cmd/tink-cli/cmd/hardware/get_test.go:84:9: assignOp: replace `s.counter = s.counter + 1` with `s.counter++` (gocritic)
								s.counter = s.counter + 1
								^
cmd/tink-cli/cmd/hardware/id.go:17:35: Comment should end in a period (godot)
// idCmd represents the id command
                                  ^
cmd/tink-cli/cmd/hardware/ip.go:18:35: Comment should end in a period (godot)
// ipCmd represents the ip command
                                  ^
cmd/tink-cli/cmd/hardware/list.go:58:19: comparing with != will fail on wrapped errors. Use errors.Is to check for a specific error (errorlint)
	if err != nil && err != io.EOF {
	                 ^
cmd/tink-cli/cmd/hardware/push.go:26:39: Comment should end in a period (godot)
// pushCmd represents the push command
                                      ^
cmd/tink-cli/cmd/hardware/push.go:96:3: exitAfterDefer: log.Fatal will exit, and `defer f.Close()` will not run (gocritic)
		log.Fatal(err)
		^
cmd/tink-cli/cmd/hardware_test.go:27:13: test helper function should start from t.Helper() (thelper)
			cmdFunc: func(t *testing.T, c *cobra.Command) {
			         ^
cmd/tink-cli/cmd/hardware_test.go:40:13: test helper function should start from t.Helper() (thelper)
			cmdFunc: func(t *testing.T, c *cobra.Command) {
			         ^
cmd/tink-cli/cmd/hardware_test.go:57:13: test helper function should start from t.Helper() (thelper)
			cmdFunc: func(t *testing.T, c *cobra.Command) {
			         ^
cmd/tink-cli/cmd/hardware_test.go:74:13: test helper function should start from t.Helper() (thelper)
			cmdFunc: func(t *testing.T, c *cobra.Command) {
			         ^
cmd/tink-cli/cmd/hardware_test.go:91:13: test helper function should start from t.Helper() (thelper)
			cmdFunc: func(t *testing.T, c *cobra.Command) {
			         ^
cmd/tink-cli/cmd/hardware_test.go:108:13: test helper function should start from t.Helper() (thelper)
			cmdFunc: func(t *testing.T, c *cobra.Command) {
			         ^
cmd/tink-cli/cmd/hardware_test.go:126:13: test helper function should start from t.Helper() (thelper)
			cmdFunc: func(t *testing.T, c *cobra.Command) {
			         ^
cmd/tink-cli/cmd/root.go:13:75: Comment should end in a period (godot)
// rootCmd represents the base command when called without any subcommands
                                                                          ^
cmd/tink-cli/cmd/template/get.go:18:61: Comment should end in a period (godot)
// getCmd represents the get subcommand for template command
                                                            ^
cmd/tink-cli/cmd/template/get.go:46:22: unnecessary conversion (unconvert)
			fmt.Println(string(t.Data))
			                  ^
cmd/tink-cli/cmd/template/get.go:55:36: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
func (h *getTemplate) RetrieveByID(ctx context.Context, cl *client.FullClient, requestedID string) (interface{}, error) {
                                   ^
cmd/tink-cli/cmd/template/get.go:78:19: comparing with != will fail on wrapped errors. Use errors.Is to check for a specific error (errorlint)
	if err != nil && err != io.EOF {
	                 ^
cmd/tink-cli/cmd/template/get.go:87: File is not `gofumpt`-ed (gofumpt)
			t.AppendRow(table.Row{tmp.Id, tmp.Name,
cmd/tink-cli/cmd/template/get.go:89: File is not `gofumpt`-ed (gofumpt)
				tmp.UpdatedAt.AsTime().Format(time.RFC3339)})
cmd/tink-cli/cmd/template/get_test.go:59:9: assignOp: replace `s.counter = s.counter + 1` with `s.counter++` (gocritic)
								s.counter = s.counter + 1
								^
cmd/tink-cli/cmd/template/list.go:17:17: Comment should end in a period (godot)
// table headers
                ^
cmd/tink-cli/cmd/template/list.go:30:63: Comment should end in a period (godot)
// listCmd represents the list subcommand for template command
                                                              ^
cmd/tink-cli/cmd/template/list.go:78:19: comparing with != will fail on wrapped errors. Use errors.Is to check for a specific error (errorlint)
	if err != nil && err != io.EOF {
	                 ^
cmd/tink-cli/cmd/template/update.go:17:64: Comment should end in a period (godot)
// updateCmd represents the get subcommand for template command
                                                               ^
cmd/tink-cli/cmd/template/update.go:86:3: exitAfterDefer: log.Fatal will exit, and `defer f.Close()` will not run (gocritic)
		log.Fatal(err)
		^
cmd/tink-cli/cmd/template_test.go:27:13: test helper function should start from t.Helper() (thelper)
			cmdFunc: func(t *testing.T, c *cobra.Command) {
			         ^
cmd/tink-cli/cmd/template_test.go:40:13: test helper function should start from t.Helper() (thelper)
			cmdFunc: func(t *testing.T, c *cobra.Command) {
			         ^
cmd/tink-cli/cmd/template_test.go:58:13: test helper function should start from t.Helper() (thelper)
			cmdFunc: func(t *testing.T, c *cobra.Command) {
			         ^
cmd/tink-cli/cmd/template_test.go:76:13: test helper function should start from t.Helper() (thelper)
			cmdFunc: func(t *testing.T, c *cobra.Command) {
			         ^
cmd/tink-cli/cmd/template_test.go:94:13: test helper function should start from t.Helper() (thelper)
			cmdFunc: func(t *testing.T, c *cobra.Command) {
			         ^
cmd/tink-cli/cmd/template_test.go:112:13: test helper function should start from t.Helper() (thelper)
			cmdFunc: func(t *testing.T, c *cobra.Command) {
			         ^
cmd/tink-cli/cmd/workflow/create.go:43:21: unused-parameter: parameter 'args' seems to be unused, consider removing or renaming it as _ (revive)
func createWorkflow(args []string) {
                    ^
cmd/tink-cli/cmd/workflow/data.go:20:63: Comment should end in a period (godot)
// dataCmd represents the data subcommand for workflow command
                                                              ^
cmd/tink-cli/cmd/workflow/data.go:42:5: ifElseChain: rewrite if-else to switch statement (gocritic)
				if needsMetadata {
				^
cmd/tink-cli/cmd/workflow/events.go:43: File is not `gofumpt`-ed (gofumpt)

cmd/tink-cli/cmd/workflow/events.go:56:3: commentFormatting: put a space between `//` and comment text (gocritic)
		//var wf *workflow.Workflow
		^
cmd/tink-cli/cmd/workflow/events.go:63:20: comparing with != will fail on wrapped errors. Use errors.Is to check for a specific error (errorlint)
		if err != nil && err != io.EOF {
		                 ^
cmd/tink-cli/cmd/workflow/get.go:23:61: Comment should end in a period (godot)
// getCmd represents the get subcommand for workflow command
                                                            ^
cmd/tink-cli/cmd/workflow/get.go:79:19: comparing with != will fail on wrapped errors. Use errors.Is to check for a specific error (errorlint)
	if err != nil && err != io.EOF {
	                 ^
cmd/tink-cli/cmd/workflow/get.go:88: File is not `gofumpt`-ed (gofumpt)
			t.AppendRow(table.Row{w.Id, w.Template,
cmd/tink-cli/cmd/workflow/get.go:91: File is not `gofumpt`-ed (gofumpt)
				w.UpdatedAt.AsTime().UTC().Format(time.RFC3339)})
cmd/tink-cli/cmd/workflow/list.go:25:63: Comment should end in a period (godot)
// listCmd represents the list subcommand for workflow command
                                                              ^
cmd/tink-cli/cmd/workflow/list.go:76:19: comparing with != will fail on wrapped errors. Use errors.Is to check for a specific error (errorlint)
	if err != nil && err != io.EOF {
	                 ^
cmd/tink-cli/cmd/workflow/state.go:46: unnecessary trailing newline (whitespace)

			}
cmd/tink-cli/cmd/workflow_test.go:26:13: test helper function should start from t.Helper() (thelper)
			cmdFunc: func(t *testing.T, c *cobra.Command) {
			         ^
cmd/tink-cli/cmd/workflow_test.go:39:13: test helper function should start from t.Helper() (thelper)
			cmdFunc: func(t *testing.T, c *cobra.Command) {
			         ^
cmd/tink-cli/cmd/workflow_test.go:56:13: test helper function should start from t.Helper() (thelper)
			cmdFunc: func(t *testing.T, c *cobra.Command) {
			         ^
cmd/tink-cli/cmd/workflow_test.go:73:13: test helper function should start from t.Helper() (thelper)
			cmdFunc: func(t *testing.T, c *cobra.Command) {
			         ^
cmd/tink-cli/cmd/workflow_test.go:90:13: test helper function should start from t.Helper() (thelper)
			cmdFunc: func(t *testing.T, c *cobra.Command) {
			         ^
cmd/tink-cli/cmd/workflow_test.go:107:13: test helper function should start from t.Helper() (thelper)
			cmdFunc: func(t *testing.T, c *cobra.Command) {
			         ^
cmd/tink-cli/cmd/workflow_test.go:124:13: test helper function should start from t.Helper() (thelper)
			cmdFunc: func(t *testing.T, c *cobra.Command) {
			         ^
cmd/tink-cli/cmd/workflow_test.go:141:13: test helper function should start from t.Helper() (thelper)
			cmdFunc: func(t *testing.T, c *cobra.Command) {
			         ^
cmd/tink-cli/main.go:12:32: Comment should end in a period (godot)
// version is set at build time
                               ^
cmd/tink-cli/main.go:21:3: exitAfterDefer: os.Exit will exit, and `defer otelShutdown(ctx)` will not run (gocritic)
		os.Exit(1)
		^
cmd/tink-server/main.go:23: File is not `gofumpt`-ed (gofumpt)
var (
	// version is set at build time
	version = "devel"
)
cmd/tink-server/main.go:24:33: Comment should end in a period (godot)
	// version is set at build time
	                               ^
cmd/tink-server/main.go:114:3: exitAfterDefer: os.Exit will exit, and `defer otelShutdown(ctx)` will not run (gocritic)
		os.Exit(1)
		^
cmd/tink-server/main.go:116: File is not `gofumpt`-ed (gofumpt)

cmd/tink-worker/cmd/root.go:23:49: commentFormatting: put a space between `//` and comment text (gocritic)
	defaultMaxFileSize    int64 = 10 * 1024 * 1024 //10MB
	                                               ^
cmd/tink-worker/cmd/root.go:27:63: Comment should end in a period (godot)
// NewRootCommand creates a new Tink Worker Cobra root command
                                                              ^
cmd/tink-worker/cmd/root.go:84:51: unnecessary conversion (unconvert)
	rootCmd.Flags().Duration("timeout", time.Duration(defaultTimeoutMinutes*time.Minute), "Max duration to wait for worker to complete (TIMEOUT)")
	                                                 ^
cmd/tink-worker/cmd/root.go:141:2: import-shadowing: The name 'errors' shadows an import name (revive)
	errors := []error{}
	^
cmd/tink-worker/cmd/root.go:169:17: Multiplication of durations: `retryInterval * time.Second` (durationcheck)
			<-time.After(retryInterval * time.Second)
			             ^
cmd/tink-worker/internal/action.go:47:2: variable 'pidConfig' is only used in the if-statement (cmd/tink-worker/internal/action.go:48:2); consider using short syntax (ifshort)
	pidConfig := action.GetPid()
	^
cmd/tink-worker/internal/action.go:70:3: error is not nil (line 69) but it returns nil (nilerr)
		return pb.State_STATE_FAILED, nil
		^
cmd/tink-worker/internal/registry.go:16:35: Comment should end in a period (godot)
// registry and logging activities
                                  ^
cmd/tink-worker/internal/registry.go:24:63: Comment should end in a period (godot)
// ImagePullStatus is the status of the downloaded Image chunk
                                                              ^
cmd/tink-worker/internal/registry.go:35:60: Comment should end in a period (godot)
// NewRegistryConnDetails creates a new RegistryConnDetails
                                                           ^
cmd/tink-worker/internal/registry.go:45:72: Comment should end in a period (godot)
// NewClient uses the RegistryConnDetails to create a new Docker Client
                                                                       ^
cmd/tink-worker/internal/registry.go:51: File is not `gofumpt`-ed (gofumpt)

cmd/tink-worker/internal/registry.go:63:94: Comment should end in a period (godot)
// pullImage outputs to stdout the contents of the requested image (relative to the registry)
                                                                                             ^
cmd/tink-worker/internal/registry.go:85:7: comparing with == will fail on wrapped errors. Use errors.Is to check for a specific error (errorlint)
			if err == io.EOF {
			   ^
cmd/tink-worker/internal/registry_test.go:16:6: test helper function should start from t.Helper() (thelper)
func setupTestLogger(t *testing.T) log.Logger {
     ^
cmd/tink-worker/internal/registry_test.go:30:37: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
func (d *imagePullerMock) ImagePull(ctx context.Context, str string, op types.ImagePullOptions) (io.ReadCloser, error) {
                                    ^
cmd/tink-worker/internal/worker.go:41:61: Comment should end in a period (godot)
// WorkflowMetadata is the metadata related to workflow data
                                                            ^
cmd/tink-worker/internal/worker.go:50:58: Comment should end in a period (godot)
// Worker details provide all the context needed to run a
                                                         ^
cmd/tink-worker/internal/worker.go:62:73: Comment should end in a period (godot)
// NewWorker creates a new Worker, creating a new Docker registry client
                                                                        ^
cmd/tink-worker/internal/worker.go:63:16: import-shadowing: The name 'client' shadows an import name (revive)
func NewWorker(client pb.WorkflowServiceClient, regConn *RegistryConnDetails, logger log.Logger, registry string, retries int, retryInterval time.Duration, maxFileSize int64) *Worker {
               ^
cmd/tink-worker/internal/worker.go:133:2: import-shadowing: The name 'status' shadows an import name (revive)
	status, waitErr := waitContainer(timeCtx, cli, id)
	^
cmd/tink-worker/internal/worker.go:145:2: `if status != pb.State_STATE_SUCCESS` is deeply nested (complexity: 20) (nestif)
	if status != pb.State_STATE_SUCCESS {
	^
cmd/tink-worker/internal/worker.go:163:10: elseif: can replace 'else {if cond {}}' with 'else if cond {}' (gocritic)
		} else {
		       ^
cmd/tink-worker/internal/worker.go:191:81: Comment should end in a period (godot)
// ProcessWorkflowActions gets all Workflow contexts and processes their actions
                                                                                ^
cmd/tink-worker/internal/worker.go:252: File is not `gofumpt`-ed (gofumpt)
					err := os.Mkdir(wfDir, os.FileMode(0755))
cmd/tink-worker/internal/worker.go:302:5: import-shadowing: The name 'status' shadows an import name (revive)
				status, err := w.execute(ctx, wfID, action, captureActionLogs)
				^
cmd/tink-worker/internal/worker.go:343:6: assigned to turn, but reassigned without using the value (wastedassign)
					turn = false
					^
cmd/tink-worker/internal/worker.go:351:6: assignOp: replace `actionIndex = actionIndex + 1` with `actionIndex++` (gocritic)
					actionIndex = actionIndex + 1
					^
cmd/tink-worker/internal/worker.go:356:16: Multiplication of durations: `w.retryInterval * time.Second` (durationcheck)
		<-time.After(w.retryInterval * time.Second)
		             ^
cmd/tink-worker/internal/worker.go:383:17: Multiplication of durations: `w.retryInterval * time.Second` (durationcheck)
			<-time.After(w.retryInterval * time.Second)
			             ^
cmd/tink-worker/internal/worker.go:392:62: import-shadowing: The name 'client' shadows an import name (revive)
func getWorkflowData(ctx context.Context, logger log.Logger, client pb.WorkflowServiceClient, workerID, workflowID string) {
                                                             ^
cmd/tink-worker/internal/worker.go:446:57: import-shadowing: The name 'client' shadows an import name (revive)
func sendUpdate(ctx context.Context, logger log.Logger, client pb.WorkflowServiceClient, st *pb.WorkflowActionStatus, data []byte, checksum string) {
                                                        ^
cmd/tink-worker/internal/worker.go:477: File is not `gofumpt`-ed (gofumpt)
	f, err := os.OpenFile(filepath.Clean(wfDir+string(os.PathSeparator)+dataFile), os.O_RDWR|os.O_CREATE, 0600)
cmd/tink-worker/main.go:16: File is not `gofumpt`-ed (gofumpt)
var (
	// version is set at build time
	version = "devel"
)
cmd/tink-worker/main.go:17:33: Comment should end in a period (godot)
	// version is set at build time
	                               ^
cmd/tink-worker/main.go:34:3: exitAfterDefer: os.Exit will exit, and `defer otelShutdown(ctx)` will not run (gocritic)
		os.Exit(1)
		^
db/db.go:20:57: Comment should end in a period (godot)
// Database interface for tinkerbell database operations
                                                        ^
db/db.go:58:86: import-shadowing: The name 'time' shadows an import name (revive)
	InsertIntoWorkflowEventTable(ctx context.Context, wfEvent *pb.WorkflowActionStatus, time time.Time) error
	                                                                                    ^
db/db.go:62:44: Comment should end in a period (godot)
// TinkDB implements the Database interface
                                           ^
db/db.go:68:53: Comment should end in a period (godot)
// Connect returns a connection to postgres database
                                                    ^
db/db.go:77:18: ST1016: methods on the same type should have the same receiver name (seen 26x "d", 2x "t") (stylecheck)
func (t *TinkDB) CheckRequiredMigrations() (int, error) {
                 ^
db/db.go:86:48: Comment should end in a period (godot)
// Error returns the underlying cause for error
                                               ^
db/db.go:98:2: variable 'err' is only used in the if-statement (db/db.go:99:2); consider using short syntax (ifshort)
	err := row.Scan(&buf)
	^
db/db.go:106:102: Comment should end in a period (godot)
// takes in a map[string]string with keys being the column name and the values being the field values
                                                                                                     ^
db/db_test.go:23:71: Comment should end in a period (godot)
// test is over. Tests using this function are safe to run in parallel
                                                                      ^
db/db_test.go:24:46: context-as-argument: context.Context should be the first parameter of a function (revive)
func NewPostgresDatabaseClient(t *testing.T, ctx context.Context, req NewPostgresDatabaseRequest) (*sql.DB, *db.TinkDB, func() error) {
                                             ^
db/hardware.go:14:50: Comment should end in a period (godot)
// DeleteFromDB : delete data from hardware table
                                                 ^
db/hardware.go:28: File is not `gofumpt`-ed (gofumpt)

db/hardware.go:44:50: Comment should end in a period (godot)
// InsertIntoDB : insert data into hardware table
                                                 ^
db/hardware.go:72:38: Comment should end in a period (godot)
// GetByMAC : get data by machine mac
                                     ^
db/hardware.go:99:36: Comment should end in a period (godot)
// GetByIP : get data by machine ip
                                   ^
db/hardware.go:143:36: Comment should end in a period (godot)
// GetByID : get data by machine id
                                   ^
db/hardware.go:158:37: Comment should end in a period (godot)
// GetAll : get data for all machine
                                    ^
db/hardware.go:166: File is not `gofumpt`-ed (gofumpt)

db/hardware.go:185: unnecessary trailing newline (whitespace)

	}
db/hardware.go:189:5: comparing with == will fail on wrapped errors. Use errors.Is to check for a specific error (errorlint)
	if err == sql.ErrNoRows {
	   ^
db/hardware_test.go:40:17: test helper function should start from t.Helper() (thelper)
			Expectation: func(t *testing.T, input []*hardware.Hardware, tinkDB *db.TinkDB) {
			             ^
db/hardware_test.go:68:17: test helper function should start from t.Helper() (thelper)
			ExpectedErr: func(t *testing.T, err error) {
			             ^
db/hardware_test.go:92:17: test helper function should start from t.Helper() (thelper)
			Expectation: func(t *testing.T, input []*hardware.Hardware, tinkDB *db.TinkDB) {
			             ^
db/hardware_test.go:119:17: test helper function should start from t.Helper() (thelper)
			Expectation: func(t *testing.T, input []*hardware.Hardware, tinkDB *db.TinkDB) {
			             ^
db/hardware_test.go:122:6: assignOp: replace `count = count + 1` with `count++` (gocritic)
					count = count + 1
					^
db/hardware_test.go:132:17: test helper function should start from t.Helper() (thelper)
			ExpectedErr: func(t *testing.T, err error) {
			             ^
db/hardware_test.go:203:3: assignOp: replace `count = count + 1` with `count++` (gocritic)
		count = count + 1
		^
db/hardware_test.go:216:17: test helper function should start from t.Helper() (thelper)
	expectation := func(t *testing.T, input *hardware.Hardware, tinkDB *db.TinkDB) {
	               ^
db/hardware_test.go:286:9: test helper function should start from t.Helper() (thelper)
					go func(t *testing.T, h *hardware.Hardware, db *db.TinkDB) {
					   ^
db/hardware_test.go:320:86: non-wrapping format verb for fmt.Errorf. Use `%w` to format errors (errorlint)
		t.Error(fmt.Errorf("unexpected output, looking for %q as a substring in %q", want, err.Error()))
		                                                                                   ^
db/hardware_test.go:326:17: test helper function should start from t.Helper() (thelper)
	expectation := func(t *testing.T, input *hardware.Hardware, tinkDB *db.TinkDB) {
	               ^
db/hardware_test.go:399:9: test helper function should start from t.Helper() (thelper)
					go func(t *testing.T, h *hardware.Hardware, db *db.TinkDB) {
					   ^
db/hardware_test.go:433:86: non-wrapping format verb for fmt.Errorf. Use `%w` to format errors (errorlint)
		t.Error(fmt.Errorf("unexpected output, looking for %q as a substring in %q", want, err.Error()))
		                                                                                   ^
db/hardware_test.go:439:17: test helper function should start from t.Helper() (thelper)
	expectation := func(t *testing.T, input *hardware.Hardware, tinkDB *db.TinkDB) {
	               ^
db/hardware_test.go:510:9: test helper function should start from t.Helper() (thelper)
					go func(t *testing.T, h *hardware.Hardware, db *db.TinkDB) {
					   ^
db/hardware_test.go:544:86: non-wrapping format verb for fmt.Errorf. Use `%w` to format errors (errorlint)
		t.Error(fmt.Errorf("unexpected output, looking for %q as a substring in %q", want, err.Error()))
		                                                                                   ^
db/hardware_test.go:554:29: unnecessary conversion (unconvert)
	err = json.Unmarshal([]byte(data), &hw)
	                           ^
db/hardware_test.go:561:42: import-shadowing: The name 'db' shadows an import name (revive)
func createHardware(ctx context.Context, db *db.TinkDB, hw *hardware.Hardware) error {
                                         ^
db/migration/migration_test.go:45: File is not `gofumpt`-ed (gofumpt)

db/migration/migration_test.go:68: File is not `gofumpt`-ed (gofumpt)

db/mock/hardware.go:7:50: Comment should end in a period (godot)
// DeleteFromDB : delete data from hardware table
                                                 ^
db/mock/hardware.go:8:26: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
func (d DB) DeleteFromDB(ctx context.Context, id string) error {
                         ^
db/mock/hardware.go:12:50: Comment should end in a period (godot)
// InsertIntoDB : insert data into hardware table
                                                 ^
db/mock/hardware.go:13:26: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
func (d DB) InsertIntoDB(ctx context.Context, data string) error {
                         ^
db/mock/hardware.go:17:38: Comment should end in a period (godot)
// GetByMAC : get data by machine mac
                                     ^
db/mock/hardware.go:18:22: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
func (d DB) GetByMAC(ctx context.Context, mac string) (string, error) {
                     ^
db/mock/hardware.go:22:36: Comment should end in a period (godot)
// GetByIP : get data by machine ip
                                   ^
db/mock/hardware.go:23:21: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
func (d DB) GetByIP(ctx context.Context, ip string) (string, error) {
                    ^
db/mock/hardware.go:27:36: Comment should end in a period (godot)
// GetByID : get data by machine id
                                   ^
db/mock/hardware.go:28:21: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
func (d DB) GetByID(ctx context.Context, id string) (string, error) {
                    ^
db/mock/hardware.go:32:37: Comment should end in a period (godot)
// GetAll : get data for all machine
                                    ^
db/mock/hardware.go:33:20: unused-parameter: parameter 'fn' seems to be unused, consider removing or renaming it as _ (revive)
func (d DB) GetAll(fn func([]byte) error) error {
                   ^
db/mock/mock.go:13:57: Comment should end in a period (godot)
// DB is the mocked implementation of Database interface
                                                        ^
db/mock/template.go:18:50: Comment should end in a period (godot)
// CreateTemplate creates a new workflow template
                                                 ^
db/mock/template.go:19:29: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
func (d *DB) CreateTemplate(ctx context.Context, name string, data string, id uuid.UUID) error {
                            ^
db/mock/template.go:32:11: ST1005: error strings should not be capitalized (stylecheck)
			return errors.New("Not a Template type in the database")
			       ^
db/mock/template.go:44:43: Comment should end in a period (godot)
// GetTemplate returns a workflow template
                                          ^
db/mock/template.go:49:46: Comment should end in a period (godot)
// DeleteTemplate deletes a workflow template
                                             ^
db/mock/template.go:50:28: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
func (d DB) DeleteTemplate(ctx context.Context, name string) error {
                           ^
db/mock/template.go:58:45: Comment should end in a period (godot)
// ListTemplates returns all saved templates
                                            ^
db/mock/template.go:59:27: unused-parameter: parameter 'in' seems to be unused, consider removing or renaming it as _ (revive)
func (d DB) ListTemplates(in string, fn func(id, n string, in, del *timestamp.Timestamp) error) error {
                          ^
db/mock/template.go:63:42: Comment should end in a period (godot)
// UpdateTemplate update a given template
                                         ^
db/mock/template.go:64:28: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
func (d DB) UpdateTemplate(ctx context.Context, name string, data string, id uuid.UUID) error {
                           ^
db/mock/template.go:68:43: Comment should end in a period (godot)
// ClearTemplateDB clear all the templates
                                          ^
db/mock/workflow.go:12:41: Comment should end in a period (godot)
// CreateWorkflow creates a new workflow
                                        ^
db/mock/workflow.go:17:72: Comment should end in a period (godot)
// InsertIntoWfDataTable : Insert ephemeral data in workflow_data table
                                                                       ^
db/mock/workflow.go:22:77: Comment should end in a period (godot)
// GetfromWfDataTable : Give you the ephemeral data from workflow_data table
                                                                            ^
db/mock/workflow.go:27:80: Comment should end in a period (godot)
// GetWorkflowMetadata returns metadata wrt to the ephemeral data of a workflow
                                                                               ^
db/mock/workflow.go:32:76: Comment should end in a period (godot)
// GetWorkflowDataVersion returns the latest version of data for a workflow
                                                                           ^
db/mock/workflow.go:37:81: Comment should end in a period (godot)
// GetWorkflowsForWorker : returns the list of workflows for a particular worker
                                                                                ^
db/mock/workflow.go:42:34: Comment should end in a period (godot)
// GetWorkflow returns a workflow
                                 ^
db/mock/workflow.go:47:37: Comment should end in a period (godot)
// DeleteWorkflow deletes a workflow
                                    ^
db/mock/workflow.go:48:28: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
func (d DB) DeleteWorkflow(ctx context.Context, id string, state int32) error {
                           ^
db/mock/workflow.go:52:39: Comment should end in a period (godot)
// ListWorkflows returns all workflows
                                      ^
db/mock/workflow.go:53:27: unused-parameter: parameter 'fn' seems to be unused, consider removing or renaming it as _ (revive)
func (d DB) ListWorkflows(fn func(wf db.Workflow) error) error {
                          ^
db/mock/workflow.go:57:43: Comment should end in a period (godot)
// UpdateWorkflow updates a given workflow
                                          ^
db/mock/workflow.go:58:28: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
func (d DB) UpdateWorkflow(ctx context.Context, wf db.Workflow, state int32) error {
                           ^
db/mock/workflow.go:62:59: Comment should end in a period (godot)
// UpdateWorkflowState : update the current workflow state
                                                          ^
db/mock/workflow.go:67:64: Comment should end in a period (godot)
// GetWorkflowContexts : gives you the current workflow context
                                                               ^
db/mock/workflow.go:72:62: Comment should end in a period (godot)
// GetWorkflowActions : gives you the action list of workflow
                                                             ^
db/mock/workflow.go:77:62: Comment should end in a period (godot)
// InsertIntoWorkflowEventTable : insert workflow event table
                                                             ^
db/mock/workflow.go:78:97: import-shadowing: The name 'time' shadows an import name (revive)
func (d DB) InsertIntoWorkflowEventTable(ctx context.Context, wfEvent *pb.WorkflowActionStatus, time time.Time) error {
                                                                                                ^
db/mock/workflow.go:82:44: Comment should end in a period (godot)
// ShowWorkflowEvents returns all workflows
                                           ^
db/mock/workflow.go:83:32: unused-parameter: parameter 'wfID' seems to be unused, consider removing or renaming it as _ (revive)
func (d DB) ShowWorkflowEvents(wfID string, fn func(wfs *pb.WorkflowActionStatus) error) error {
                               ^
db/template.go:19:50: Comment should end in a period (godot)
// CreateTemplate creates a new workflow template
                                                 ^
db/template.go:51:53: Comment should end in a period (godot)
// GetTemplate returns template which is not deleted
                                                    ^
db/template.go:96:5: comparing with != will fail on wrapped errors. Use errors.Is to check for a specific error (errorlint)
	if err != sql.ErrNoRows {
	   ^
db/template.go:103:52: Comment should end in a period (godot)
// DeleteTemplate deletes a workflow template by id
                                                   ^
db/template.go:132:45: Comment should end in a period (godot)
// ListTemplates returns all saved templates
                                            ^
db/template.go:142: File is not `gofumpt`-ed (gofumpt)

db/template.go:172:5: comparing with == will fail on wrapped errors. Use errors.Is to check for a specific error (errorlint)
	if err == sql.ErrNoRows {
	   ^
db/template.go:178:42: Comment should end in a period (godot)
// UpdateTemplate update a given template
                                         ^
db/template.go:185:2: ifElseChain: rewrite if-else to switch statement (gocritic)
	if data == "" && name != "" {
	^
db/template_test.go:47:17: test helper function should start from t.Helper() (thelper)
			Expectation: func(t *testing.T, input []*workflow.Workflow, tinkDB *db.TinkDB) {
			             ^
db/template_test.go:74:17: test helper function should start from t.Helper() (thelper)
			ExpectedErr: func(t *testing.T, err error) {
			             ^
db/template_test.go:98:17: test helper function should start from t.Helper() (thelper)
			Expectation: func(t *testing.T, input []*workflow.Workflow, tinkDB *db.TinkDB) {
			             ^
db/template_test.go:122:17: test helper function should start from t.Helper() (thelper)
			ExpectedErr: func(t *testing.T, err error) {
			             ^
db/template_test.go:127:17: test helper function should start from t.Helper() (thelper)
			Expectation: func(t *testing.T, input []*workflow.Workflow, tinkDB *db.TinkDB) {
			             ^
db/template_test.go:130:6: assignOp: replace `count = count + 1` with `count++` (gocritic)
					count = count + 1
					^
db/template_test.go:240:3: assignOp: replace `count = count + 1` with `count++` (gocritic)
		count = count + 1
		^
db/template_test.go:253:17: test helper function should start from t.Helper() (thelper)
	expectation := func(t *testing.T, input *workflow.Workflow, tinkDB *db.TinkDB) {
	               ^
db/template_test.go:328:9: test helper function should start from t.Helper() (thelper)
					go func(t *testing.T, wf *workflow.Workflow, db *db.TinkDB) {
					   ^
db/template_test.go:363:86: non-wrapping format verb for fmt.Errorf. Use `%w` to format errors (errorlint)
		t.Error(fmt.Errorf("unexpected output, looking for %q as a substring in %q", want, err.Error()))
		                                                                                   ^
db/workflow.go:24:55: Comment should end in a period (godot)
// Workflow represents a workflow instance in database
                                                      ^
db/workflow.go:36:41: Comment should end in a period (godot)
// CreateWorkflow creates a new workflow
                                        ^
db/workflow.go:46: File is not `gofumpt`-ed (gofumpt)

db/workflow.go:51: File is not `gofumpt`-ed (gofumpt)

db/workflow.go:60:23: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
func insertInWorkflow(ctx context.Context, db *sql.DB, wf Workflow, tx *sql.Tx) error {
                      ^
db/workflow.go:77:30: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
func insertIntoWfWorkerTable(ctx context.Context, db *sql.DB, wfID uuid.UUID, workerID uuid.UUID, tx *sql.Tx) error {
                             ^
db/workflow.go:92:46: Comment should end in a period (godot)
// Insert actions in the workflow_state table
                                             ^
db/workflow.go:194:72: Comment should end in a period (godot)
// InsertIntoWfDataTable : Insert ephemeral data in workflow_data table
                                                                       ^
db/workflow.go:201:2: commentFormatting: put a space between `//` and comment text (gocritic)
	//increment version
	^
db/workflow.go:202:2: assignOp: replace `version = version + 1` with `version++` (gocritic)
	version = version + 1
	^
db/workflow.go:239:77: Comment should end in a period (godot)
// GetfromWfDataTable : Give you the ephemeral data from workflow_data table
                                                                            ^
db/workflow.go:259:16: unnecessary conversion (unconvert)
		return []byte(buf), nil
		             ^
db/workflow.go:270:80: Comment should end in a period (godot)
// GetWorkflowMetadata returns metadata wrt to the ephemeral data of a workflow
                                                                               ^
db/workflow.go:290:16: unnecessary conversion (unconvert)
		return []byte(buf), nil
		             ^
db/workflow.go:301:76: Comment should end in a period (godot)
// GetWorkflowDataVersion returns the latest version of data for a workflow
                                                                           ^
db/workflow.go:306:81: Comment should end in a period (godot)
// GetWorkflowsForWorker : returns the list of workflows for a particular worker
                                                                                ^
db/workflow.go:331:5: comparing with == will fail on wrapped errors. Use errors.Is to check for a specific error (errorlint)
	if err == sql.ErrNoRows {
	   ^
db/workflow.go:337:34: Comment should end in a period (godot)
// GetWorkflow returns a workflow
                                 ^
db/workflow.go:373:37: Comment should end in a period (godot)
// DeleteWorkflow deletes a workflow
                                    ^
db/workflow.go:374:64: unused-parameter: parameter 'state' seems to be unused, consider removing or renaming it as _ (revive)
func (d TinkDB) DeleteWorkflow(ctx context.Context, id string, state int32) error {
                                                               ^
db/workflow.go:420:39: Comment should end in a period (godot)
// ListWorkflows returns all workflows
                                      ^
db/workflow.go:428: File is not `gofumpt`-ed (gofumpt)

db/workflow.go:460:5: comparing with == will fail on wrapped errors. Use errors.Is to check for a specific error (errorlint)
	if err == sql.ErrNoRows {
	   ^
db/workflow.go:466:43: Comment should end in a period (godot)
// UpdateWorkflow updates a given workflow
                                          ^
db/workflow.go:467:66: unused-parameter: parameter 'state' seems to be unused, consider removing or renaming it as _ (revive)
func (d TinkDB) UpdateWorkflow(ctx context.Context, wf Workflow, state int32) error {
                                                                 ^
db/workflow.go:473:2: ifElseChain: rewrite if-else to switch statement (gocritic)
	if wf.Hardware == "" && wf.Template != "" {
	^
db/workflow.go:510:59: Comment should end in a period (godot)
// UpdateWorkflowState : update the current workflow state
                                                          ^
db/workflow.go:537:64: Comment should end in a period (godot)
// GetWorkflowContexts : gives you the current workflow context
                                                               ^
db/workflow.go:558: File is not `gofumpt`-ed (gofumpt)
			TotalNumberOfActions: tact}, nil
db/workflow.go:568:62: Comment should end in a period (godot)
// GetWorkflowActions : gives you the action list of workflow
                                                             ^
db/workflow.go:585: File is not `gofumpt`-ed (gofumpt)
			ActionList: actions}, nil
db/workflow.go:594:62: Comment should end in a period (godot)
// InsertIntoWorkflowEventTable : insert workflow event table
                                                             ^
db/workflow.go:595:101: import-shadowing: The name 'time' shadows an import name (revive)
func (d TinkDB) InsertIntoWorkflowEventTable(ctx context.Context, wfEvent *pb.WorkflowActionStatus, time time.Time) error {
                                                                                                    ^
db/workflow.go:618:44: Comment should end in a period (godot)
// ShowWorkflowEvents returns all workflows
                                           ^
db/workflow.go:628: File is not `gofumpt`-ed (gofumpt)

db/workflow.go:635:3: import-shadowing: The name 'status' shadows an import name (revive)
		status                int32
		^
db/workflow.go:664:5: comparing with == will fail on wrapped errors. Use errors.Is to check for a specific error (errorlint)
	if err == sql.ErrNoRows {
	   ^
db/workflow.go:679:2: variable 'err' is only used in the if-statement (db/workflow.go:680:2); consider using short syntax (ifshort)
	err := row.Scan(&version)
	^
db/workflow.go:710:5: comparing with == will fail on wrapped errors. Use errors.Is to check for a specific error (errorlint)
	if errors.Cause(err) == sql.ErrNoRows {
	   ^
db/workflow.go:758:5: comparing with == will fail on wrapped errors. Use errors.Is to check for a specific error (errorlint)
	if errors.Cause(err) == sql.ErrNoRows {
	   ^
db/workflow.go:773: unnecessary trailing newline (whitespace)

	}
db/workflow_test.go:55:17: test helper function should start from t.Helper() (thelper)
			Expectation: func(t *testing.T, in *input, tinkDB *db.TinkDB) {
			             ^
db/workflow_test.go:58:6: assignOp: replace `count = count + 1` with `count++` (gocritic)
					count = count + 1
					^
db/workflow_test.go:82:17: test helper function should start from t.Helper() (thelper)
			Expectation: func(t *testing.T, in *input, tinkDB *db.TinkDB) {
			             ^
db/workflow_test.go:85:6: assignOp: replace `count = count + 1` with `count++` (gocritic)
					count = count + 1
					^
db/workflow_test.go:109:17: test helper function should start from t.Helper() (thelper)
			Expectation: func(t *testing.T, in *input, tinkDB *db.TinkDB) {
			             ^
db/workflow_test.go:112:6: assignOp: replace `count = count + 1` with `count++` (gocritic)
					count = count + 1
					^
db/workflow_test.go:137:17: test helper function should start from t.Helper() (thelper)
			Expectation: func(t *testing.T, in *input, tinkDB *db.TinkDB) {
			             ^
db/workflow_test.go:140:6: assignOp: replace `count = count + 1` with `count++` (gocritic)
					count = count + 1
					^
db/workflow_test.go:245:3: assignOp: replace `count = count + 1` with `count++` (gocritic)
		count = count + 1
		^
db/workflow_test.go:282:17: test helper function should start from t.Helper() (thelper)
			Expectation: func(t *testing.T, tinkDB *db.TinkDB, id string) {
			             ^
db/workflow_test.go:301:17: test helper function should start from t.Helper() (thelper)
			Expectation: func(t *testing.T, tinkDB *db.TinkDB, id string) {
			             ^
db/workflow_test.go:323:17: test helper function should start from t.Helper() (thelper)
			Expectation: func(t *testing.T, tinkDB *db.TinkDB, id string) {
			             ^
db/workflow_test.go:372:9: test helper function should start from t.Helper() (thelper)
					go func(t *testing.T, tinkDB *db.TinkDB, wfID string) {
					   ^
grpc-server/grpc_server.go:29:44: Comment should end in a period (godot)
// Server is the gRPC server for tinkerbell
                                           ^
grpc-server/grpc_server.go:53:44: Comment should end in a period (godot)
// SetupGRPC setup and return a gRPC server
                                           ^
grpc-server/hardware.go:143:33: Comment should end in a period (godot)
// ByID implements hardware.ByID
                                ^
grpc-server/hardware.go:150:31: Comment should end in a period (godot)
// ALL implements hardware.All
                              ^
grpc-server/hardware.go:244:62: Comment should end in a period (godot)
// Cert returns the public cert that can be served to clients
                                                             ^
grpc-server/hardware.go:249:54: Comment should end in a period (godot)
// ModTime returns the modified-time of the grpc cert
                                                     ^
grpc-server/template.go:16:53: Comment should end in a period (godot)
// CreateTemplate implements template.CreateTemplate
                                                    ^
grpc-server/template.go:46:47: Comment should end in a period (godot)
// GetTemplate implements template.GetTemplate
                                              ^
grpc-server/template.go:78:53: Comment should end in a period (godot)
// DeleteTemplate implements template.DeleteTemplate
                                                    ^
grpc-server/template.go:106:51: Comment should end in a period (godot)
// ListTemplates implements template.ListTemplates
                                                  ^
grpc-server/template.go:132: File is not `gofumpt`-ed (gofumpt)

grpc-server/template.go:142:53: Comment should end in a period (godot)
// UpdateTemplate implements template.UpdateTemplate
                                                    ^
grpc-server/template_test.go:54:6: TestCreateTemplate should use t.Cleanup instead of defer (tparallel)
func TestCreateTemplate(t *testing.T) {
     ^
grpc-server/template_test.go:156:6: TestGetTemplate should use t.Cleanup instead of defer (tparallel)
func TestGetTemplate(t *testing.T) {
     ^
grpc-server/tinkerbell.go:20:2: var-naming: const errInvalidWorkflowId should be errInvalidWorkflowID (revive)
	errInvalidWorkflowId     = "invalid workflow id"
	^
grpc-server/tinkerbell.go:31:65: Comment should end in a period (godot)
// GetWorkflowContexts implements tinkerbell.GetWorkflowContexts
                                                                ^
grpc-server/tinkerbell.go:51:71: Comment should end in a period (godot)
// GetWorkflowContextList implements tinkerbell.GetWorkflowContextList
                                                                      ^
grpc-server/tinkerbell.go:52:41: import-shadowing: The name 'context' shadows an import name (revive)
func (s *server) GetWorkflowContextList(context context.Context, req *pb.WorkflowContextRequest) (*pb.WorkflowContextList, error) {
                                        ^
grpc-server/tinkerbell.go:74:63: Comment should end in a period (godot)
// GetWorkflowActions implements tinkerbell.GetWorkflowActions
                                                              ^
grpc-server/tinkerbell.go:75:37: import-shadowing: The name 'context' shadows an import name (revive)
func (s *server) GetWorkflowActions(context context.Context, req *pb.WorkflowActionsRequest) (*pb.WorkflowActionList, error) {
                                    ^
grpc-server/tinkerbell.go:83:63: Comment should end in a period (godot)
// ReportActionStatus implements tinkerbell.ReportActionStatus
                                                              ^
grpc-server/tinkerbell.go:84:37: import-shadowing: The name 'context' shadows an import name (revive)
func (s *server) ReportActionStatus(context context.Context, req *pb.WorkflowActionStatus) (*pb.Empty, error) {
                                    ^
grpc-server/tinkerbell.go:111:4: assignOp: replace `actionIndex = actionIndex + 1` with `actionIndex++` (gocritic)
			actionIndex = actionIndex + 1
			^
grpc-server/tinkerbell.go:132:2: import-shadowing: The name 'time' shadows an import name (revive)
	time := time.Now()
	^
grpc-server/tinkerbell.go:151:54: Comment should end in a period (godot)
// UpdateWorkflowData updates workflow ephemeral data
                                                     ^
grpc-server/tinkerbell.go:152:37: import-shadowing: The name 'context' shadows an import name (revive)
func (s *server) UpdateWorkflowData(context context.Context, req *pb.UpdateWorkflowDataRequest) (*pb.Empty, error) {
                                    ^
grpc-server/tinkerbell.go:168:58: Comment should end in a period (godot)
// GetWorkflowData gets the ephemeral data for a workflow
                                                         ^
grpc-server/tinkerbell.go:169:34: import-shadowing: The name 'context' shadows an import name (revive)
func (s *server) GetWorkflowData(context context.Context, req *pb.GetWorkflowDataRequest) (*pb.GetWorkflowDataResponse, error) {
                                 ^
grpc-server/tinkerbell.go:170:2: variable 'wfID' is only used in the if-statement (grpc-server/tinkerbell.go:171:2); consider using short syntax (ifshort)
	wfID := req.GetWorkflowId()
	^
grpc-server/tinkerbell.go:181:80: Comment should end in a period (godot)
// GetWorkflowMetadata returns metadata wrt to the ephemeral data of a workflow
                                                                               ^
grpc-server/tinkerbell.go:182:38: import-shadowing: The name 'context' shadows an import name (revive)
func (s *server) GetWorkflowMetadata(context context.Context, req *pb.GetWorkflowDataRequest) (*pb.GetWorkflowDataResponse, error) {
                                     ^
grpc-server/tinkerbell.go:190:76: Comment should end in a period (godot)
// GetWorkflowDataVersion returns the latest version of data for a workflow
                                                                           ^
grpc-server/tinkerbell.go:191:41: import-shadowing: The name 'context' shadows an import name (revive)
func (s *server) GetWorkflowDataVersion(context context.Context, req *pb.GetWorkflowDataRequest) (*pb.GetWorkflowDataResponse, error) {
                                        ^
grpc-server/tinkerbell.go:199:28: import-shadowing: The name 'db' shadows an import name (revive)
func getWorkflowsForWorker(db db.Database, id string) ([]string, error) {
                           ^
grpc-server/tinkerbell.go:210:25: import-shadowing: The name 'context' shadows an import name (revive)
func getWorkflowActions(context context.Context, db db.Database, wfID string) (*pb.WorkflowActionList, error) {
                        ^
grpc-server/tinkerbell.go:219:90: Comment should end in a period (godot)
// be sent to a worker based on the state of the current action and the targeted workerID
                                                                                         ^
grpc-server/tinkerbell.go:220:25: import-shadowing: The name 'context' shadows an import name (revive)
func isApplicableToSend(context context.Context, logger log.Logger, wfContext *pb.WorkflowContext, workerID string, db db.Database) bool {
                        ^
grpc-server/tinkerbell.go:242: unnecessary trailing newline (whitespace)

	}
grpc-server/tinkerbell_test.go:31:31: import-shadowing: The name 'db' shadows an import name (revive)
func testServer(t *testing.T, db db.Database) *server {
                              ^
grpc-server/tinkerbell_test.go:874:20: unnecessary conversion (unconvert)
						return []byte(meta), nil
						             ^
grpc-server/workflow.go:18:53: Comment should end in a period (godot)
// CreateWorkflow implements workflow.CreateWorkflow
                                                    ^
grpc-server/workflow.go:45: File is not `gofumpt`-ed (gofumpt)

grpc-server/workflow.go:74:47: Comment should end in a period (godot)
// GetWorkflow implements workflow.GetWorkflow
                                              ^
grpc-server/workflow.go:125:53: Comment should end in a period (godot)
// DeleteWorkflow implements workflow.DeleteWorkflow
                                                    ^
grpc-server/workflow.go:154:51: Comment should end in a period (godot)
// ListWorkflows implements workflow.ListWorkflows
                                                  ^
grpc-server/workflow.go:183: File is not `gofumpt`-ed (gofumpt)

grpc-server/workflow.go:223:39: unnecessary conversion (unconvert)
		CurrentActionState:   workflow.State(w.CurrentActionState),
		                                    ^
grpc-server/workflow.go:239:60: Comment should end in a period (godot)
// ShowWorflowevents  implements workflow.ShowWorflowEvents
                                                           ^
grpc-server/workflow.go:262:32: unnecessary conversion (unconvert)
			ActionStatus: workflow.State(w.ActionStatus),
			                            ^
grpc-server/workflow.go:269: File is not `gofumpt`-ed (gofumpt)

grpc-server/workflow.go:284:23: import-shadowing: The name 'db' shadows an import name (revive)
func getWorkflowState(db db.Database, ctx context.Context, id string) workflow.State {
                      ^
grpc-server/workflow.go:288:9: indent-error-flow: if block ends with a return statement, so drop this else and outdent its block (revive)
	} else {
		if wfCtx.GetCurrentActionIndex() == wfCtx.GetTotalNumberOfActions()-1 {
			return workflow.State_STATE_SUCCESS
		} else {
			return workflow.State_STATE_RUNNING
		}
	}
grpc-server/workflow.go:291:10: indent-error-flow: if block ends with a return statement, so drop this else and outdent its block (revive)
		} else {
			return workflow.State_STATE_RUNNING
		}
grpc-server/workflow_test.go:151: File is not `gofumpt`-ed (gofumpt)
							Hardware: hw}, nil
grpc-server/workflow_test.go:196: File is not `gofumpt`-ed (gofumpt)
							Hardware: hw}, nil
http-server/http_handlers.go:24:28: Comment should end in a period (godot)
// given endpoint over GRPC
                           ^
http-server/http_handlers.go:56:69: comparing with != will fail on wrapped errors. Use errors.Is to check for a specific error (errorlint)
		if err := json.NewDecoder(newReader()).Decode(&hw); err != nil && err != io.EOF {
		                                                                  ^
http-server/http_handlers.go:84:69: comparing with != will fail on wrapped errors. Use errors.Is to check for a specific error (errorlint)
		if err := json.NewDecoder(newReader()).Decode(&gr); err != nil && err != io.EOF {
		                                                                  ^
http-server/http_handlers.go:112:69: comparing with != will fail on wrapped errors. Use errors.Is to check for a specific error (errorlint)
		if err := json.NewDecoder(newReader()).Decode(&gr); err != nil && err != io.EOF {
		                                                                  ^
http-server/http_handlers.go:173:3: assigned to err, but reassigned without using the value (wastedassign)
		err = nil
		^
http-server/http_handlers.go:182:20: comparing with != will fail on wrapped errors. Use errors.Is to check for a specific error (errorlint)
		if err != nil && err != io.EOF {
		                 ^
http-server/http_handlers.go:217:22: Comment should end in a period (godot)
// endpoint over GRPC
                     ^
http-server/http_handlers.go:249:71: comparing with != will fail on wrapped errors. Use errors.Is to check for a specific error (errorlint)
		if err := json.NewDecoder(newReader()).Decode(&tmpl); err != nil && err != io.EOF {
		                                                                    ^
http-server/http_handlers.go:367:3: assigned to err, but reassigned without using the value (wastedassign)
		err = nil
		^
http-server/http_handlers.go:378:20: comparing with != will fail on wrapped errors. Use errors.Is to check for a specific error (errorlint)
		if err != nil && err != io.EOF {
		                 ^
http-server/http_handlers.go:387:22: Comment should end in a period (godot)
// endpoint over GRPC
                     ^
http-server/http_handlers.go:419:69: comparing with != will fail on wrapped errors. Use errors.Is to check for a specific error (errorlint)
		if err := json.NewDecoder(newReader()).Decode(&cr); err != nil && err != io.EOF {
		                                                                  ^
http-server/http_handlers.go:491:3: assigned to err, but reassigned without using the value (wastedassign)
		err = nil
		^
http-server/http_handlers.go:502:20: comparing with != will fail on wrapped errors. Use errors.Is to check for a specific error (errorlint)
		if err != nil && err != io.EOF {
		                 ^
http-server/http_handlers.go:564:3: assigned to err, but reassigned without using the value (wastedassign)
		err = nil
		^
http-server/http_handlers.go:574:20: comparing with != will fail on wrapped errors. Use errors.Is to check for a specific error (errorlint)
		if err != nil && err != io.EOF {
		                 ^
http-server/http_handlers.go:591:46: Comment should end in a period (godot)
// writeResponse appends a new line after res
                                             ^
http-server/http_handlers.go:592:43: import-shadowing: The name 'status' shadows an import name (revive)
func writeResponse(w http.ResponseWriter, status int, res string) {
                                          ^
http-server/http_handlers_test.go:34:23: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
func (s *server) Push(ctx context.Context, in *hardware.PushRequest) (*hardware.Empty, error) {
                      ^
http-server/http_handlers_test.go:64: unnecessary leading newline (whitespace)
func TestHardwarePushHandler(t *testing.T) {

http-server/http_handlers_test.go:65: File is not `gofumpt`-ed (gofumpt)

http-server/http_server.go:29:6: exported: type name will be used as httpserver.HTTPServerConfig by other packages, and that stutters; consider calling this Config (revive)
type HTTPServerConfig struct {
     ^
http-server/http_server.go:38:45: Comment should end in a period (godot)
// SetupHTTP setup and return an HTTP server
                                            ^
http-server/http_server.go:90:6: comparing with == will fail on wrapped errors. Use errors.Is to check for a specific error (errorlint)
		if err == http.ErrServerClosed {
		   ^
http-server/http_server.go:103:44: unused-parameter: parameter 'r' seems to be unused, consider removing or renaming it as _ (revive)
func versionHandler(w http.ResponseWriter, r *http.Request) {
                                           ^
http-server/http_server.go:108:48: unused-parameter: parameter 'r' seems to be unused, consider removing or renaming it as _ (revive)
func healthCheckHandler(w http.ResponseWriter, r *http.Request) {
                                               ^
http-server/http_server.go:146:73: Comment should end in a period (godot)
// skips authentication if both authUsername and authPassword aren't set
                                                                        ^
metrics/metrics.go:9:22: Comment should end in a period (godot)
// Prometheus Metrics
                     ^
metrics/metrics.go:25:46: Comment should end in a period (godot)
// SetupMetrics sets the defaults for metrics
                                             ^
pkg/hardware_wrapper.go:34:20: Comment should end in a period (godot)
// 5. Marshal map A
                   ^
pkg/hardware_wrapper.go:70:62: Comment should end in a period (godot)
// 5. Marshal map to then be unmarshaled into Hardware object
                                                             ^
workflow/template_validator.go:27:58: Comment should end in a period (godot)
// Parse parses the template yaml content into a Workflow
                                                         ^
workflow/template_validator.go:44:65: Comment should end in a period (godot)
// function triggers a panic. Common utility for testing purpose
                                                                ^
workflow/template_validator.go:63:75: Comment should end in a period (godot)
// RenderTemplate renders the workflow template wrt given hardware details
                                                                          ^
workflow/template_validator.go:73:25: unnecessary conversion (unconvert)
	_, err = t.Parse(string(templateData))
	                       ^
workflow/template_validator.go:95:71: Comment should end in a period (godot)
// validate validates a workflow template against certain requirements
                                                                      ^
workflow/template_validator_test.go:52:13: test helper function should start from t.Helper() (thelper)
			Recover: func(t *testing.T) {
			         ^
workflow/template_validator_test.go:53:13: defer: recover must be called inside a deferred function (revive)
				if r := recover(); r != nil {
				        ^
workflow/template_validator_test.go:61:13: test helper function should start from t.Helper() (thelper)
			Recover: func(t *testing.T) {
			         ^
workflow/template_validator_test.go:62:13: defer: recover must be called inside a deferred function (revive)
				if r := recover(); r == nil {
				        ^
workflow/template_validator_test.go:85:13: test helper function should start from t.Helper() (thelper)
			Recover: func(t *testing.T) {
			         ^
workflow/template_validator_test.go:86:13: defer: recover must be called inside a deferred function (revive)
				if r := recover(); r != nil {
				        ^
workflow/template_validator_test.go:94:13: test helper function should start from t.Helper() (thelper)
			Recover: func(t *testing.T) {
			         ^
workflow/template_validator_test.go:95:13: defer: recover must be called inside a deferred function (revive)
				if r := recover(); r == nil {
				        ^
workflow/template_validator_test.go:139:28: unnecessary conversion (unconvert)
			res, err := Parse([]byte(test.content))
			                        ^
workflow/template_validator_test.go:265:19: test helper function should start from t.Helper() (thelper)
			expectedError: func(t *testing.T, err error) {
			               ^
workflow/types.go:3:49: Comment should end in a period (godot)
// Workflow represents a workflow to be executed
                                                ^
workflow/types.go:12:63: Comment should end in a period (godot)
// Task represents a task to be executed as part of a workflow
                                                              ^
workflow/types.go:21:55: Comment should end in a period (godot)
// Action is the basic executional unit for a workflow

Why is this needed

Fixes #512

How Has This Been Tested?

make test

Signed-off-by: Thomas Stromberg <t+github@stromberg.org>
Signed-off-by: Thomas Stromberg <t+github@stromberg.org>
Signed-off-by: Thomas Stromberg <t+github@stromberg.org>
Signed-off-by: Thomas Stromberg <t+github@stromberg.org>
Signed-off-by: Thomas Stromberg <t+github@stromberg.org>
@tstromberg tstromberg changed the title Add Introduce more stringent golangci-lint checks & address issues raised Sep 3, 2021
@codecov
Copy link

codecov bot commented Sep 3, 2021

Codecov Report

Merging #538 (ac890f6) into main (7ef02f8) will increase coverage by 0.39%.
The diff coverage is 27.45%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #538      +/-   ##
==========================================
+ Coverage   34.36%   34.76%   +0.39%     
==========================================
  Files          44       44              
  Lines        3384     3348      -36     
==========================================
+ Hits         1163     1164       +1     
+ Misses       2122     2085      -37     
  Partials       99       99              
Impacted Files Coverage Δ
cmd/tink-cli/cmd/delete/delete.go 67.44% <0.00%> (+1.53%) ⬆️
cmd/tink-cli/cmd/docs.go 95.83% <ø> (ø)
cmd/tink-cli/cmd/get/get.go 70.00% <0.00%> (ø)
cmd/tink-cli/cmd/hardware/commands.go 0.00% <0.00%> (ø)
cmd/tink-cli/cmd/hardware/delete.go 0.00% <0.00%> (ø)
cmd/tink-cli/cmd/hardware/id.go 0.00% <0.00%> (ø)
cmd/tink-cli/cmd/hardware/ip.go 0.00% <0.00%> (ø)
cmd/tink-cli/cmd/hardware/list.go 0.00% <0.00%> (ø)
cmd/tink-cli/cmd/hardware/mac.go 0.00% <0.00%> (ø)
cmd/tink-cli/cmd/hardware/push.go 0.00% <0.00%> (ø)
... and 22 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7ef02f8...ac890f6. Read the comment docs.

@tstromberg
Copy link
Contributor Author

FWIW, I can't make heads or tails about the CI check failure:

 + failed=0
+ git ls-files '*.sh' '*.go' '*.md'
+ xargs codespell -q 3 -I .codespell-whitelist
+ git ls-files '*.yml' '*.json' '*.md'
+ xargs prettier --check
Checking formatting...
[warn] .golangci.yml
[warn] Code style issues found in the above file(s). Forgot to run Prettier?
+ failed=1
+ xargs shfmt -l -d
+ git ls-files '*.sh'
+ git ls-files '*.sh'
+ xargs shellcheck
+ nixfmt shell.nix
+ git diff
+ grep .
+ exit 1

When I run git ls-files '*.yml' '*.json' '*.md' | xargs prettier --check, locally, it reports "All matched files use Prettier code style!

@Raj-Dharwadkar
Copy link

@tstromberg . I see this PR has conflicts. Please can you update PR?

Signed-off-by: Thomas Stromberg <t+github@stromberg.org>
…ge more easily

Signed-off-by: Thomas Stromberg <t+github@stromberg.org>
Signed-off-by: Thomas Stromberg <t+github@stromberg.org>
Signed-off-by: Thomas Stromberg <t+github@stromberg.org>
Signed-off-by: Thomas Stromberg <t+github@stromberg.org>
@tstromberg
Copy link
Contributor Author

It appears that prettier did want two empty lines before the comments. I think prettier is a bad way to check YAML files, but let's just leave it where it's at for now. I'll swap it out for yamllint in a future PR.

This PR is now ready for review.

Copy link
Member

@jacobweinstock jacobweinstock left a comment

Choose a reason for hiding this comment

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

/lgtm

jacobweinstock
jacobweinstock previously approved these changes Sep 29, 2021
displague
displague previously approved these changes Sep 30, 2021
Copy link
Member

@displague displague left a comment

Choose a reason for hiding this comment

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

I left some questions and nitpics but all in all this looks great.

One more non-blocking question - are the changes to the generated files (mocks and protobufs) going to cause more PR noise on subsequent PRs or will our make commands ensure that the generated files are formatted properly?

db/workflow.go Outdated Show resolved Hide resolved
cmd/tink-server/main.go Show resolved Hide resolved
cmd/tink-cli/cmd/completion.go Show resolved Hide resolved
@displague displague added the kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. label Sep 30, 2021
Signed-off-by: Thomas Stromberg <t+github@stromberg.org>
@tstromberg
Copy link
Contributor Author

I left some questions and nitpics but all in all this looks great.

One more non-blocking question - are the changes to the generated files (mocks and protobufs) going to cause more PR noise on subsequent PRs or will our make commands ensure that the generated files are formatted properly?

That's a great question: the short answer is that regenerating the protobuf related files may cause the gofumpt check to fail. make fix will fix it, if so. I've opened up tinkerbell/lint-install#23 to address this possible source of noise.

Signed-off-by: Thomas Stromberg <t+github@stromberg.org>
@tstromberg tstromberg merged commit 5923ca9 into tinkerbell:main Oct 4, 2021
@displague displague added this to the 0.7.0 milestone Aug 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve Go Report Card compatibility
4 participants