Skip to content

Commit

Permalink
update .golangci.yml (#344)
Browse files Browse the repository at this point in the history
* update .golangci.yml

Signed-off-by: adisos <[email protected]>

* update headers

Signed-off-by: adisos <[email protected]>

* lint fix: the type name connlistAnalyzerWarning should conform to the xxxError format

Signed-off-by: adisos <[email protected]>

---------

Signed-off-by: adisos <[email protected]>
  • Loading branch information
adisos authored May 6, 2024
1 parent 15fa943 commit 1e64c08
Show file tree
Hide file tree
Showing 56 changed files with 351 additions and 194 deletions.
31 changes: 20 additions & 11 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ linters-settings:
lines: 100
statements: 50
gci:
local-prefixes: github.com/np-guard
prefix: github.com/np-guard
goconst:
min-len: 2
min-occurrences: 2
Expand All @@ -18,18 +18,24 @@ linters-settings:
- 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:
settings:
mnd:
# don't include the "operation" and "assign"
checks: argument,case,condition,return
ignored-numbers: 0,1,2,3
ignored-functions: strings.SplitN
# don't include the "operation" and "assign"
checks: argument,case,condition,return
ignored-numbers: 0,1,2,3
ignored-functions: strings.SplitN

govet:
check-shadowing: true
shadow: true
lll:
line-length: 140
misspell:
Expand Down Expand Up @@ -70,6 +76,7 @@ linters:
- dupl
- durationcheck
- errcheck
- errname
- errorlint
- exportloopref
- funlen
Expand All @@ -79,6 +86,7 @@ linters:
- gocritic
- gocyclo
- gofmt
- goheader
- goimports
- mnd
- gomoddirectives
Expand Down Expand Up @@ -108,7 +116,6 @@ linters:
- tagliatelle
- tenv
- testableexamples
- tparallel
- typecheck
- unconvert
- unparam
Expand All @@ -124,7 +131,9 @@ issues:
- revive
- goconst
- funlen
- errcheck


run:
timeout: 5m

output:
print-issued-lines: false
19 changes: 6 additions & 13 deletions cmd/netpolicy/main.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
// Copyright 2022
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/*
Copyright 2023- IBM Inc. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/

package main

import (
Expand Down
6 changes: 6 additions & 0 deletions pkg/cli/command_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/*
Copyright 2023- IBM Inc. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/

package cli

import (
Expand Down
19 changes: 6 additions & 13 deletions pkg/cli/diff.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
// Copyright 2022
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/*
Copyright 2023- IBM Inc. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/

package cli

import (
Expand Down
19 changes: 6 additions & 13 deletions pkg/cli/evaluate.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
// Copyright 2022
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/*
Copyright 2023- IBM Inc. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/

package cli

import (
Expand Down
19 changes: 6 additions & 13 deletions pkg/cli/list.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
// Copyright 2022
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/*
Copyright 2023- IBM Inc. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/

package cli

import (
Expand Down
19 changes: 6 additions & 13 deletions pkg/cli/root.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
// Copyright 2022
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/*
Copyright 2023- IBM Inc. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/

package cli

import (
Expand Down
6 changes: 6 additions & 0 deletions pkg/internal/netpolerrors/netpol_errors.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/*
Copyright 2023- IBM Inc. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/

package netpolerrors

import "fmt"
Expand Down
6 changes: 6 additions & 0 deletions pkg/internal/output/output.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/*
Copyright 2023- IBM Inc. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/

package output

import "os"
Expand Down
6 changes: 6 additions & 0 deletions pkg/internal/projectpath/projectpath.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/*
Copyright 2023- IBM Inc. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/

package projectpath

import (
Expand Down
6 changes: 6 additions & 0 deletions pkg/internal/testutils/testutils.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/*
Copyright 2023- IBM Inc. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/

package testutils

import (
Expand Down
6 changes: 6 additions & 0 deletions pkg/logger/logger.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/*
Copyright 2023- IBM Inc. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/

package logger

import (
Expand Down
6 changes: 6 additions & 0 deletions pkg/manifests/fsscanner/manifests.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/*
Copyright 2023- IBM Inc. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/

package fsscanner

import (
Expand Down
6 changes: 6 additions & 0 deletions pkg/manifests/fsscanner/manifests_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/*
Copyright 2023- IBM Inc. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/

package fsscanner

import (
Expand Down
6 changes: 6 additions & 0 deletions pkg/manifests/parser/error_types.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/*
Copyright 2023- IBM Inc. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/

package parser

import (
Expand Down
6 changes: 6 additions & 0 deletions pkg/manifests/parser/k8sobj.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/*
Copyright 2023- IBM Inc. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/

package parser

import (
Expand Down
6 changes: 6 additions & 0 deletions pkg/manifests/parser/parser.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/*
Copyright 2023- IBM Inc. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/

package parser

import (
Expand Down
6 changes: 6 additions & 0 deletions pkg/netpol/connlist/connlist.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/*
Copyright 2023- IBM Inc. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/

// The connlist package of netpol-analyzer allows producing a k8s connectivity report based on several resources:
// k8s NetworkPolicy, k8s Ingress, openshift Route
// It lists the set of allowed connections between each pair of different peers (k8s workloads or ip-blocks).
Expand Down
12 changes: 9 additions & 3 deletions pkg/netpol/connlist/connlist_errors.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/*
Copyright 2023- IBM Inc. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/

package connlist

import (
Expand All @@ -23,7 +29,7 @@ type resourceEvaluationError struct {
origErr error
}

type connlistAnalyzerWarning struct {
type connlistAnalyzerWarnError struct {
origErr error
}

Expand All @@ -35,7 +41,7 @@ func (e *resourceEvaluationError) Error() string {
return e.origErr.Error()
}

func (e *connlistAnalyzerWarning) Error() string {
func (e *connlistAnalyzerWarnError) Error() string {
return e.origErr.Error()
}

Expand Down Expand Up @@ -70,5 +76,5 @@ func newResourceEvaluationError(err error) *connlistGeneratingError {
}

func newConnlistAnalyzerWarning(err error) *connlistGeneratingError {
return &connlistGeneratingError{err: &connlistAnalyzerWarning{err}, fatal: false, severe: false}
return &connlistGeneratingError{err: &connlistAnalyzerWarnError{err}, fatal: false, severe: false}
}
6 changes: 6 additions & 0 deletions pkg/netpol/connlist/connlist_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/*
Copyright 2023- IBM Inc. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/

package connlist

import (
Expand Down
6 changes: 6 additions & 0 deletions pkg/netpol/connlist/conns_formatter.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/*
Copyright 2023- IBM Inc. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/

package connlist

import (
Expand Down
6 changes: 6 additions & 0 deletions pkg/netpol/connlist/conns_formatter_csv.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/*
Copyright 2023- IBM Inc. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/

package connlist

import (
Expand Down
6 changes: 6 additions & 0 deletions pkg/netpol/connlist/conns_formatter_dot.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/*
Copyright 2023- IBM Inc. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/

package connlist

import (
Expand Down
6 changes: 6 additions & 0 deletions pkg/netpol/connlist/conns_formatter_json.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/*
Copyright 2023- IBM Inc. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/

package connlist

import "encoding/json"
Expand Down
Loading

0 comments on commit 1e64c08

Please sign in to comment.