From 5d70da641b0d88123fb153e60ed169a45675122b Mon Sep 17 00:00:00 2001 From: Guillaume Belanger Date: Wed, 3 Jan 2024 13:46:11 -0500 Subject: [PATCH] chore: Adds lint checks to CI (#34) * chore: Adds lint checks to CI * Uses single quotes * Re-adds whitespace lint check --- .github/workflows/master.yml | 15 ++++++++++++ .golangci.yml | 47 ++++++++++-------------------------- 2 files changed, 28 insertions(+), 34 deletions(-) diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index 680a6e4..9ee56c7 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -35,3 +35,18 @@ jobs: - name: Unit tests run: go test ./... + + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-go@v5 + with: + go-version-file: 'go.mod' + + - name: golangci-lint + uses: golangci/golangci-lint-action@v3.7.0 + with: + version: latest + args: -v --config ./.golangci.yml diff --git a/.golangci.yml b/.golangci.yml index 776c69f..ce5cba8 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,7 +1,7 @@ # Copyright 2019 free5GC.org # # SPDX-License-Identifier: Apache-2.0 -# +# # This file contains all available configuration options # with their default values. @@ -142,22 +142,6 @@ linters-settings: mnd: # the list of enabled checks, see https://github.com/tommy-muehle/go-mnd/#checks for description. checks: argument,case,condition,operation,return,assign - gomodguard: - allowed: - modules: # List of allowed modules - # - gopkg.in/yaml.v2 - domains: # List of allowed module domains - # - golang.org - blocked: - modules: # List of blocked modules - # - github.com/uudashr/go-module: # Blocked module - # recommendations: # Recommended modules that should be used instead (Optional) - # - golang.org/x/mod - # reason: "`mod` is the official go.mod parser library." # Reason why the recommended module should be used (Optional) - versions: # List of blocked module version constraints - # - github.com/mitchellh/go-homedir: # Blocked module with version constraint - # version: "< 1.1.0" # Version constraint, see https://github.com/Masterminds/semver#basic-comparisons - # reason: "testing if blocked version constraint works." # Reason why the version constraint exists. (Optional) govet: # report about shadowed variables check-shadowing: true @@ -205,16 +189,13 @@ linters-settings: # if it's called for subdir of a project it can't find funcs usages. All text editor integrations # with golangci-lint call it on a directory with the changed file. check-exported: false - whitespace: - multi-if: false # Enforces newlines (or comments) after every multi-line if statement - multi-func: false # Enforces newlines (or comments) after every multi-line function signature gci: local-prefixes: "bitbucket.org" misspell: #locale: US ignore-words: whitespace: - multi-if: false # Enforces newlines (or comments) after every multi-line if statement + multi-if: false # Enforces newlines (or comments) after every multi-line if statement multi-func: false # Enforces newlines (or comments) after every multi-line function signature wsl: # If true append is only allowed to be cuddled if appending value is @@ -240,19 +221,17 @@ linters-settings: linters: enable: - - gofmt + # - gofmt - govet - errcheck - - staticcheck - - unused - - gosimple - - structcheck - - varcheck + # - staticcheck + # - unused + # - gosimple + # - structcheck - ineffassign - - deadcode - typecheck # Additional - - lll + # - lll - godox #- gomnd #- goconst @@ -261,15 +240,15 @@ linters: # - nestif # - gomodguard - nakedret - - gci + # - gci - misspell - - gofumpt - - whitespace + # - gofumpt + # - whitespace - unconvert - predeclared - noctx - dogsled - - bodyclose + # - bodyclose - asciicheck #- stylecheck # - unparam @@ -332,5 +311,5 @@ severity: # Only affects out formats that support setting severity information. rules: - linters: - - gomnd + - gomnd severity: ignore