Showing 247 of 615 total issues
File container_test.go
has 617 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
Function ExportedFields
has a Cognitive Complexity of 46 (exceeds 20 allowed). Consider refactoring. Open
func ExportedFields(input interface{}) (exported []*ExportedField, err error) {
nonEmbeddedFields := make(map[string]struct{})
embeddedFields := make(map[string][]*ExportedField)
if nil == input {
return exported, ErrNilStruct
- 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 Group.Apply
has 138 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (g *Group) Apply(context.Context) (resource.TaskStatus, error) {
var (
groupByGid *user.Group
gidErr error
newNameErr error
Method Group.Check
has a Cognitive Complexity of 45 (exceeds 20 allowed). Consider refactoring. Open
func (g *Group) Check(context.Context, resource.Renderer) (resource.TaskStatus, error) {
var (
groupByGid *user.Group
gidErr error
groupByNewName *user.Group
- 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 Group.Check
has 130 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (g *Group) Check(context.Context, resource.Renderer) (resource.TaskStatus, error) {
var (
groupByGid *user.Group
gidErr error
groupByNewName *user.Group
Graph
has 33 methods (exceeds 20 allowed). Consider refactoring. Open
type Graph struct {
inner *dag.AcyclicGraph
values cmap.ConcurrentMap
innerLock *sync.RWMutex
Function dependencyWalk
has 127 lines of code (exceeds 50 allowed). Consider refactoring. Open
func dependencyWalk(rctx context.Context, g *Graph, cb WalkFunc) error {
// the basic idea of this implementation is that we want to defer schedule
// children of any given node until after that node's non-child dependencies
// are satisfied. We're going to have a couple major components of this.
// First, a scheduler/latch to make sure we don't schedule work more than
File fetch_test.go
has 579 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
Function TestCheck
has 116 lines of code (exceeds 50 allowed). Consider refactoring. Open
func TestCheck(t *testing.T) {
t.Parallel()
t.Run("state=present", func(t *testing.T) {
u := user.NewUser(new(user.System))
Function TestShouldEvaluate
has 115 lines of code (exceeds 50 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) {
Function TestContainerCheck
has 40 return statements (exceeds 4 allowed). Open
func TestContainerCheck(t *testing.T) {
t.Parallel()
defer logging.HideLogs(t)()
t.Run("container not found", func(t *testing.T) {
Function TestPrepare
has 108 lines of code (exceeds 50 allowed). Consider refactoring. Open
func TestPrepare(t *testing.T) {
t.Parallel()
fr := fakerenderer.FakeRenderer{}
var invalidID = uint32(math.MaxUint32)
Function TestVolumeApply
has 107 lines of code (exceeds 50 allowed). Consider refactoring. Open
func TestVolumeApply(t *testing.T) {
t.Parallel()
defer logging.HideLogs(t)()
t.Run("docker find volume error", func(t *testing.T) {
Function TestSetDirsAndContents
has 106 lines of code (exceeds 50 allowed). Consider refactoring. Open
func TestSetDirsAndContents(t *testing.T) {
t.Parallel()
srcFile, err := ioutil.TempFile("", "unarchive_test.zip")
require.NoError(t, err)
Function TestNetworkApply
has 106 lines of code (exceeds 50 allowed). Consider refactoring. Open
func TestNetworkApply(t *testing.T) {
t.Parallel()
defer logging.HideLogs(t)()
nwName := "test-network"
Function TestVolumeCheck
has 103 lines of code (exceeds 50 allowed). Consider refactoring. Open
func TestVolumeCheck(t *testing.T) {
t.Parallel()
defer logging.HideLogs(t)()
t.Run("state: absent", func(t *testing.T) {
Method User.DiffMod
has a Cognitive Complexity of 37 (exceeds 20 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 != "" {
- 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 TestPreparer
has 101 lines of code (exceeds 50 allowed). Consider refactoring. Open
func TestPreparer(t *testing.T) {
t.Parallel()
t.Run("sets-signal-when-signal-name", func(t *testing.T) {
t.Parallel()
Function TestGetFailedReason
has 98 lines of code (exceeds 50 allowed). Consider refactoring. Open
func TestGetFailedReason(t *testing.T) {
t.Parallel()
t.Run("returns-error-when-no-properties", func(t *testing.T) {
t.Parallel()
Function TestCheck
has a Cognitive Complexity of 36 (exceeds 20 allowed). Consider refactoring. Open
func TestCheck(t *testing.T) {
t.Parallel()
t.Run("state=present", func(t *testing.T) {
u := user.NewUser(new(user.System))
- 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"