asteris-llc/converge

View on GitHub

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

    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 }
    Severity: Minor
    Found in graph/notifier_test.go - About 1 hr to fix

      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
      Severity: Minor
      Found in resource/unarchive/unarchive.go - About 1 hr 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 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 },
      Severity: Major
      Found in resource/systemd/unit/utils_linux_test.go - About 1 hr to fix

        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)
        Severity: Minor
        Found in resource/unarchive/unarchive_test.go - About 1 hr to fix

          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)
          Severity: Minor
          Found in load/nodes_test.go - About 1 hr to fix

            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
                }
            Severity: Minor
            Found in resource/systemd/unit/signals.go - About 1 hr to fix

              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)
              Severity: Minor
              Found in resource/systemd/unit/systemd_properties.go - About 1 hr 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 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)
              Severity: Minor
              Found in load/dependencyresolver.go - About 1 hr 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 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}}
              
              
              Severity: Minor
              Found in load/nodes.go - About 1 hr 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 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)
              Severity: Minor
              Found in resource/systemd/unit/systemd_properties.go - About 1 hr to fix

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

                  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
                      }
                  
                  
                  Severity: Minor
                  Found in resource/preparer.go - About 1 hr to fix

                    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
                    Severity: Minor
                    Found in resource/user/user.go - About 1 hr to fix

                      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" {
                      Severity: Minor
                      Found in render/render_test.go - About 1 hr to fix

                        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:
                        Severity: Minor
                        Found in resource/systemd/unit/signals.go - About 1 hr to fix

                          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
                              }
                          
                          
                          Severity: Minor
                          Found in docs/extract.go - About 1 hr to fix

                            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)
                            Severity: Minor
                            Found in resource/lvm/vg/vg_test.go - About 1 hr to fix

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

                                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) {
                                Severity: Minor
                                Found in resource/systemd/unit/systemd_linux_test.go - About 1 hr to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language