Skip to content

Commit 5796954

Browse files
dependabot[bot]Abhijeet V
andauthored
[chore] : Bump golangci/golangci-lint-action from 3.6.0 to 8.0.0 (#133)
* [chore] : Bump golangci/golangci-lint-action from 3.6.0 to 8.0.0 Bumps [golangci/golangci-lint-action](https://github.com/golangci/golangci-lint-action) from 3.6.0 to 8.0.0. - [Release notes](https://github.com/golangci/golangci-lint-action/releases) - [Commits](golangci/golangci-lint-action@639cd34...4afd733) --- updated-dependencies: - dependency-name: golangci/golangci-lint-action dependency-version: 8.0.0 dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> * fix lint errors and remove golangcli config --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Abhijeet V <abhijeet.v@hashicorp.com>
1 parent c9ce8cb commit 5796954

File tree

9 files changed

+25
-44
lines changed

9 files changed

+25
-44
lines changed

.github/workflows/golangci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
go-version-file: '.go-version'
2626

2727
- name: run go lint
28-
uses: golangci/golangci-lint-action@639cd343e1d3b897ff35927a75193d57cfcba299 # v3.6.0
28+
uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # v8.0.0
2929
with:
3030
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
3131
version: latest

.golangci.yaml

Lines changed: 0 additions & 19 deletions
This file was deleted.

cmd/init.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ for any unknown values. If you are running this command in CI, please use the
101101
// Render it out!
102102
f, err := os.Create(".copywrite.hcl")
103103
cobra.CheckErr(err)
104-
defer f.Close()
104+
defer func() { cobra.CheckErr(f.Close()) }()
105105

106106
err = configToHCL(*newConfig, f)
107107
cobra.CheckErr(err)

cmd/license.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ var licenseCmd = &cobra.Command{
4545

4646
// Input Validation
4747
if conf.Project.CopyrightYear == 0 {
48-
errYearNotFound := errors.New("Unable to automatically determine copyright year. Please specify it manually in the config or via the --year flag")
48+
errYearNotFound := errors.New("unable to automatically determine copyright year: Please specify it manually in the config or via the --year flag")
4949

5050
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.")
5151
repo, err := github.DiscoverRepo()
@@ -78,7 +78,7 @@ var licenseCmd = &cobra.Command{
7878
var file string
7979

8080
if len(licenseFiles) > 1 {
81-
err = fmt.Errorf("More than one license file exists. Please review the following files and manually ensure only one is present: %s", licenseFiles)
81+
err = fmt.Errorf("more than one license file exists: Please review the following files and manually ensure only one is present: %s", licenseFiles)
8282
cliLogger.Error(err.Error())
8383
cobra.CheckErr(err)
8484
return

config/config.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,25 +202,25 @@ func (c *Config) LoadCommandFlags(flagSet *pflag.FlagSet, mapping map[string]str
202202
func (c *Config) LoadConfigFile(cfgPath string) error {
203203
abs, err := filepath.Abs(cfgPath)
204204
if err != nil {
205-
return fmt.Errorf("Unable to determine config path: %w", err)
205+
return fmt.Errorf("unable to determine config path: %w", err)
206206
}
207207
c.absCfgPath = abs
208208

209209
// If a config file exists, let's load it
210210
if _, err := os.Stat(abs); err != nil {
211-
return fmt.Errorf("Config file doesn't exist: %w", err)
211+
return fmt.Errorf("config file doesn't exist: %w", err)
212212
}
213213

214214
// Load HCL config.
215215
err = c.globalKoanf.Load(file.Provider(abs), hcl.Parser(true))
216216
if err != nil {
217-
return fmt.Errorf("Unable to load config: %w", err)
217+
return fmt.Errorf("unable to load config: %w", err)
218218
}
219219

220220
// Attempt to suss out a Config struct
221221
err = c.globalKoanf.Unmarshal("", &c)
222222
if err != nil {
223-
return fmt.Errorf("Unable to unmarshal config: %w", err)
223+
return fmt.Errorf("unable to unmarshal config: %w", err)
224224
}
225225

226226
return nil

dispatch/dispatch.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,11 @@ func WaitRunFinished(client *github.Client, opts Options, run github.WorkflowRun
5858
case "in_progress":
5959
// Do nothing, keep watching
6060
default:
61-
return fmt.Errorf("Workflow \"%s\" is in unrepairable state: %s", *run.Name, *this.Status)
61+
return fmt.Errorf("workflow \"%s\" is in unrepairable state: %s", *run.Name, *this.Status)
6262
}
6363
}
6464

65-
return fmt.Errorf("Timed out polling for workflow job")
65+
return fmt.Errorf("timed out polling for workflow job")
6666
}
6767

6868
// 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
8686
runs, _, err := client.Actions.ListWorkflowRunsByFileName(context.Background(), opts.GitHubOwner, opts.GitHubRepo, opts.WorkflowFileName, searchOpts)
8787
if err != nil {
8888
// TODO: handle rate limiting
89-
return github.WorkflowRun{}, fmt.Errorf("Error attempting to find the \"%s\" workflow run: %w", runName, err)
89+
return github.WorkflowRun{}, fmt.Errorf("error attempting to find the \"%s\" workflow run: %w", runName, err)
9090
}
9191

9292
for _, v := range runs.WorkflowRuns {
@@ -97,7 +97,7 @@ func FindRun(client *github.Client, opts Options, runName string) (github.Workfl
9797

9898
time.Sleep(time.Duration(opts.SecondsBetweenPolls) * time.Second)
9999
}
100-
return github.WorkflowRun{}, fmt.Errorf("Timed out polling for workflow job")
100+
return github.WorkflowRun{}, fmt.Errorf("timed out polling for workflow job")
101101
}
102102

103103
// Worker spawns an instance of a goroutine that listens for new job requests

github/actions/core.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ type Annotation struct {
4848
// ErrorNotInGHA is the error returned when a function can only
4949
// execute in GitHub Actions, but the current execution
5050
// environment is NOT GitHub Actions
51-
var ErrorNotInGHA = errors.New("Not in GitHub Actions")
51+
var ErrorNotInGHA = errors.New("not in GitHub Actions")
5252

5353
// New returns a new GitHub Actions Writer
5454
func New(out io.Writer) *GHA {
@@ -76,12 +76,12 @@ func (gha *GHA) EnableGHAOutput() {
7676
// https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#grouping-log-lines
7777
func (gha *GHA) StartGroup(name string) {
7878
if !gha.IsGHA() {
79-
gha.println(text.Bold.Sprint(name))
79+
_, _ = gha.println(text.Bold.Sprint(name))
8080
return
8181
}
8282

8383
out := "::group::" + name
84-
gha.println(out)
84+
_, _ = gha.println(out)
8585
}
8686

8787
// EndGroup ends a GitHub Actions logging group
@@ -91,7 +91,7 @@ func (gha *GHA) EndGroup() {
9191
return
9292
}
9393

94-
gha.println("::endgroup::")
94+
_, _ = gha.println("::endgroup::")
9595
}
9696

9797
// SetOutput generates a GitHub Actions output for the current job
@@ -122,7 +122,7 @@ func (gha *GHA) SetJobSummary(content string) error {
122122
func (gha *GHA) appendToFile(fileEnvVar string, content string) error {
123123
path, exists := os.LookupEnv(fileEnvVar)
124124
if !gha.IsGHA() || !exists {
125-
return fmt.Errorf("Unable to set modify GitHub Actions environment file %s: %w", fileEnvVar, ErrorNotInGHA)
125+
return fmt.Errorf("unable to set modify GitHub Actions environment file %s: %w", fileEnvVar, ErrorNotInGHA)
126126
}
127127

128128
// Short cut if no content is provided
@@ -141,7 +141,7 @@ func (gha *GHA) appendToFile(fileEnvVar string, content string) error {
141141
return err
142142
}
143143

144-
defer f.Close()
144+
defer func() { _ = f.Close() }()
145145

146146
_, err = f.WriteString(content)
147147
if err != nil {
@@ -199,10 +199,10 @@ func (gha *GHA) newAnnotation(T string, a Annotation) {
199199
// "::error file={name},line={line},endLine={endLine},title={title}::{message}"
200200
// "::error file=app.js,line=1,title=Syntax Error::Missing semicolon"
201201
str := fmt.Sprintf("::%s %s::%s", T, strings.Join(attributes, ","), a.Message)
202-
gha.println(str)
202+
_, _ = gha.println(str)
203203
}
204204

205205
// println is an internal helper for printing to the expected output io.Writer
206-
func (gha *GHA) println(i ...interface{}) {
207-
fmt.Fprintln(gha.outWriter, i...)
206+
func (gha *GHA) println(i ...interface{}) (int, error) {
207+
return fmt.Fprintln(gha.outWriter, i...)
208208
}

github/actions/core_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,15 @@ func Test_New(t *testing.T) {
5858
for _, tt := range tests {
5959
t.Run(tt.name, func(t *testing.T) {
6060
for k, v := range tt.env {
61-
os.Setenv(k, v)
61+
_ = os.Setenv(k, v)
6262
fmt.Println("Setting env var " + k + " equal to " + v)
6363
}
6464

6565
gha := New(&b)
6666
assert.Equal(t, tt.expectedOutput.isGHA, gha.isGHA)
6767

6868
for k := range tt.env {
69-
os.Unsetenv(k)
69+
_ = os.Unsetenv(k)
7070
}
7171
})
7272
}

licensecheck/licensecheck.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ func EnsureCorrectName(filePath string) (string, error) {
2323
fmt.Printf("Found improperly named file \"%s\". Renaming to \"%s\"", filePath, desiredPath)
2424
err := os.Rename(filePath, filepath.Join(dir, "LICENSE"))
2525
if err != nil {
26-
return "", fmt.Errorf("Unable to rename file \"%s\". Full error context: %s", filePath, err)
26+
return "", fmt.Errorf("unable to rename file \"%s\". Full error context: %s", filePath, err)
2727
}
2828
} else {
2929
fmt.Printf("Validated file: %s\n", filePath)
@@ -53,7 +53,7 @@ func AddLicenseFile(dirPath string, spdxID string) (string, error) {
5353
template, exists := licenseTemplate[spdxID]
5454
if !exists {
5555
validOptions := strings.Join(lo.Keys(licenseTemplate), ", ")
56-
return "", fmt.Errorf("Failed to add license file, unknown SPDX license ID: %s. The following options are supported at this time: %s", spdxID, validOptions)
56+
return "", fmt.Errorf("failed to add license file, unknown SPDX license ID: %s. The following options are supported at this time: %s", spdxID, validOptions)
5757
}
5858

5959
destinationPath, err := filepath.Abs(filepath.Join(dirPath, "LICENSE"))

0 commit comments

Comments
 (0)