asteris-llc/converge

View on GitHub

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
Severity: Minor
Found in resource/docker/container/container_test.go - About 4 hrs to fix

    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
    Severity: Minor
    Found in resource/field_extractor.go - About 4 hrs to fix

    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
    Severity: Major
    Found in resource/group/group.go - About 4 hrs to fix

      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
      Severity: Minor
      Found in resource/group/group.go - About 4 hrs to fix

      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
      Severity: Major
      Found in resource/group/group.go - About 4 hrs to fix

        Graph has 33 methods (exceeds 20 allowed). Consider refactoring.
        Open

        type Graph struct {
            inner  *dag.AcyclicGraph
            values cmap.ConcurrentMap
        
            innerLock *sync.RWMutex
        Severity: Minor
        Found in graph/graph.go - About 4 hrs to fix

          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
          Severity: Major
          Found in graph/graph.go - About 4 hrs to fix

            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
            Severity: Minor
            Found in resource/file/fetch/fetch_test.go - About 3 hrs to fix

              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))
              Severity: Major
              Found in resource/user/user_test.go - About 3 hrs to fix

                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) {
                Severity: Major
                Found in graph/node/conditional/conditional_test.go - About 3 hrs to fix

                  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) {
                  Severity: Major
                  Found in resource/docker/container/container_test.go - About 3 hrs to fix

                    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)
                    Severity: Major
                    Found in resource/user/preparer_test.go - About 3 hrs to fix

                      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) {
                      Severity: Major
                      Found in resource/docker/volume/volume_test.go - About 3 hrs to fix

                        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)
                        Severity: Major
                        Found in resource/unarchive/unarchive_test.go - About 3 hrs to fix

                          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"
                          Severity: Major
                          Found in resource/docker/network/network_test.go - About 3 hrs to fix

                            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) {
                            Severity: Major
                            Found in resource/docker/volume/volume_test.go - About 3 hrs to fix

                              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 != "" {
                              Severity: Minor
                              Found in resource/user/user.go - About 3 hrs to fix

                              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()
                              Severity: Major
                              Found in resource/systemd/unit/preparer_test.go - About 3 hrs to fix

                                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()
                                Severity: Major
                                Found in resource/systemd/unit/resource_test.go - About 2 hrs to fix

                                  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))
                                  Severity: Minor
                                  Found in resource/user/user_test.go - About 2 hrs to fix

                                  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

                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language