Skip to content

Bump golangci/golangci-lint-action from 6.1.1 to 7.0.0 #980

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ jobs:
- uses: actions/setup-go@0aaccfd150d50ccaeb58ebd88d36e91967a5f35b
with:
go-version-file: ./go.mod
- uses: golangci/golangci-lint-action@971e284b6050e8a5849b72094c50ab08da042db8
- uses: golangci/golangci-lint-action@1481404843c368bc19ca9406f87d6e0fc97bdcfd
with:
version: latest
187 changes: 100 additions & 87 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,71 +1,6 @@
linters-settings:
dupl:
threshold: 100
funlen:
lines: 100
statements: 50
gci:
prefix: github.com/np-guard
goconst:
min-len: 2
min-occurrences: 2
gocritic:
enabled-tags:
- diagnostic
- experimental
- opinionated
- performance
- style
gocyclo:
min-complexity: 15
goheader:
values:
const:
COMPANY: IBM Inc.
template: |-
Copyright 2023- {{ COMPANY }} All Rights Reserved.

SPDX-License-Identifier: Apache-2.0
goimports:
local-prefixes: github.com/np-guard
mnd:
# don't include the "operation" and "assign"
checks: argument,case,condition,return
ignored-numbers: 0,1,2,3
ignored-functions: strings.SplitN

govet:
shadow: true
lll:
line-length: 140
misspell:
locale: US
nolintlint:
allow-leading-space: true # don't require machine-readable nolint directives (i.e. with no leading space)
allow-unused: false # report any unused nolint directives
require-explanation: false # don't require an explanation for nolint directives
require-specific: false # don't require nolint directives to be specific about which linter is being skipped
revive:
# see https://github.com/mgechev/revive#available-rules for details.
ignore-generated-header: true
severity: warning
rules:
- name: indent-error-flow
severity: warning
- name: add-constant
severity: warning
arguments:
- maxLitCount: "1"
allowStrs: '"",".","-","/","\n","\n\n","\t","error","true","false"'
allowInts: "0,1,2,404"
allowFloats: "0.0,0.,1.0,1.,2.0,2."
tagliatelle:
case:
rules:
json: snake

version: "2"
linters:
disable-all: true
default: none
enable:
- asasalint
- asciicheck
Expand All @@ -85,14 +20,10 @@ linters:
- goconst
- gocritic
- gocyclo
- gofmt
- goheader
- goimports
- mnd
- gomoddirectives
- goprintffuncname
- gosec
- gosimple
- govet
- grouper
- importas
Expand All @@ -101,6 +32,7 @@ linters:
- loggercheck
- makezero
- misspell
- mnd
- nakedret
- nilerr
- noctx
Expand All @@ -112,28 +44,109 @@ linters:
- reassign
- revive
- staticcheck
- stylecheck
- tagliatelle
- testableexamples
- typecheck
- unconvert
- unparam
- unused
- usestdlibvars
- usetesting
- whitespace

issues:
exclude-rules:
- path: _test\.go
linters:
- dupl
- revive
- goconst
- funlen

run:
timeout: 5m
settings:
dupl:
threshold: 100
funlen:
lines: 100
statements: 50
goconst:
min-len: 2
min-occurrences: 2
gocritic:
enabled-tags:
- diagnostic
- experimental
- opinionated
- performance
- style
gocyclo:
min-complexity: 15
goheader:
values:
const:
COMPANY: IBM Inc.
template: |-
Copyright 2023- {{ COMPANY }} All Rights Reserved.

output:
print-issued-lines: false
SPDX-License-Identifier: Apache-2.0
govet:
enable:
- shadow
lll:
line-length: 140
misspell:
locale: US
mnd:
checks:
- argument
- case
- condition
- return
ignored-numbers:
- "0"
- "1"
- "2"
- "3"
ignored-functions:
- strings.SplitN
nolintlint:
require-explanation: false
require-specific: false
allow-unused: false
revive:
severity: warning
rules:
- name: indent-error-flow
severity: warning
- name: add-constant
arguments:
- allowFloats: 0.0,0.,1.0,1.,2.0,2.
allowInts: 0,1,2,404
allowStrs: '"",".","-","/","\n","\n\n","\t","error","true","false"'
maxLitCount: "1"
severity: warning
tagliatelle:
case:
rules:
json: snake
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
rules:
- linters:
- dupl
- funlen
- goconst
- revive
path: _test\.go
paths:
- third_party$
- builtin$
- examples$
formatters:
enable:
- gofmt
- goimports
settings:
goimports:
local-prefixes:
- github.com/np-guard
exclusions:
generated: lax
paths:
- third_party$
- builtin$
- examples$
6 changes: 3 additions & 3 deletions pkg/awsvpc/nacl_analysis.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ func (na *AWSNACLAnalyzer) GetNACLRule(index int) (ruleStr string, ruleRes *comm
portsStr = fmt.Sprintf(", dstPorts: %d-%d", minPort, maxPort)
case protocolICMP:
icmpTypeMin, icmpTypeMax, icmpCodeMin, icmpCodeMax,
err := handleIcmpTypeCode(ruleObj.IcmpTypeCode.Type, ruleObj.IcmpTypeCode.Code)
err2 := handleIcmpTypeCode(ruleObj.IcmpTypeCode.Type, ruleObj.IcmpTypeCode.Code)

if err != nil {
return "", nil, false, err
if err2 != nil {
return "", nil, false, err2
}
if ruleObj.IcmpTypeCode.Type != nil && *ruleObj.IcmpTypeCode.Type != -1 {
portsStr = fmt.Sprintf(", type: %d", *ruleObj.IcmpTypeCode.Type)
Expand Down
10 changes: 6 additions & 4 deletions pkg/commonvpc/nacl_analysis.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ func GetAllowedXgressConnections(rules []*NACLRule, src, subnetCidr *netset.IPBl
}
for _, disjointDestCidr := range destCidrList {
disjointDestIP := disjointDestCidr.ToIPRanges()
if rule.Action == ALLOW {
switch rule.Action {
case ALLOW:
addedAllowedConns := rule.Connections.Copy()
addedAllowedConns = addedAllowedConns.Subtract(deniedXgress[disjointDestIP])
// issue here at union below
Expand All @@ -148,7 +149,7 @@ func GetAllowedXgressConnections(rules []*NACLRule, src, subnetCidr *netset.IPBl
if !allowedXgress[disjointDestIP].Equal(allowedXgressDestCidrBefore) { // this rule contributes to the connection
allowRules[disjointDestIP] = append(allowRules[disjointDestIP], rule.Index)
}
} else if rule.Action == DENY {
case DENY:
addedDeniedConns := rule.Connections.Copy()
addedDeniedConns = addedDeniedConns.Subtract(allowedXgress[disjointDestIP])
deniedXgressDestCidrBefore := deniedXgress[disjointDestIP]
Expand Down Expand Up @@ -418,9 +419,10 @@ func (na *NACLAnalyzer) getRulesRelevantConn(rules []int,
continue
}
curConn = curConn.Union(rule.Connections)
if rule.Action == ALLOW {
switch rule.Action {
case ALLOW:
allowRelevant = append(allowRelevant, rule.Index)
} else if rule.Action == DENY {
case DENY:
denyRelevant = append(denyRelevant, rule.Index)
}
contains := connQuery.IsSubset(curConn)
Expand Down
6 changes: 3 additions & 3 deletions pkg/commonvpc/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,9 @@ func NewVPC(name, uid, region string, zonesToAP map[string][]string, regionToStr
}
for zoneName, zoneCidrsList := range zonesToAP {
vpcNodeSet.AddressPrefixesList = append(vpcNodeSet.AddressPrefixesList, zoneCidrsList...)
zoneIPBlock, err := netset.IPBlockFromCidrList(zoneCidrsList)
if err != nil {
return nil, err
zoneIPBlock, err2 := netset.IPBlockFromCidrList(zoneCidrsList)
if err2 != nil {
return nil, err2
}
vpcNodeSet.Zones[zoneName] = &Zone{Name: zoneName,
Vpc: vpcNodeSet,
Expand Down
5 changes: 3 additions & 2 deletions pkg/commonvpc/testfunc/common_test_functionality.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,8 @@ func GetTestsDirInput() string {

func compareOrRegenerateOutputPerTest(t *testing.T, mode testMode, actualOutput, testDir, name string,
expectedOutput map[vpcmodel.OutputUseCase]string, uc vpcmodel.OutputUseCase) error {
if mode == OutputComparison {
switch mode {
case OutputComparison:
expectedOutput, err := os.ReadFile(expectedOutput[uc])
if err != nil {
t.Fatalf(errString, err)
Expand All @@ -309,7 +310,7 @@ func compareOrRegenerateOutputPerTest(t *testing.T, mode testMode, actualOutput,
compareTextualResult(expectedOutputStr, actualOutput, testDir)
t.Fatalf("output mismatch expected-vs-actual on test name: %s, use case: %d", name, uc)
}
} else if mode == OutputGeneration {
case OutputGeneration:
fmt.Printf("outputGeneration\n")
// create or override expected output file
if _, err := vpcmodel.WriteToFile(actualOutput, expectedOutput[uc]); err != nil {
Expand Down
13 changes: 7 additions & 6 deletions pkg/drawio/layout.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,12 +207,13 @@ func getSubnetIconsOrder(subnet SquareTreeNodeInterface) [][]IconTreeNodeInterfa
// collect for each group with viability square its innerSquares groups:
for _, groupS := range sortedBySizeGroups {
group := groupS.(*GroupSquareTreeNode)
if group.visibility == square {
switch group.visibility {
case square:
outerToInnersGroup[group] = map[SquareTreeNodeInterface]bool{}
for _, icon := range group.groupedIcons {
iconOuterGroup[icon] = group
}
} else if group.visibility == innerSquare {
case innerSquare:
for _, icon := range group.groupedIcons {
iconInnerGroup[icon] = group
outerToInnersGroup[iconOuterGroup[icon]][group] = true
Expand Down Expand Up @@ -379,8 +380,8 @@ func (ly *layoutS) resolveGroupedSubnetsOverlap() {

// check if two squares: share a col and have the same first/last raw, or share a row and have the same first/last col
func squareBordersOverlap(l1, l2 *Location) bool {
shareCol := !(l1.firstCol.index > l2.lastCol.index || l2.firstCol.index > l1.lastCol.index)
shareRow := !(l1.firstRow.index > l2.lastRow.index || l2.firstRow.index > l1.lastRow.index)
shareCol := l1.firstCol.index <= l2.lastCol.index && l2.firstCol.index <= l1.lastCol.index
shareRow := l1.firstRow.index <= l2.lastRow.index && l2.firstRow.index <= l1.lastRow.index
sameRow := l1.firstRow == l2.firstRow || l1.lastRow == l2.lastRow
sameCol := l1.firstCol == l2.firstCol || l1.lastCol == l2.lastCol
return shareCol && sameRow || shareRow && sameCol
Expand Down Expand Up @@ -772,13 +773,13 @@ func (ly *layoutS) setGroupingIconLocations() {
r, c := calcGroupingIconLocation(parentLocation, colleagueLocation)
gIcon.setLocation(newCellLocation(r, c))
// add the icon to its border:
groupBorder := groupBorder{
gb := groupBorder{
c: c,
r: r,
visibility: parent.visibility,
right: c == parentLocation.nextCol(),
}
iconsInBorder[groupBorder] = append(iconsInBorder[groupBorder], gIcon)
iconsInBorder[gb] = append(iconsInBorder[gb], gIcon)
// set the x offset to the icons:
switch parent.visibility {
case theSubnet:
Expand Down
10 changes: 5 additions & 5 deletions pkg/ibmvpc/routing_tables_analysis.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ func (ga *GlobalRTAnalyzer) GetRoutingPath(src vpcmodel.InternalNodeIntf, dest *
}
// if res ends with "tgw" -> should get remaining routing path in the target VPC with src:tgw
if res != nil && res.DoesEndWithTGW() {
targetVPCAnalyzer, err := ga.getRTAnalyzerPerVPC(res.TargetVPC())
if err != nil {
return nil, err
targetVPCAnalyzer, errGet := ga.getRTAnalyzerPerVPC(res.TargetVPC())
if errGet != nil {
return nil, errGet
}
targetVPC := ga.allConfigs.GetVPC(res.TargetVPC()).(*commonvpc.VPC)
destZone, _ := getZoneByIPBlock(dest, ga.allConfigs)
Expand All @@ -74,8 +74,8 @@ func (ga *GlobalRTAnalyzer) GetRoutingPath(src vpcmodel.InternalNodeIntf, dest *
// if dest zone is not found, should consider all routes for all zones in the RT
// and prefer the one with the src zone of such is available
// the analysis should be done for all available zones (up to 3)
res2, err := targetVPCAnalyzer.getIngressPath(tgwSource, dest, destZone, srcZone)
return vpcmodel.ConcatPaths(res, res2), err
res2, err2 := targetVPCAnalyzer.getIngressPath(tgwSource, dest, destZone, srcZone)
return vpcmodel.ConcatPaths(res, res2), err2
}
// else - routing remains within a single vpc context
return res, err
Expand Down
4 changes: 2 additions & 2 deletions pkg/ibmvpc/subnetsIPBlocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ type subnetsIPBlocks map[string]*oneSubnetBlocks
// 3. calculate the splitByFiltersBlocks
// 4. calculate the freeAddressesBlocks
func getSubnetsIPBlocks(rc *IBMresourcesContainer, filtersCidrs []map[string][]*string,
skipByVPC map[string]bool) (subnetsBlocks subnetsIPBlocks, err error) {
subnetsBlocks = subnetsIPBlocks{}
skipByVPC map[string]bool) (subnetsIPBlocks, error) {
subnetsBlocks := subnetsIPBlocks{}
// gets the original blocks of the subnets:
if err := subnetsBlocks.getSubnetsOriginalBlocks(rc, skipByVPC); err != nil {
return nil, err
Expand Down
Loading
Loading