Skip to content

chore: fix string formatting and ST1005 linter warning in file permission errors #535

Description

@ish-g09

Describe the bug

In pkg/config/file_permission_unix.go and pkg/config/file_permission_windows.go, the error returned by getFilePermission() is split across two concatenated string literals:

return fmt.Errorf("config file has incorrect permission flags:%s."+
	"change the file permission either to 0400 or 0600.", fi.Mode().Perm().S

Two small issues with this:

  1. Missing spaces in the string: there is no space after the colon (flags:%s), and no space between the period and "change" (.change), causing words to run together in terminal output.
  2. Trailing punctuation: ending the error message with a period triggers a staticcheck warning (ST1005: error strings should not end with punctuation or newlines).

Expected behavior

The error message should have clean spacing and omit trailing punctuation to follow Go conventions:

config file has incorrect permission flags: %s, change the file permission either to 0400 or 0600

Actual behavior

When an invalid file mode is encountered, the output text runs together:

config file has incorrect permission flags:-rw-r--r--.change the file permission either to 0400 or 0600.

And staticcheck reports:

pkg/config/file_permission_unix.go:30:9: error strings should not end with punctuation or newlines (ST1005)

How to Reproduce?

  1. Inspect pkg/config/file_permission_unix.go:30 or pkg/config/file_permission_windows.go:30.
  2. Run staticcheck ./... locally.
  3. Observe the ST1005 warning.

Microcks version or git rev

main (Latest)

Install method (docker-compose, helm chart, operator, docker-desktop extension,...)

CLI

Additional information

Minor cleanup to fix terminal output formatting and ensure clean staticcheck runs.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions