asteris-llc/converge

View on GitHub

Showing 247 of 615 total issues

Method User.Apply has 61 lines of code (exceeds 50 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 1 hr to fix

    Function TestRetryUntil has 61 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func TestRetryUntil(t *testing.T) {
        t.Parallel()
        defer logging.HideLogs(t)()
    
        t.Run("sets retry count", func(t *testing.T) {
    Severity: Minor
    Found in resource/wait/retrier_test.go - About 1 hr to fix

      Function TestVGApply has 61 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func TestVGApply(t *testing.T) {
          t.Run("single device", func(t *testing.T) {
              lvm, m := testhelpers.MakeFakeLvmEmpty()
              m.On("CreateVolumeGroup", mock.Anything, mock.Anything).Return(nil)
      
      
      Severity: Minor
      Found in resource/lvm/vg/vg_test.go - About 1 hr to fix

        Function Nodes has 61 lines of code (exceeds 50 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

          Method Printer.Show has a Cognitive Complexity of 27 (exceeds 20 allowed). Consider refactoring.
          Open

          func (p Printer) Show(ctx context.Context, g *graph.Graph) (string, error) {
              outputBuffer := new(bytes.Buffer)
              write := func(s Renderable) { outputBuffer.WriteString(s.String()) }
          
              subgraphs := makeSubgraphMap()
          Severity: Minor
          Found in prettyprinters/prettyprinter.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

          Method Renderer.lookup has 60 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          func (r *Renderer) lookup(name string) (string, error) {
              g := r.Graph()
              // fully-qualified graph name
              fqgn := graph.SiblingID(r.ID, name)
          
          
          Severity: Minor
          Found in render/renderer.go - About 1 hr to fix

            Function dependencyWalk has 14 return statements (exceeds 4 allowed).
            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 1 hr to fix

              Function TestLoadSwitch has 58 lines of code (exceeds 50 allowed). Consider refactoring.
              Open

              func TestLoadSwitch(t *testing.T) {
                  var sampleStatement = `
              switch "named-switch" {
                  case "eq 1 0" "a" {
                      task.query "foo" {
              Severity: Minor
              Found in parse/preprocessor/switch/switch_test.go - About 1 hr to fix

                Method Group.Check has 13 return statements (exceeds 4 allowed).
                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 1 hr to fix

                  Function TestDependencyResolverResolvesGroupDependencies has a Cognitive Complexity of 26 (exceeds 20 allowed). Consider refactoring.
                  Open

                  func TestDependencyResolverResolvesGroupDependencies(t *testing.T) {
                      t.Parallel()
                      defer logging.HideLogs(t)()
                  
                      t.Run("intra-module", func(t *testing.T) {
                  Severity: Minor
                  Found in load/dependencyresolver_test.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

                  Method Server.Listen has 56 lines of code (exceeds 50 allowed). Consider refactoring.
                  Open

                  func (s *Server) Listen(ctx context.Context, addr *url.URL) error {
                      logger := logging.GetLogger(ctx).WithField("addr", addr)
                  
                      // set up a context within the waitgroup
                      wg, ctx := errgroup.WithContext(ctx)
                  Severity: Minor
                  Found in rpc/server.go - About 1 hr to fix

                    Function TestPreparer has 56 lines of code (exceeds 50 allowed). Consider refactoring.
                    Open

                    func TestPreparer(t *testing.T) {
                        users := []*user.User{fakeUser("1", "1", "user-1")}
                        groups := []*user.Group{fakeGroup("1", "group-1")}
                        t.Run("implements-resource", func(t *testing.T) {
                            assert.Implements(t, (*resource.Resource)(nil), new(owner.Preparer))
                    Severity: Minor
                    Found in resource/file/owner/preparer_test.go - About 1 hr to fix

                      Function TestApply has 55 lines of code (exceeds 50 allowed). Consider refactoring.
                      Open

                      func TestApply(t *testing.T) {
                          t.Parallel()
                          defer logging.HideLogs(t)()
                      
                          newWait := func() *wait.Wait {
                      Severity: Minor
                      Found in resource/wait/wait_test.go - About 1 hr to fix

                        Function getFailedReason has 55 lines of code (exceeds 50 allowed). Consider refactoring.
                        Open

                        func getFailedReason(u *Unit) (string, error) {
                            err := errors.New("unable to determine cause of failure: no properties available")
                            var reason string
                            switch u.Type {
                            case UnitTypeService:
                        Severity: Minor
                        Found in resource/systemd/unit/resource.go - About 1 hr to fix

                          Function expandSwitchMacro has 55 lines of code (exceeds 50 allowed). Consider refactoring.
                          Open

                          func expandSwitchMacro(data []byte, current *source, n *parse.Node, g *graph.Graph) (*graph.Graph, error) {
                              if !control.IsSwitchNode(n) {
                                  return g, nil
                              }
                              switchObj, err := control.NewSwitch(n, data)
                          Severity: Minor
                          Found in load/nodes.go - About 1 hr to fix

                            Method Server.Listen has 12 return statements (exceeds 4 allowed).
                            Open

                            func (s *Server) Listen(ctx context.Context, addr *url.URL) error {
                                logger := logging.GetLogger(ctx).WithField("addr", addr)
                            
                                // set up a context within the waitgroup
                                wg, ctx := errgroup.WithContext(ctx)
                            Severity: Major
                            Found in rpc/server.go - About 1 hr to fix

                              Function TestCopyToFinalDest has 12 return statements (exceeds 4 allowed).
                              Open

                              func TestCopyToFinalDest(t *testing.T) {
                                  t.Parallel()
                              
                                  t.Run("no duplicates", func(t *testing.T) {
                                      destDir, err := ioutil.TempDir("", "destDir_unarchive")
                              Severity: Major
                              Found in resource/unarchive/unarchive_test.go - About 1 hr to fix

                                Function TestEvaluateDuplicates has 12 return statements (exceeds 4 allowed).
                                Open

                                func TestEvaluateDuplicates(t *testing.T) {
                                    t.Parallel()
                                
                                    t.Run("no duplicates", func(t *testing.T) {
                                        destDir, err := ioutil.TempDir("", "destDir_unarchive")
                                Severity: Major
                                Found in resource/unarchive/unarchive_test.go - About 1 hr to fix

                                  Function TestHandlesContext has 54 lines of code (exceeds 50 allowed). Consider refactoring.
                                  Open

                                  func TestHandlesContext(t *testing.T) {
                                      t.Parallel()
                                  
                                      t.Run("Check", func(t *testing.T) {
                                          t.Parallel()
                                  Severity: Minor
                                  Found in resource/systemd/unit/resource_test.go - About 1 hr to fix

                                    Function TestApplyOwnershipDiff has 54 lines of code (exceeds 50 allowed). Consider refactoring.
                                    Open

                                    func TestApplyOwnershipDiff(t *testing.T) {
                                        users := []*user.User{
                                            fakeUser("1", "1", "user-1"),
                                            fakeUser("2", "2", "user-2"),
                                        }
                                    Severity: Minor
                                    Found in resource/file/owner/ownership_test.go - About 1 hr to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language