Showing 247 of 615 total issues
Function TestShouldEvaluate
has a Cognitive Complexity of 36 (exceeds 20 allowed). Consider refactoring. Open
func TestShouldEvaluate(t *testing.T) {
t.Run("when-many-branches", func(t *testing.T) {
g := peerBranchSampleGraph(t)
resources := []string{"resource1", "resource2", "resource3"}
t.Run("when-true-true-true", func(t *testing.T) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
File conditional_test.go
has 537 lines of code (exceeds 500 allowed). Consider refactoring. Open
package conditional_test
import (
"errors"
"fmt"
Function TestJWTAuth
has 94 lines of code (exceeds 50 allowed). Consider refactoring. Open
func TestJWTAuth(t *testing.T) {
t.Parallel()
secret := "secret"
token := rpc.NewJWTAuth(secret)
Method User.Apply
has a Cognitive Complexity of 35 (exceeds 20 allowed). Consider refactoring. Open
func (u *User) Apply(context.Context) (resource.TaskStatus, error) {
// lookup the user by name
// ErrUnsupported is returned if the system is not supported
// Lookup returns user.UnknownUserError if the user is not found
userByName, nameErr := u.system.Lookup(u.Username)
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method resourceVG.Check
has a Cognitive Complexity of 35 (exceeds 20 allowed). Consider refactoring. Open
func (r *resourceVG) Check(context.Context, resource.Renderer) (resource.TaskStatus, error) {
status := &resource.Status{}
if err := r.lvm.Check(); err != nil {
return nil, errors.Wrap(err, "lvm.volumegroup")
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function TestNodeValidateName
has 93 lines of code (exceeds 50 allowed). Consider refactoring. Open
func TestNodeValidateName(t *testing.T) {
t.Parallel()
t.Run("when valid", func(t *testing.T) {
t.Parallel()
t.Run("alpha", func(t *testing.T) {
Function TestExportedFields
has 92 lines of code (exceeds 50 allowed). Consider refactoring. Open
func TestExportedFields(t *testing.T) {
t.Parallel()
t.Run("exported-fields", func(t *testing.T) {
t.Parallel()
t.Run("when-value", func(t *testing.T) {
Method TypeExtractor.Visit
has a Cognitive Complexity of 34 (exceeds 20 allowed). Consider refactoring. Open
func (te *TypeExtractor) Visit(node ast.Node) (w ast.Visitor) {
if node == nil {
return nil
}
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function newScopeTypePropertiesFromMap
has 89 lines of code (exceeds 50 allowed). Consider refactoring. Open
func newScopeTypePropertiesFromMap(m map[string]interface{}) *ScopeTypeProperties {
s := &ScopeTypeProperties{}
if val, ok := m["BlockIOAccounting"]; ok {
s.BlockIOAccounting = val.(bool)
Function TestReloadUnit
has 87 lines of code (exceeds 50 allowed). Consider refactoring. Open
func TestReloadUnit(t *testing.T) {
t.Parallel()
t.Run("call-reload-unit", func(t *testing.T) {
t.Parallel()
u := randomUnit(UnitTypeService)
Function TestStopUnit
has 87 lines of code (exceeds 50 allowed). Consider refactoring. Open
func TestStopUnit(t *testing.T) {
t.Parallel()
t.Run("call-stop-unit", func(t *testing.T) {
t.Parallel()
u := randomUnit(UnitTypeService)
Function TestRestartUnit
has 87 lines of code (exceeds 50 allowed). Consider refactoring. Open
func TestRestartUnit(t *testing.T) {
t.Parallel()
t.Run("call-restart-unit", func(t *testing.T) {
t.Parallel()
u := randomUnit(UnitTypeService)
Function TestStartUnit
has 87 lines of code (exceeds 50 allowed). Consider refactoring. Open
func TestStartUnit(t *testing.T) {
t.Parallel()
t.Run("call-start-unit", func(t *testing.T) {
t.Parallel()
u := randomUnit(UnitTypeService)
Function TestDirectoryCheck
has 84 lines of code (exceeds 50 allowed). Consider refactoring. Open
func TestDirectoryCheck(t *testing.T) {
tmpDir, err := ioutil.TempDir("", "converge-directory-check")
require.NoError(t, err)
defer os.RemoveAll(tmpDir)
Function TestApply
has 82 lines of code (exceeds 50 allowed). Consider refactoring. Open
func TestApply(t *testing.T) {
t.Parallel()
t.Run("single-diff", func(t *testing.T) {
users := []*user.User{fakeUser("1", "1", "user-1"), fakeUser("2", "2", "user-2")}
groups := []*user.Group{fakeGroup("1", "group-1"), fakeGroup("2", "group-2")}
File graph_test.go
has 511 lines of code (exceeds 500 allowed). Consider refactoring. Open
// Copyright © 2016 Asteris, LLC
//
// 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
Preparer
has 21 methods (exceeds 20 allowed). Consider refactoring. Open
type Preparer struct {
Source map[string]interface{}
Destination Resource
}
Method User.DiffMod
has 79 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (u *User) DiffMod(status *resource.Status, currUser *user.User) (*ModUserOptions, error) {
options := new(ModUserOptions)
// Check for differences between currUser and the desired modifications
if u.NewUsername != "" {
Method Preparer.validateMutuallyExclusive
has a Cognitive Complexity of 31 (exceeds 20 allowed). Consider refactoring. Open
func (p *Preparer) validateMutuallyExclusive(field reflect.StructField) error {
if mutuallyexclusives, ok := field.Tag.Lookup("mutually_exclusive"); ok {
name := p.getFieldName(field)
exclusives := strings.Split(mutuallyexclusives, ",")
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function TestDiffDel
has 76 lines of code (exceeds 50 allowed). Consider refactoring. Open
func TestDiffDel(t *testing.T) {
t.Parallel()
t.Run("user does not exist", func(t *testing.T) {
u := user.NewUser(new(user.System))