asteris-llc/converge

View on GitHub

Showing 615 of 615 total issues

Method Container.compareLinks has 5 return statements (exceeds 4 allowed).
Open

func (c *Container) compareLinks(container *dc.Container) (actual, expected string) {
    normalizeLink := func(link string) string {
        // internally links are stored as "/linkedcontainername:/containername/alias"
        parts := strings.Split(link, ":")
        if len(parts) == 1 {
Severity: Major
Found in resource/docker/container/container.go - About 35 mins to fix

    Method Preparer.Prepare has 5 return statements (exceeds 4 allowed).
    Open

    func (p *Preparer) Prepare(ctx context.Context, r Renderer) (Task, error) {
        value := reflect.ValueOf(p.Destination)
        typ := value.Type()
        wasPtr := false // so we can re-wrap later if we need to
    
    
    Severity: Major
    Found in resource/preparer.go - About 35 mins to fix

      Function AssertDiff has 5 return statements (exceeds 4 allowed).
      Open

      func AssertDiff(t *testing.T, diffs map[string]resource.Diff, name, original, current string) bool {
          var ok bool
      
          if ok = assert.NotEmpty(t, diffs); !ok {
              return false
      Severity: Major
      Found in helpers/comparison/diff.go - About 35 mins to fix

        Method Preparer.convertMap has 5 return statements (exceeds 4 allowed).
        Open

        func (p *Preparer) convertMap(typ reflect.Type, r Renderer, name string, val interface{}, base int) (reflect.Value, error) {
            if val == nil {
                return reflect.Zero(typ), nil
            }
        
        
        Severity: Major
        Found in resource/preparer.go - About 35 mins to fix

          Method Unarchive.readWrite has 5 return statements (exceeds 4 allowed).
          Open

          func (u *Unarchive) readWrite(file string) error {
              fileName := strings.TrimPrefix(file, u.fetchDir.Name())
          
              fStat, err := os.Stat(file)
              if err != nil {
          Severity: Major
          Found in resource/unarchive/unarchive.go - About 35 mins to fix

            Method pipelineGen.prepareNode has 5 return statements (exceeds 4 allowed).
            Open

            func (p pipelineGen) prepareNode(ctx context.Context, idi interface{}) (interface{}, error) {
                var metadataErr error
            
                res, ok := idi.(resource.Resource)
                if !ok {
            Severity: Major
            Found in render/render.go - About 35 mins to fix

              Method Preparer.convertDuration has 5 return statements (exceeds 4 allowed).
              Open

              func (p *Preparer) convertDuration(typ reflect.Type, r Renderer, name string, val interface{}, base int) (reflect.Value, error) {
                  if val == nil {
                      return reflect.Zero(typ), nil
                  }
              
              
              Severity: Major
              Found in resource/preparer.go - About 35 mins to fix

                Function newExportedField has 5 return statements (exceeds 4 allowed).
                Open

                func newExportedField(input interface{}, index int) (*ExportedField, bool) {
                    if nil == input {
                        return nil, false
                    }
                
                
                Severity: Major
                Found in resource/field_extractor.go - About 35 mins to fix

                  Method pipelineGen.GetTask has 5 return statements (exceeds 4 allowed).
                  Open

                  func (g *pipelineGen) GetTask(ctx context.Context, idi interface{}) (interface{}, error) {
                      if thunk, ok := idi.(*render.PrepareThunk); ok {
                          thunked, err := thunk.Thunk(g.RenderingPlant)
                          if err != nil {
                              return nil, err
                  Severity: Major
                  Found in plan/pipeline.go - About 35 mins to fix

                    Method GrapherClient.Graph has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring.
                    Open

                    func (gc *GrapherClient) Graph(ctx context.Context, loc *pb.LoadRequest, opts ...grpc.CallOption) (*graph.Graph, error) {
                        stream, err := gc.client.Graph(ctx, loc, opts...)
                        if err != nil {
                            return nil, errors.Wrap(err, "could not open stream")
                        }
                    Severity: Minor
                    Found in rpc/grapherclient.go - About 35 mins 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 Preparer.convertTime has 5 return statements (exceeds 4 allowed).
                    Open

                    func (p *Preparer) convertTime(typ reflect.Type, r Renderer, name string, val interface{}, base int) (reflect.Value, error) {
                        if val == nil {
                            return reflect.Zero(typ), nil
                        }
                    
                    
                    Severity: Major
                    Found in resource/preparer.go - About 35 mins to fix

                      Function getXrefs has 5 return statements (exceeds 4 allowed).
                      Open

                      func getXrefs(g *graph.Graph, id string, node *parse.Node) (out []string, err error) {
                          var nodeStrings []string
                          var calls []string
                          nodeRefs := make(map[string]struct{})
                          nodeStrings, err = node.GetStrings()
                      Severity: Major
                      Found in load/dependencyresolver.go - About 35 mins to fix

                        Function execPipeline has 5 return statements (exceeds 4 allowed).
                        Open

                        func execPipeline(ctx context.Context, in *graph.Graph, pipelineF MkPipelineF, renderingPlant *render.Factory, notify *graph.Notifier) (*graph.Graph, error) {
                            var hasErrors error
                        
                            out, err := in.Transform(ctx,
                                notify.Transform(func(meta *node.Node, out *graph.Graph) error {
                        Severity: Major
                        Found in apply/apply.go - About 35 mins to fix

                          Similar blocks of code found in 6 locations. Consider refactoring.
                          Open

                                  t.Run("automount", func(t *testing.T) {
                                      t.Parallel()
                                      u := &Unit{Type: UnitTypeAutoMount, AutomountProperties: &AutomountTypeProperties{Result: "success"}}
                                      actual, err := getFailedReason(u)
                                      require.NoError(t, err)
                          Severity: Major
                          Found in resource/systemd/unit/resource_test.go and 5 other locations - About 35 mins to fix
                          resource/systemd/unit/resource_test.go on lines 254..260
                          resource/systemd/unit/resource_test.go on lines 261..267
                          resource/systemd/unit/resource_test.go on lines 268..274
                          resource/systemd/unit/resource_test.go on lines 282..288
                          resource/systemd/unit/resource_test.go on lines 289..295

                          Duplicated Code

                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                          Tuning

                          This issue has a mass of 105.

                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                          Refactorings

                          Further Reading

                          Method resourceVG.Check has 5 return statements (exceeds 4 allowed).
                          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: Major
                          Found in resource/lvm/vg/vg.go - About 35 mins to fix

                            Method resourceVG.Apply has 5 return statements (exceeds 4 allowed).
                            Open

                            func (r *resourceVG) Apply(context.Context) (status resource.TaskStatus, err error) {
                                if r.exists {
                                    for _, d := range r.devicesToAdd {
                                        if err := r.lvm.ExtendVolumeGroup(r.name, d); err != nil {
                                            return nil, errors.Wrapf(err, "extending volume group")
                            Severity: Major
                            Found in resource/lvm/vg/vg.go - About 35 mins to fix

                              Method Printer.DrawEdge has 5 return statements (exceeds 4 allowed).
                              Open

                              func (p *Printer) DrawEdge(g *graph.Graph, id1, id2 string) (pp.Renderable, error) {
                                  var srcVal, destVal interface{}
                              
                                  if src, ok := g.Get(id1); ok {
                                      srcVal = src.Value()
                              Severity: Major
                              Found in prettyprinters/graphviz/graphviz.go - About 35 mins to fix

                                Method Graph.IsNibling has 5 return statements (exceeds 4 allowed).
                                Open

                                func (g *Graph) IsNibling(fst, snd string) bool {
                                    sndID, sndHasParent := g.GetParentID(snd)
                                    if !sndHasParent {
                                        return false
                                    }
                                Severity: Major
                                Found in graph/graph.go - About 35 mins to fix

                                  Method pipelineGen.maybeRunFinalCheck has 5 return statements (exceeds 4 allowed).
                                  Open

                                  func (g *pipelineGen) maybeRunFinalCheck(ctx context.Context, resultI interface{}) (interface{}, error) {
                                      result, ok := resultI.(*Result)
                                      if !ok {
                                          return nil, fmt.Errorf("expected *Result but got %T", resultI)
                                      }
                                  Severity: Major
                                  Found in apply/pipeline.go - About 35 mins to fix

                                    Method resourceFS.Check has 5 return statements (exceeds 4 allowed).
                                    Open

                                    func (r *resourceFS) Check(context.Context, resource.Renderer) (resource.TaskStatus, error) {
                                        status := &resource.Status{}
                                    
                                        if err := r.lvm.CheckFilesystemTools(r.mount.Type); err != nil {
                                            return nil, errors.Wrapf(err, "filesystem prerequisites for %s", r.mount.Type)
                                    Severity: Major
                                    Found in resource/lvm/fs/fs.go - About 35 mins to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language