Skip to content

Commit 336f9ce

Browse files
committed
Build: update linter to v2
1 parent 9de21ea commit 336f9ce

2 files changed

Lines changed: 46 additions & 21 deletions

File tree

.golangci.yaml

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,36 @@
1-
# Configuration for golangci-lint. See https://golangci-lint.run/usage/configuration/.
1+
version: "2"
22
linters:
3-
disable-all: false # use default linters
43
enable:
5-
- gofmt
6-
- whitespace
7-
- govet
8-
- misspell
4+
- bodyclose
95
- forcetypeassert
6+
- gosec
7+
- misspell
8+
- whitespace
9+
settings:
10+
gosec:
11+
excludes:
12+
- G404
13+
exclusions:
14+
generated: lax
15+
presets:
16+
- comments
17+
- common-false-positives
18+
- legacy
19+
- std-error-handling
20+
rules:
21+
- path: (.+)\.go$
22+
text: composite
23+
paths:
24+
- third_party$
25+
- builtin$
26+
- examples$
27+
formatters:
28+
enable:
1029
- gci
11-
- bodyclose
12-
issues:
13-
exclude:
14-
- composite
30+
- gofmt
31+
exclusions:
32+
generated: lax
33+
paths:
34+
- third_party$
35+
- builtin$
36+
- examples$

pkg/yum/repository.go

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ func (r *Repository) Repomd(ctx context.Context) (*Repomd, int, error) {
158158
return r.repomd, 0, nil
159159
}
160160
if repomdURL, err = r.getRepomdURL(); err != nil {
161-
return nil, 0, fmt.Errorf("Error parsing Repomd URL: %w", err)
161+
return nil, 0, fmt.Errorf("error parsing Repomd URL: %w", err)
162162
}
163163

164164
req, err := http.NewRequestWithContext(ctx, http.MethodGet, repomdURL, nil)
@@ -172,10 +172,10 @@ func (r *Repository) Repomd(ctx context.Context) (*Repomd, int, error) {
172172
defer resp.Body.Close()
173173

174174
if resp.StatusCode != http.StatusOK {
175-
return nil, resp.StatusCode, fmt.Errorf("Cannot fetch %v: %v", repomdURL, resp.StatusCode)
175+
return nil, resp.StatusCode, fmt.Errorf("cannot fetch %v: %v", repomdURL, resp.StatusCode)
176176
}
177177
if result, err = ParseRepomdXML(resp.Body); err != nil {
178-
return nil, resp.StatusCode, fmt.Errorf("Error parsing repomd.xml: %w", err)
178+
return nil, resp.StatusCode, fmt.Errorf("error parsing repomd.xml: %w", err)
179179
}
180180

181181
r.repomd = &result
@@ -249,7 +249,7 @@ func (r *Repository) Packages(ctx context.Context) ([]Package, int, error) {
249249
}
250250

251251
if primaryURL, err = r.getPrimaryURL(ctx); err != nil {
252-
return nil, 0, fmt.Errorf("Error getting primary URL: %w", err)
252+
return nil, 0, fmt.Errorf("error getting primary URL: %w", err)
253253
}
254254

255255
if resp, err = r.settings.Client.Get(primaryURL); err != nil {
@@ -258,7 +258,7 @@ func (r *Repository) Packages(ctx context.Context) ([]Package, int, error) {
258258
defer resp.Body.Close()
259259

260260
if resp.StatusCode != http.StatusOK {
261-
return nil, resp.StatusCode, fmt.Errorf("Cannot fetch %v: %d", primaryURL, resp.StatusCode)
261+
return nil, resp.StatusCode, fmt.Errorf("cannot fetch %v: %d", primaryURL, resp.StatusCode)
262262
}
263263

264264
if packages, err = ParseCompressedXMLData(io.NopCloser(resp.Body), *r.settings.MaxXmlSize); err != nil {
@@ -356,9 +356,10 @@ func (r *Repository) getCompsURL() (*string, error) {
356356
var compsLocation string
357357

358358
for _, data := range r.repomd.Data {
359-
if data.Type == "group_gz" {
359+
switch data.Type {
360+
case "group_gz":
360361
compsLocation = data.Location.Href
361-
} else if data.Type == "group" {
362+
case "group":
362363
compsLocation = data.Location.Href
363364
}
364365
}
@@ -379,9 +380,10 @@ func (r *Repository) getModulesURL() (*string, error) {
379380
var compsLocation string
380381

381382
for _, data := range r.repomd.Data {
382-
if data.Type == "modules_gz" {
383+
switch data.Type {
384+
case "modules_gz":
383385
compsLocation = data.Location.Href
384-
} else if data.Type == "modules" {
386+
case "modules":
385387
compsLocation = data.Location.Href
386388
}
387389
}
@@ -487,13 +489,14 @@ func ParseCompsXML(body io.ReadCloser, url *string) (Comps, error) {
487489

488490
switch elType := t.(type) {
489491
case xml.StartElement:
490-
if elType.Name.Local == "group" {
492+
switch elType.Name.Local {
493+
case "group":
491494
var packageGroup PackageGroup
492495
if decodeElementError := decoder.DecodeElement(&packageGroup, &elType); decodeElementError != nil {
493496
return comps, decodeElementError
494497
}
495498
packageGroups = append(packageGroups, packageGroup)
496-
} else if elType.Name.Local == "environment" {
499+
case "environment":
497500
var environment Environment
498501
if decodeElementError := decoder.DecodeElement(&environment, &elType); decodeElementError != nil {
499502
return comps, decodeElementError

0 commit comments

Comments
 (0)