From 4169d7d02834911678ccacbd515222a086e8634e Mon Sep 17 00:00:00 2001 From: Patrick Ohly Date: Mon, 24 Apr 2023 13:08:13 +0200 Subject: [PATCH] golangci-lint: allow exceptions for Go naming convention In strict mode, stylecheck complains about Convert_* and SetDefaults_* functions in Kubernetes because they use underscores. We want to allow that to make the functions more readable. --- hack/golangci-strict.yaml | 6 ++++++ hack/golangci.yaml | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/hack/golangci-strict.yaml b/hack/golangci-strict.yaml index e07ab4d1c65b..b54a11f3b40b 100644 --- a/hack/golangci-strict.yaml +++ b/hack/golangci-strict.yaml @@ -15,6 +15,12 @@ issues: - path: conversion\.go linters: - ineffassign + # The Kubernetes naming convention for conversion functions uses underscores + # and intentionally deviates from normal Go conventions to make those function + # names more readable. Same for SetDefaults_*. + - linters: + - stylecheck + text: "ST1003: should not use underscores in Go names; func (Convert_.*_To_.*|SetDefaults_)" linters: disable-all: false # in contrast to golangci.yaml, the default set of linters remains enabled diff --git a/hack/golangci.yaml b/hack/golangci.yaml index d34f1e209003..280037377bf7 100644 --- a/hack/golangci.yaml +++ b/hack/golangci.yaml @@ -16,6 +16,12 @@ issues: - path: (pkg/volume/*|test/*|azure/*|pkg/cmd/wait*|request/bearertoken/*|metrics/*|filters/*) # not in golangci-strict.yaml linters: # not in golangci-strict.yaml - gocritic # not in golangci-strict.yaml + # The Kubernetes naming convention for conversion functions uses underscores + # and intentionally deviates from normal Go conventions to make those function + # names more readable. Same for SetDefaults_*. + - linters: + - stylecheck + text: "ST1003: should not use underscores in Go names; func (Convert_.*_To_.*|SetDefaults_)" linters: disable-all: true # not disabled in golangci-strict.yaml