Skip to content
Snippets Groups Projects
Commit fd7c7a12 authored by Fabian Seidl's avatar Fabian Seidl
Browse files

more linters, also spellchecker with autofix

parent 6858f7da
No related branches found
No related tags found
1 merge request!363Resolve "Improve security by enabling and enforcing more linting rules"
Pipeline #110724 passed
This commit is part of merge request !363. Comments created here will be created in the context of that merge request.
...@@ -33,7 +33,8 @@ issues: ...@@ -33,7 +33,8 @@ issues:
linters: linters:
# enable the specific needed linters # enable the specific needed linters
# see here for full list: https://golangci-lint.run/usage/linters/ # see here for full list: https://golangci-lint.run/usage/linters/
# linters to consider: gosimple, containedctx, contextcheck, depguard, errname, exhaustive, exhaustruct, forbidigo, forcetypeassert, forcetypeassert, gochecknoinits, gocognit, goconst # linters to consider: gosimple, containedctx, contextcheck, depguard, errname, exhaustive, exhaustruct, forbidigo, forcetypeassert,
# forcetypeassert, gochecknoinits, gocognit, goconst, godot, gofumpt, gomnd, gosec, lll
disable-all: true disable-all: true
enable: enable:
- gofmt - gofmt
...@@ -55,6 +56,10 @@ linters: ...@@ -55,6 +56,10 @@ linters:
- errchkjson - errchkjson
- errorlint - errorlint
- exportloopref - exportloopref
- grouper
- importas
- makezero
- misspell
# custom settings for linters # custom settings for linters
linters-settings: linters-settings:
......
...@@ -64,7 +64,7 @@ var changeListCmd = &cobra.Command{ ...@@ -64,7 +64,7 @@ var changeListCmd = &cobra.Command{
data = append(data, []string{ch.String(), "pending"}) data = append(data, []string{ch.String(), "pending"})
} }
for _, ch := range committed { for _, ch := range committed {
data = append(data, []string{ch.String(), "commited"}) data = append(data, []string{ch.String(), "committed"})
} }
spinner.Success() spinner.Success()
......
...@@ -69,7 +69,7 @@ The device UUID and request path must be specified as a positional arguments.`, ...@@ -69,7 +69,7 @@ The device UUID and request path must be specified as a positional arguments.`,
if r.Status == ppb.Status_STATUS_OK { if r.Status == ppb.Status_STATUS_OK {
spinner.Success("A change for path deletion for Device: ", did.String(), "has been created -> Change ID: ", r.GetId()) spinner.Success("A change for path deletion for Device: ", did.String(), "has been created -> Change ID: ", r.GetId())
} else { } else {
spinner.Fail("An error occured while creating a path deletion request for Device with ID: ", r.GetId(), r.GetStatus()) spinner.Fail("An error occurred while creating a path deletion request for Device with ID: ", r.GetId(), r.GetStatus())
} }
} }
return nil return nil
......
...@@ -12,7 +12,7 @@ import ( ...@@ -12,7 +12,7 @@ import (
) )
var ( var (
// YangSchemaCompletionSeperator is the seperator for yang schemas // YangSchemaCompletionSeperator is the separator for yang schemas
YangSchemaCompletionSeperator = string([]byte{' ', '/'}) YangSchemaCompletionSeperator = string([]byte{' ', '/'})
) )
......
...@@ -161,7 +161,7 @@ func createTestRoles(roleService rbacInterfaces.RoleService) error { ...@@ -161,7 +161,7 @@ func createTestRoles(roleService rbacInterfaces.RoleService) error {
} }
// This is needed as a workaround for a bug where the output of the getUser test falsely was // This is needed as a workaround for a bug where the output of the getUser test falsely was
// that it failed while actually passing. Apparantely, this can happen when loggers write // that it failed while actually passing. Apparently, this can happen when loggers write
// the output of test cases. // the output of test cases.
// Solution found here: https://github.com/gotestyourself/gotestsum/issues/141#issuecomment-686243110 // Solution found here: https://github.com/gotestyourself/gotestsum/issues/141#issuecomment-686243110
func patchLogger(t *testing.T) { func patchLogger(t *testing.T) {
......
...@@ -81,7 +81,7 @@ func (c *Change) ID() uuid.UUID { ...@@ -81,7 +81,7 @@ func (c *Change) ID() uuid.UUID {
// and starts the timeout-timer for the Change. If the timer expires // and starts the timeout-timer for the Change. If the timer expires
// the change is rolled back. // the change is rolled back.
func (c *Change) Commit() error { func (c *Change) Commit() error {
//TODO: check if already commited //TODO: check if already committed
c.stateIn <- ppb.ChangeState_CHANGE_STATE_COMMITTED c.stateIn <- ppb.ChangeState_CHANGE_STATE_COMMITTED
select { select {
case err := <-c.errChan: case err := <-c.errChan:
...@@ -132,7 +132,7 @@ func stateManager(ctx context.Context, ch *Change, timeout time.Duration) (chan< ...@@ -132,7 +132,7 @@ func stateManager(ctx context.Context, ch *Change, timeout time.Duration) (chan<
stateIn := make(chan ppb.ChangeState) stateIn := make(chan ppb.ChangeState)
stateOut := make(chan ppb.ChangeState) stateOut := make(chan ppb.ChangeState)
// A Goroutine, which is created while a new Change is initialized acts as // A Goroutine, which is created while a new Change is initialized acts as
// the reciever for errorChan // the receiver for errorChan
errChan := make(chan error) errChan := make(chan error)
// create ticker and make it wait for 1 week // create ticker and make it wait for 1 week
// workaround for delayed ticker start and ugly housekeeping // workaround for delayed ticker start and ugly housekeeping
......
...@@ -160,7 +160,7 @@ func (e ErrTypeNotSupported) Error() string { ...@@ -160,7 +160,7 @@ func (e ErrTypeNotSupported) Error() string {
} }
// ErrCouldNotMarshall implements Error interface and is called if a // ErrCouldNotMarshall implements Error interface and is called if a
// database respone can not be parsed. // database response can not be parsed.
type ErrCouldNotMarshall struct { type ErrCouldNotMarshall struct {
Identifier any Identifier any
Type any Type any
......
...@@ -302,7 +302,7 @@ func (pnd *pndImplementation) UpdateDevice(device device.Device, modelAsString s ...@@ -302,7 +302,7 @@ func (pnd *pndImplementation) UpdateDevice(device device.Device, modelAsString s
return err return err
} }
// Actual implementation, bind to struct if neccessary // Actual implementation, bind to struct if necessary
func destroy() error { func destroy() error {
return nil return nil
} }
......
...@@ -68,7 +68,7 @@ func processEntry(e *yang.Entry) *Element { ...@@ -68,7 +68,7 @@ func processEntry(e *yang.Entry) *Element {
return leaf return leaf
} }
// Strings constructs a slice containg all possible root to leaf paths. // Strings constructs a slice containing all possible root to leaf paths.
// Calls stringBuilder internally // Calls stringBuilder internally
func Strings(paths map[string]*Element) []string { func Strings(paths map[string]*Element) []string {
ch := make(chan string) ch := make(chan string)
......
...@@ -67,7 +67,7 @@ func (s server) Get(ctx context.Context, req *pb.GetRequest) (*pb.GetResponse, e ...@@ -67,7 +67,7 @@ func (s server) Get(ctx context.Context, req *pb.GetRequest) (*pb.GetResponse, e
} }
// Create creates a new cSBI; this includes generating a deployment, building // Create creates a new cSBI; this includes generating a deployment, building
// the container, generating gostructs from the devices capabilites. // the container, generating gostructs from the devices capabilities.
func (s server) Create(ctx context.Context, req *pb.CreateRequest) (*pb.CreateResponse, error) { func (s server) Create(ctx context.Context, req *pb.CreateRequest) (*pb.CreateResponse, error) {
labels := prometheus.Labels{"rpc": "create"} labels := prometheus.Labels{"rpc": "create"}
start := promStartHook(labels, grpcRequestsTotal) start := promStartHook(labels, grpcRequestsTotal)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment