Showing 247 of 615 total issues
Method Container.diffContainer
has 75 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (c *Container) diffContainer(container *dc.Container, status *resource.Status) error {
expectedStatus := strings.ToLower(c.CStatus)
if expectedStatus == "" {
expectedStatus = containerStatusRunning
}
Function TestNotifyTransform
has 73 lines of code (exceeds 50 allowed). Consider refactoring. Open
func TestNotifyTransform(t *testing.T) {
g := graph.New()
g.Add(node.New("root", 1))
doNothing := func(*node.Node, *graph.Graph) error { return nil }
Method Unarchive.evaluateDuplicates
has a Cognitive Complexity of 30 (exceeds 20 allowed). Consider refactoring. Open
func (u *Unarchive) evaluateDuplicates() error {
// determine which directory has fewer items in order to minimize operations
dirA := u.destDir.Name()
dirB := u.fetchDir.Name()
filesA := u.destContents
- 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 assertCorrectTypeProperties
has 20 return statements (exceeds 4 allowed). Open
func assertCorrectTypeProperties(t *testing.T, u *Unit) {
checks := map[string]func() bool{
"service": func() bool { return u.ServiceProperties == nil },
"socket": func() bool { return u.SocketProperties == nil },
"device": func() bool { return u.DeviceProperties == nil },
Function TestCheck
has 70 lines of code (exceeds 50 allowed). Consider refactoring. Open
func TestCheck(t *testing.T) {
t.Parallel()
srcFile, err := ioutil.TempFile("", "unarchive_test.txt")
require.NoError(t, err)
Function TestNodeWithConditionals
has 69 lines of code (exceeds 50 allowed). Consider refactoring. Open
func TestNodeWithConditionals(t *testing.T) {
t.Parallel()
defer logging.HideLogs(t)()
g, err := load.Nodes(context.Background(), "../samples/conditionalLanguages.hcl", false)
require.NoError(t, err)
Function ParseSignalByName
has 69 lines of code (exceeds 50 allowed). Consider refactoring. Open
func ParseSignalByName(s string) (Signal, error) {
s = strings.ToUpper(s)
if !strings.HasPrefix(s, "SIG") {
s = "SIG" + s
}
Function newScopeTypePropertiesFromMap
has a Cognitive Complexity of 29 (exceeds 20 allowed). Consider refactoring. Open
func newScopeTypePropertiesFromMap(m map[string]interface{}) *ScopeTypeProperties {
s := &ScopeTypeProperties{}
if val, ok := m["BlockIOAccounting"]; ok {
s.BlockIOAccounting = val.(bool)
- 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 alignEdgesInGroup
has a Cognitive Complexity of 29 (exceeds 20 allowed). Consider refactoring. Open
func alignEdgesInGroup(ctx context.Context, g *graph.Graph, id, group string) (*graph.Graph, error) {
upEdges := withoutRoot(g.UpEdgesInGroup(id, group))
for i, upEdge := range upEdges {
if i > 0 {
dest := highestGroupEdge(g, upEdges[i-1], 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
Function Nodes
has a Cognitive Complexity of 29 (exceeds 20 allowed). Consider refactoring. Open
func Nodes(ctx context.Context, root string, verify bool) (*graph.Graph, error) {
logger := logging.GetLogger(ctx).WithField("function", "Nodes")
toLoad := []*source{{"root", root, root}}
- 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 newSliceTypePropertiesFromMap
has 68 lines of code (exceeds 50 allowed). Consider refactoring. Open
func newSliceTypePropertiesFromMap(m map[string]interface{}) *SliceTypeProperties {
s := &SliceTypeProperties{}
if val, ok := m["BlockIOAccounting"]; ok {
s.BlockIOAccounting = val.(bool)
Function ExportedFields
has 67 lines of code (exceeds 50 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
Method Preparer.convertNumber
has 65 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (p *Preparer) convertNumber(typ reflect.Type, r Renderer, name string, val interface{}, base int) (reflect.Value, error) {
if val == nil {
return reflect.Zero(typ), nil
}
Method User.DiffAdd
has 65 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (u *User) DiffAdd(status *resource.Status) (*AddUserOptions, error) {
options := new(AddUserOptions)
// if a group exists with the same name as the user being added, a groupname
// must also be indicated so the user may be added to that group
Function TestRenderConditionals
has 65 lines of code (exceeds 50 allowed). Consider refactoring. Open
func TestRenderConditionals(t *testing.T) {
defer logging.HideLogs(t)()
src := `
param "a" {
Method Signal.String
has 65 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (s Signal) String() string {
switch s {
case SIGHUP:
return "SIGHUP"
case SIGINT:
Method TypeExtractor.Visit
has 65 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (te *TypeExtractor) Visit(node ast.Node) (w ast.Visitor) {
if node == nil {
return nil
}
Function TestVGCheck
has 65 lines of code (exceeds 50 allowed). Consider refactoring. Open
func TestVGCheck(t *testing.T) {
t.Run("check prerequisites failure", func(t *testing.T) {
lvm, m := testhelpers.MakeFakeLvm()
m.On("Check").Return(fmt.Errorf("failed"))
_ = simpleCheckFailure(t, lvm, "vg0", []string{"/dev/sda1"}, false, false)
Method Group.Apply
has 16 return statements (exceeds 4 allowed). Open
func (g *Group) Apply(context.Context) (resource.TaskStatus, error) {
var (
groupByGid *user.Group
gidErr error
newNameErr error
Function TestQueryUnit
has 61 lines of code (exceeds 50 allowed). Consider refactoring. Open
func TestQueryUnit(t *testing.T) {
t.Parallel()
t.Run("when-verify", func(t *testing.T) {
t.Parallel()
t.Run("when-unit-exists", func(t *testing.T) {