-
Notifications
You must be signed in to change notification settings - Fork 21
[chore] : Bump golangci/golangci-lint-action from 3.6.0 to 8.0.0 #133
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -101,7 +101,7 @@ for any unknown values. If you are running this command in CI, please use the | |
| // Render it out! | ||
| f, err := os.Create(".copywrite.hcl") | ||
| cobra.CheckErr(err) | ||
| defer f.Close() | ||
| defer func() { cobra.CheckErr(f.Close()) }() | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixes: |
||
|
|
||
| err = configToHCL(*newConfig, f) | ||
| cobra.CheckErr(err) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -45,7 +45,7 @@ var licenseCmd = &cobra.Command{ | |
|
|
||
| // Input Validation | ||
| if conf.Project.CopyrightYear == 0 { | ||
| errYearNotFound := errors.New("Unable to automatically determine copyright year. Please specify it manually in the config or via the --year flag") | ||
| errYearNotFound := errors.New("unable to automatically determine copyright year: Please specify it manually in the config or via the --year flag") | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixes: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixes: |
||
|
|
||
| cliLogger.Info("Copyright year was not supplied via config or via the --year flag. Attempting to infer from the year the GitHub repo was created.") | ||
| repo, err := github.DiscoverRepo() | ||
|
|
@@ -78,7 +78,7 @@ var licenseCmd = &cobra.Command{ | |
| var file string | ||
|
|
||
| if len(licenseFiles) > 1 { | ||
| err = fmt.Errorf("More than one license file exists. Please review the following files and manually ensure only one is present: %s", licenseFiles) | ||
| err = fmt.Errorf("more than one license file exists: Please review the following files and manually ensure only one is present: %s", licenseFiles) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixes: |
||
| cliLogger.Error(err.Error()) | ||
| cobra.CheckErr(err) | ||
| return | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -202,25 +202,25 @@ func (c *Config) LoadCommandFlags(flagSet *pflag.FlagSet, mapping map[string]str | |
| func (c *Config) LoadConfigFile(cfgPath string) error { | ||
| abs, err := filepath.Abs(cfgPath) | ||
| if err != nil { | ||
| return fmt.Errorf("Unable to determine config path: %w", err) | ||
| return fmt.Errorf("unable to determine config path: %w", err) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixes: |
||
| } | ||
| c.absCfgPath = abs | ||
|
|
||
| // If a config file exists, let's load it | ||
| if _, err := os.Stat(abs); err != nil { | ||
| return fmt.Errorf("Config file doesn't exist: %w", err) | ||
| return fmt.Errorf("config file doesn't exist: %w", err) | ||
| } | ||
|
|
||
| // Load HCL config. | ||
| err = c.globalKoanf.Load(file.Provider(abs), hcl.Parser(true)) | ||
| if err != nil { | ||
| return fmt.Errorf("Unable to load config: %w", err) | ||
| return fmt.Errorf("unable to load config: %w", err) | ||
| } | ||
|
Comment on lines
217
to
218
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixes: |
||
|
|
||
| // Attempt to suss out a Config struct | ||
| err = c.globalKoanf.Unmarshal("", &c) | ||
| if err != nil { | ||
| return fmt.Errorf("Unable to unmarshal config: %w", err) | ||
| return fmt.Errorf("unable to unmarshal config: %w", err) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixes: |
||
| } | ||
|
|
||
| return nil | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -58,11 +58,11 @@ func WaitRunFinished(client *github.Client, opts Options, run github.WorkflowRun | |
| case "in_progress": | ||
| // Do nothing, keep watching | ||
| default: | ||
| return fmt.Errorf("Workflow \"%s\" is in unrepairable state: %s", *run.Name, *this.Status) | ||
| return fmt.Errorf("workflow \"%s\" is in unrepairable state: %s", *run.Name, *this.Status) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixes: |
||
| } | ||
| } | ||
|
|
||
| return fmt.Errorf("Timed out polling for workflow job") | ||
| return fmt.Errorf("timed out polling for workflow job") | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixes: |
||
| } | ||
|
|
||
| // FindRun finds the most recent GitHub Actions run matching a given run name. | ||
|
|
@@ -86,7 +86,7 @@ func FindRun(client *github.Client, opts Options, runName string) (github.Workfl | |
| runs, _, err := client.Actions.ListWorkflowRunsByFileName(context.Background(), opts.GitHubOwner, opts.GitHubRepo, opts.WorkflowFileName, searchOpts) | ||
| if err != nil { | ||
| // TODO: handle rate limiting | ||
| return github.WorkflowRun{}, fmt.Errorf("Error attempting to find the \"%s\" workflow run: %w", runName, err) | ||
| return github.WorkflowRun{}, fmt.Errorf("error attempting to find the \"%s\" workflow run: %w", runName, err) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixes: |
||
| } | ||
|
|
||
| for _, v := range runs.WorkflowRuns { | ||
|
|
@@ -97,7 +97,7 @@ func FindRun(client *github.Client, opts Options, runName string) (github.Workfl | |
|
|
||
| time.Sleep(time.Duration(opts.SecondsBetweenPolls) * time.Second) | ||
| } | ||
| return github.WorkflowRun{}, fmt.Errorf("Timed out polling for workflow job") | ||
| return github.WorkflowRun{}, fmt.Errorf("timed out polling for workflow job") | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixes: |
||
| } | ||
|
|
||
| // Worker spawns an instance of a goroutine that listens for new job requests | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -48,7 +48,7 @@ type Annotation struct { | |
| // ErrorNotInGHA is the error returned when a function can only | ||
| // execute in GitHub Actions, but the current execution | ||
| // environment is NOT GitHub Actions | ||
| var ErrorNotInGHA = errors.New("Not in GitHub Actions") | ||
| var ErrorNotInGHA = errors.New("not in GitHub Actions") | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixes: |
||
|
|
||
| // New returns a new GitHub Actions Writer | ||
| func New(out io.Writer) *GHA { | ||
|
|
@@ -76,12 +76,12 @@ func (gha *GHA) EnableGHAOutput() { | |
| // https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#grouping-log-lines | ||
| func (gha *GHA) StartGroup(name string) { | ||
| if !gha.IsGHA() { | ||
| gha.println(text.Bold.Sprint(name)) | ||
| _, _ = gha.println(text.Bold.Sprint(name)) | ||
| return | ||
| } | ||
|
|
||
| out := "::group::" + name | ||
| gha.println(out) | ||
| _, _ = gha.println(out) | ||
| } | ||
|
|
||
| // EndGroup ends a GitHub Actions logging group | ||
|
|
@@ -91,7 +91,7 @@ func (gha *GHA) EndGroup() { | |
| return | ||
| } | ||
|
|
||
| gha.println("::endgroup::") | ||
| _, _ = gha.println("::endgroup::") | ||
| } | ||
|
|
||
| // SetOutput generates a GitHub Actions output for the current job | ||
|
|
@@ -122,7 +122,7 @@ func (gha *GHA) SetJobSummary(content string) error { | |
| func (gha *GHA) appendToFile(fileEnvVar string, content string) error { | ||
| path, exists := os.LookupEnv(fileEnvVar) | ||
| if !gha.IsGHA() || !exists { | ||
| return fmt.Errorf("Unable to set modify GitHub Actions environment file %s: %w", fileEnvVar, ErrorNotInGHA) | ||
| return fmt.Errorf("unable to set modify GitHub Actions environment file %s: %w", fileEnvVar, ErrorNotInGHA) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixes: |
||
| } | ||
|
|
||
| // Short cut if no content is provided | ||
|
|
@@ -141,7 +141,7 @@ func (gha *GHA) appendToFile(fileEnvVar string, content string) error { | |
| return err | ||
| } | ||
|
|
||
| defer f.Close() | ||
| defer func() { _ = f.Close() }() | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixes: |
||
|
|
||
| _, err = f.WriteString(content) | ||
| if err != nil { | ||
|
|
@@ -199,10 +199,10 @@ func (gha *GHA) newAnnotation(T string, a Annotation) { | |
| // "::error file={name},line={line},endLine={endLine},title={title}::{message}" | ||
| // "::error file=app.js,line=1,title=Syntax Error::Missing semicolon" | ||
| str := fmt.Sprintf("::%s %s::%s", T, strings.Join(attributes, ","), a.Message) | ||
| gha.println(str) | ||
| _, _ = gha.println(str) | ||
| } | ||
|
|
||
| // println is an internal helper for printing to the expected output io.Writer | ||
| func (gha *GHA) println(i ...interface{}) { | ||
| fmt.Fprintln(gha.outWriter, i...) | ||
| func (gha *GHA) println(i ...interface{}) (int, error) { | ||
| return fmt.Fprintln(gha.outWriter, i...) | ||
|
Comment on lines
-206
to
+207
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixes: We are propagating the errors upward. Callers are swallowing the errors for now. |
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -58,15 +58,15 @@ func Test_New(t *testing.T) { | |
| for _, tt := range tests { | ||
| t.Run(tt.name, func(t *testing.T) { | ||
| for k, v := range tt.env { | ||
| os.Setenv(k, v) | ||
| _ = os.Setenv(k, v) | ||
| fmt.Println("Setting env var " + k + " equal to " + v) | ||
| } | ||
|
|
||
| gha := New(&b) | ||
| assert.Equal(t, tt.expectedOutput.isGHA, gha.isGHA) | ||
|
|
||
| for k := range tt.env { | ||
| os.Unsetenv(k) | ||
| _ = os.Unsetenv(k) | ||
|
Comment on lines
-61
to
+69
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixes: |
||
| } | ||
| }) | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,7 +23,7 @@ func EnsureCorrectName(filePath string) (string, error) { | |
| fmt.Printf("Found improperly named file \"%s\". Renaming to \"%s\"", filePath, desiredPath) | ||
| err := os.Rename(filePath, filepath.Join(dir, "LICENSE")) | ||
| if err != nil { | ||
| return "", fmt.Errorf("Unable to rename file \"%s\". Full error context: %s", filePath, err) | ||
| return "", fmt.Errorf("unable to rename file \"%s\". Full error context: %s", filePath, err) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixes: |
||
| } | ||
| } else { | ||
| fmt.Printf("Validated file: %s\n", filePath) | ||
|
|
@@ -53,7 +53,7 @@ func AddLicenseFile(dirPath string, spdxID string) (string, error) { | |
| template, exists := licenseTemplate[spdxID] | ||
| if !exists { | ||
| validOptions := strings.Join(lo.Keys(licenseTemplate), ", ") | ||
| return "", fmt.Errorf("Failed to add license file, unknown SPDX license ID: %s. The following options are supported at this time: %s", spdxID, validOptions) | ||
| return "", fmt.Errorf("failed to add license file, unknown SPDX license ID: %s. The following options are supported at this time: %s", spdxID, validOptions) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixes: |
||
| } | ||
|
|
||
| destinationPath, err := filepath.Abs(filepath.Join(dirPath, "LICENSE")) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The config file is not required with golangci-lint v2. Disabled linters have been "reneabled" by this change and their errors have been fixed.