Skip to content
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

Configured golangci-lint #51

Merged
merged 6 commits into from
Sep 14, 2021
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/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@ jobs:
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v2
with:
version: v1.37
version: latest
116 changes: 115 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,124 @@
# Configuration reference: https://golangci-lint.run/usage/configuration/
# Linters reference: https://golangci-lint.run/usage/linters/
run:
build-tags:
- examples
skip-dirs:
- apiv6/localhost_apiserver/cloudexport
- apiv6/localhost_apiserver/synthetics

issues:
max-issues-per-linter: 0
max-same-issues: 0
# TODO(dfurman): enable more linters
exclude:
# TODO: These errors should be enabled
- don't use an underscore in package name
- should not use underscores in package names
# EXC0002 golint: Annoying issue about not having a comment. The rare codebase has such comments
- (comment on exported (method|function|type|const)|should have( a package)? comment|comment should be of the form)
exclude-use-default: false
exclude-rules: # exclude linters impossible to exclude via //nolint
- path: ^kentikapi/models/enum_ # these files are generated and shouldn't be edited with //nolint
linters:
- gochecknoglobals
- lll
- gomnd

# Disabled linters:
# - cyclop - duplicates functionality of gocyclo
# - exhaustivestruct - breaks "Make the zero value useful" proverb, meant to be used only for special cases
# - funlen - not needed - gocyclo ensures that functions complexity is not too high
# - godox - requires all TODOs to be removed - too strict
# - golint - deprecated (since v1.41.0) due to: The repository of the linter has been archived by the owner
# - gomoddirectives - does not allow "replace" directives - too strict
# - goerr113 - following check is too strict: "do not define dynamic errors, use wrapped static errors instead",
# the check cannot be disabled
# - interfacer - deprecated (since v1.38.0) due to: The repository of the linter has been archived by the owner
# - maligned - deprecated (since v1.38.0) due to: The repository of the linter has been archived by the owner
# - nlreturn - leads to using too many line breaks
# - paralleltest - premature optimization
# - prealloc - considered a premature optimization.
# - scopelint - deprecated (since v1.39.0) due to: The repository of the linter has been deprecated by the owner
# - thelper - enforcing t.Helper() everywhere is too strict
# - wrapcheck - valuable linter, TODO: ignore false-positives (interfaces, internal imports) and adjust the code to comply
# - wsl - leads to using too many line breaks
linters:
enable:
- asciicheck
- bodyclose
- deadcode
- depguard
- dogsled
- dupl
- durationcheck
- errcheck
- errorlint
- exhaustive
- exportloopref
- forbidigo
- forcetypeassert
- gci
- gochecknoglobals
- gochecknoinits
- gocognit
- goconst
- gocritic
- gocyclo
- godot
- gofmt
- gofumpt
- goheader
- goimports
- gomnd
- gomodguard
- goprintffuncname
- gosec
- gosimple
- govet
- ifshort
- importas
- ineffassign
- lll
- makezero
- misspell
- nakedret
- nestif
- nilerr
- noctx
- nolintlint
- predeclared
- revive
- rowserrcheck
- sqlclosecheck
- staticcheck
- structcheck
- stylecheck
- testpackage
- tparallel
- typecheck
- unconvert
- unparam
- unused
- varcheck
- wastedassign
- whitespace

linters-settings:
errcheck:
check-type-assertions: true
check-blank: true
errorlint:
# Check whether fmt.Errorf uses the %w verb for formatting errors - too strict
errorf: false
gocyclo:
min-complexity: 10
govet:
disable:
# Reordering struct fields may decrease readability
- fieldalignment
enable-all: true
lll:
# TODO: 120 (default) should be achieved to increase comfort of window split view
line-length: 127
nakedret:
max-func-lines: 5
10 changes: 5 additions & 5 deletions apiv6/examples/cloud_export/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func runCRUD(client *kentikapi.Client) error {
createReqPayload := *cloudexport.NewV202101beta1CreateCloudExportRequest()
createReqPayload.Export = export

createResp, httpResp, err := client.CloudExportAdminServiceApi.
createResp, httpResp, err := client.CloudExportAdminServiceAPI.
ExportCreate(context.Background()).
Body(createReqPayload).
Execute()
Expand All @@ -57,7 +57,7 @@ func runCRUD(client *kentikapi.Client) error {
updateReqPayload := *cloudexport.NewV202101beta1UpdateCloudExportRequest()
updateReqPayload.Export = created

updateResp, httpResp, err := client.CloudExportAdminServiceApi.
updateResp, httpResp, err := client.CloudExportAdminServiceAPI.
ExportUpdate(context.Background(), *created.Id).
Body(updateReqPayload).
Execute()
Expand All @@ -68,7 +68,7 @@ func runCRUD(client *kentikapi.Client) error {
fmt.Println()

fmt.Println("### GET")
getResp, httpResp, err := client.CloudExportAdminServiceApi.
getResp, httpResp, err := client.CloudExportAdminServiceAPI.
ExportGet(context.Background(), *created.Id).
Execute()
if err != nil {
Expand All @@ -78,7 +78,7 @@ func runCRUD(client *kentikapi.Client) error {
fmt.Println()

fmt.Println("### DELETE")
deleteResp, httpResp, err := client.CloudExportAdminServiceApi.
deleteResp, httpResp, err := client.CloudExportAdminServiceAPI.
ExportDelete(context.Background(), *created.Id).
Execute()
if err != nil {
Expand All @@ -93,7 +93,7 @@ func runCRUD(client *kentikapi.Client) error {

func runGetAll(client *kentikapi.Client) error {
fmt.Println("### GET ALL")
getAllResp, httpResp, err := client.CloudExportAdminServiceApi.
getAllResp, httpResp, err := client.CloudExportAdminServiceAPI.
ExportList(context.Background()).
Execute()
if err != nil {
Expand Down
10 changes: 5 additions & 5 deletions apiv6/examples/demos/cloud_export_demo/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func createCloudExport(client *kentikapi.Client) string {
createReqPayload := *cloudexport.NewV202101beta1CreateCloudExportRequest()
createReqPayload.Export = export

createResp, _, err := client.CloudExportAdminServiceApi.
createResp, _, err := client.CloudExportAdminServiceAPI.
ExportCreate(context.Background()).
Body(createReqPayload).
Execute()
Expand All @@ -56,7 +56,7 @@ func createCloudExport(client *kentikapi.Client) string {
func getCloudExport(client *kentikapi.Client, id string) *cloudexport.V202101beta1CloudExport {
fmt.Printf("Retrieving cloud export of ID = %s\n", id)

getResp, _, err := client.CloudExportAdminServiceApi.
getResp, _, err := client.CloudExportAdminServiceAPI.
ExportGet(context.Background(), id).
Execute()
demos.ExitOnError(err)
Expand All @@ -70,7 +70,7 @@ func updateCloudExport(client *kentikapi.Client, export *cloudexport.V202101beta
updateReqPayload := *cloudexport.NewV202101beta1UpdateCloudExportRequest()
updateReqPayload.Export = export

updateResp, _, err := client.CloudExportAdminServiceApi.
updateResp, _, err := client.CloudExportAdminServiceAPI.
ExportUpdate(context.Background(), *export.Id).
Body(updateReqPayload).
Execute()
Expand All @@ -81,7 +81,7 @@ func updateCloudExport(client *kentikapi.Client, export *cloudexport.V202101beta

func deleteCloudExport(client *kentikapi.Client, id string) {
fmt.Printf("Deleting cloud export of ID = %s\n", id)
deleteResp, _, err := client.CloudExportAdminServiceApi.
deleteResp, _, err := client.CloudExportAdminServiceAPI.
ExportDelete(context.Background(), id).
Execute()
demos.ExitOnError(err)
Expand All @@ -91,7 +91,7 @@ func deleteCloudExport(client *kentikapi.Client, id string) {
}

func getAllCloudExports(client *kentikapi.Client) {
getAllResp, _, err := client.CloudExportAdminServiceApi.
getAllResp, _, err := client.CloudExportAdminServiceAPI.
ExportList(context.Background()).
Execute()
demos.ExitOnError(err)
Expand Down
2 changes: 1 addition & 1 deletion apiv6/examples/demos/retry_demo/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func showRetryingOnMultipleCodes() error {
})

demos.Step("List synthetic agents")
result, _, err := c.SyntheticsAdminServiceApi.
result, _, err := c.SyntheticsAdminServiceAPI.
AgentsList(context.Background()).
Execute()

Expand Down
24 changes: 12 additions & 12 deletions apiv6/examples/synthetics/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func runCRUDTest(client *kentikapi.Client) error {
createReqPayload := *synthetics.NewV202101beta1CreateTestRequest()
createReqPayload.SetTest(*test)

createResp, httpResp, err := client.SyntheticsAdminServiceApi.
createResp, httpResp, err := client.SyntheticsAdminServiceAPI.
TestCreate(context.Background()).
Body(createReqPayload).
Execute()
Expand All @@ -82,7 +82,7 @@ func runCRUDTest(client *kentikapi.Client) error {
setStatusReqPayload.Status = &status
setStatusReqPayload.Id = &testID

statusResp, httpResp, err := client.SyntheticsAdminServiceApi.
statusResp, httpResp, err := client.SyntheticsAdminServiceAPI.
TestStatusUpdate(context.Background(), testID).
Body(setStatusReqPayload).
Execute()
Expand All @@ -94,7 +94,7 @@ func runCRUDTest(client *kentikapi.Client) error {
fmt.Println()

fmt.Println("### GET TEST")
getReq := client.SyntheticsAdminServiceApi.TestGet(context.Background(), testID)
getReq := client.SyntheticsAdminServiceAPI.TestGet(context.Background(), testID)
getResp, httpResp, err := getReq.Execute()
if err != nil {
return fmt.Errorf("%v %v", err, httpResp)
Expand All @@ -112,7 +112,7 @@ func runCRUDTest(client *kentikapi.Client) error {
patchReqPayload.SetTest(*test)
patchReqPayload.SetMask("test.name")

patchResp, httpResp, err := client.SyntheticsAdminServiceApi.
patchResp, httpResp, err := client.SyntheticsAdminServiceAPI.
TestPatch(context.Background(), *test.Id).
Body(patchReqPayload).
Execute()
Expand All @@ -123,7 +123,7 @@ func runCRUDTest(client *kentikapi.Client) error {
fmt.Println()

fmt.Println("### DELETE TEST")
deleteReq := client.SyntheticsAdminServiceApi.TestDelete(context.Background(), testID)
deleteReq := client.SyntheticsAdminServiceAPI.TestDelete(context.Background(), testID)
deleteResp, httpResp, err := deleteReq.Execute()
if err != nil {
return fmt.Errorf("%v %v", err, httpResp)
Expand All @@ -138,7 +138,7 @@ func runCRUDTest(client *kentikapi.Client) error {
func runListTests(client *kentikapi.Client) error {
fmt.Println("### LIST TESTS")

getAllReq := client.SyntheticsAdminServiceApi.TestsList(context.Background())
getAllReq := client.SyntheticsAdminServiceAPI.TestsList(context.Background())
getAllResp, httpResp, err := getAllReq.Execute()
if err != nil {
return fmt.Errorf("%v %v", err, httpResp)
Expand Down Expand Up @@ -167,7 +167,7 @@ func runGetHealthForTests(client *kentikapi.Client, testIDs []string) error {
healthPayload.SetEndTime(time.Now())
healthPayload.SetIds(testIDs)

getHealthResp, httpResp, err := client.SyntheticsDataServiceApi.
getHealthResp, httpResp, err := client.SyntheticsDataServiceAPI.
GetHealthForTests(context.Background()).
Body(healthPayload).
Execute()
Expand Down Expand Up @@ -195,7 +195,7 @@ func runGetTraceForTest(client *kentikapi.Client, testID string) error {
tracePayload.SetStartTime(time.Now().Add(-time.Hour))
tracePayload.SetEndTime(time.Now())

getTraceResp, httpResp, err := client.SyntheticsDataServiceApi.
getTraceResp, httpResp, err := client.SyntheticsDataServiceAPI.
GetTraceForTest(context.Background(), testID).
Body(tracePayload).
Execute()
Expand Down Expand Up @@ -230,7 +230,7 @@ func runCRUDAgent(client *kentikapi.Client) error {
agentID := "1717"

fmt.Println("### GET AGENT")
getReq := client.SyntheticsAdminServiceApi.AgentGet(context.Background(), agentID)
getReq := client.SyntheticsAdminServiceAPI.AgentGet(context.Background(), agentID)
getResp, httpResp, err := getReq.Execute()
if err != nil {
return fmt.Errorf("%v %v", err, httpResp)
Expand All @@ -249,7 +249,7 @@ func runCRUDAgent(client *kentikapi.Client) error {
patchReqPayload.SetAgent(agent)
patchReqPayload.SetMask("agent.family")

patchResp, httpResp, err := client.SyntheticsAdminServiceApi.
patchResp, httpResp, err := client.SyntheticsAdminServiceAPI.
AgentPatch(context.Background(), agentID).
Body(patchReqPayload).
Execute()
Expand All @@ -261,7 +261,7 @@ func runCRUDAgent(client *kentikapi.Client) error {

// NOTE: as we can't create agents through the API - let's not delete them
// fmt.Println("### DELETE AGENT")
// deleteReq := client.SyntheticsAdminServiceApi.AgentDelete(context.Background(), agentID)
// deleteReq := client.SyntheticsAdminServiceAPI.AgentDelete(context.Background(), agentID)
// deleteResp, httpResp, err := deleteReq.Execute()
// if err != nil {
// return fmt.Errorf("%v %v", err, httpResp)
Expand All @@ -276,7 +276,7 @@ func runCRUDAgent(client *kentikapi.Client) error {
func runListAgents(client *kentikapi.Client) error {
fmt.Println("### LIST AGENTS")

getAllReq := client.SyntheticsAdminServiceApi.AgentsList(context.Background())
getAllReq := client.SyntheticsAdminServiceAPI.AgentsList(context.Background())
getAllResp, httpResp, err := getAllReq.Execute()
if err != nil {
return fmt.Errorf("%v %v", err, httpResp)
Expand Down
2 changes: 1 addition & 1 deletion apiv6/examples/synthetics/mesh_test/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func getMeshTestResults(testID string) *[]synthetics.V202101beta1MeshResponse {
healthPayload.SetIds([]string{testID})
healthPayload.SetAugment(true) // if not set, returned Mesh pointer will be empty

getHealthResp, httpResp, err := client.SyntheticsDataServiceApi.
getHealthResp, httpResp, err := client.SyntheticsDataServiceAPI.
GetHealthForTests(context.Background()).
Body(healthPayload).
Execute()
Expand Down
13 changes: 7 additions & 6 deletions apiv6/kentikapi/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/kentik/community_sdk_golang/apiv6/kentikapi/synthetics"
)

//nolint:gosec
const (
authAPITokenKey = "X-CH-Auth-API-Token"
authEmailKey = "X-CH-Auth-Email"
Expand All @@ -16,11 +17,11 @@ const (
// Client is the root object for manipulating all the Kentik API resources.
type Client struct {
// cloudexport
CloudExportAdminServiceApi *cloudexport.CloudExportAdminServiceApiService
CloudExportAdminServiceAPI *cloudexport.CloudExportAdminServiceApiService

// synthetics
SyntheticsAdminServiceApi *synthetics.SyntheticsAdminServiceApiService
SyntheticsDataServiceApi *synthetics.SyntheticsDataServiceApiService
SyntheticsAdminServiceAPI *synthetics.SyntheticsAdminServiceApiService
SyntheticsDataServiceAPI *synthetics.SyntheticsDataServiceApiService
}

// Config holds configuration of the Client.
Expand Down Expand Up @@ -52,9 +53,9 @@ func NewClient(c Config) *Client {
syntheticsClient := synthetics.NewAPIClient(makeSyntheticsConfig(c))

return &Client{
CloudExportAdminServiceApi: cloudexportClient.CloudExportAdminServiceApi,
SyntheticsAdminServiceApi: syntheticsClient.SyntheticsAdminServiceApi,
SyntheticsDataServiceApi: syntheticsClient.SyntheticsDataServiceApi,
CloudExportAdminServiceAPI: cloudexportClient.CloudExportAdminServiceApi,
SyntheticsAdminServiceAPI: syntheticsClient.SyntheticsAdminServiceApi,
SyntheticsDataServiceAPI: syntheticsClient.SyntheticsDataServiceApi,
}
}

Expand Down
Loading