asteris-llc/converge

View on GitHub

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) {
Severity: Minor
Found in graph/node/conditional/conditional_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

File conditional_test.go has 537 lines of code (exceeds 500 allowed). Consider refactoring.
Open

package conditional_test

import (
    "errors"
    "fmt"
Severity: Minor
Found in graph/node/conditional/conditional_test.go - About 2 hrs to fix

    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)
    Severity: Major
    Found in rpc/jwt_test.go - About 2 hrs to fix

      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)
      Severity: Minor
      Found in resource/user/user.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

      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")
      Severity: Minor
      Found in resource/lvm/vg/vg.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

      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) {
      Severity: Major
      Found in parse/node_test.go - About 2 hrs to fix

        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) {
        Severity: Major
        Found in resource/field_extractor_test.go - About 2 hrs to fix

          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
              }
          
          
          Severity: Minor
          Found in docs/extract.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

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

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

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

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

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

                    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)
                    
                    
                    Severity: Major
                    Found in resource/file/directory/directory_test.go - About 2 hrs to fix

                      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")}
                      Severity: Major
                      Found in resource/file/owner/owner_test.go - About 2 hrs to fix

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

                          Preparer has 21 methods (exceeds 20 allowed). Consider refactoring.
                          Open

                          type Preparer struct {
                              Source      map[string]interface{}
                              Destination Resource
                          }
                          Severity: Minor
                          Found in resource/preparer.go - About 2 hrs to fix

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

                              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, ",")
                              Severity: Minor
                              Found in resource/preparer.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

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