asteris-llc/converge

View on GitHub

Showing 615 of 615 total issues

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

        t.Run("no home_dir parameter", func(t *testing.T) {
            p := user.Preparer{UID: &testID, GID: &testID, Username: "test", Name: "test", State: user.StateAbsent}
            _, err := p.Prepare(context.Background(), &fr)

            assert.NoError(t, err)
Severity: Minor
Found in resource/user/preparer_test.go and 1 other location - About 40 mins to fix
resource/user/preparer_test.go on lines 119..124

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 111.

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

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

func (m *mockClient) FindVolume(name string) (*dc.Volume, error) {
    args := m.Called(name)

    ret := args.Get(0)
    if ret == nil {
Severity: Minor
Found in resource/docker/volume/volume_test.go and 1 other location - About 40 mins to fix
resource/docker/network/network_test.go on lines 517..524

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 111.

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

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

                case groupByName != nil && groupByGid != nil && groupByName.Name != groupByGid.Name || groupByName.Gid != groupByGid.Gid:
                    status.RaiseLevel(resource.StatusCantChange)
                    status.Output = append(status.Output, fmt.Sprintf("group add/modify: group %s and gid %s belong to different groups", g.Name, g.GID))
                    return status, errors.New("cannot add or modify group")
Severity: Minor
Found in resource/group/group.go and 1 other location - About 40 mins to fix
resource/group/group.go on lines 211..214

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 111.

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

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

            case groupByName != nil && groupByGid != nil && groupByName.Name != groupByGid.Name || groupByName.Gid != groupByGid.Gid:
                status.RaiseLevel(resource.StatusCantChange)
                status.Output = append(status.Output, fmt.Sprintf("group delete: group %s and gid %s belong to different groups", g.Name, g.GID))
                return status, errors.New("cannot delete group")
Severity: Minor
Found in resource/group/group.go and 1 other location - About 40 mins to fix
resource/group/group.go on lines 157..160

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 111.

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

Function Parse has 6 return statements (exceeds 4 allowed).
Open

func Parse(content []byte) (resources []*Node, err error) {
    obj, err := hcl.ParseBytes(content)
    if err != nil {
        return resources, err
    }
Severity: Major
Found in parse/parse.go - About 40 mins to fix

    Method Unarchive.isMemAvailable has 6 return statements (exceeds 4 allowed).
    Open

    func (u *Unarchive) isMemAvailable() (bool, error) {
        var (
            destStat syscall.Statfs_t
            tmpStat  syscall.Statfs_t
        )
    Severity: Major
    Found in resource/unarchive/unarchive.go - About 40 mins to fix

      Method grapher.Graph has 6 return statements (exceeds 4 allowed).
      Open

      func (g *grapher) Graph(in *pb.LoadRequest, stream pb.Grapher_GraphServer) error {
          logger, ctx := setIDLogger(stream.Context())
          logger = logger.WithField("function", "grapher.Graph")
      
          loaded, err := in.Load(ctx)
      Severity: Major
      Found in rpc/grapher.go - About 40 mins to fix

        Function WithNotify has 6 return statements (exceeds 4 allowed).
        Open

        func WithNotify(ctx context.Context, in *graph.Graph, 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 plan/plan.go - About 40 mins to fix

          Method User.Check has 6 return statements (exceeds 4 allowed).
          Open

          func (u *User) Check(context.Context, resource.Renderer) (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: Major
          Found in resource/user/user.go - About 40 mins to fix

            Function TraverseUntilModule has 6 return statements (exceeds 4 allowed).
            Open

            func TraverseUntilModule(g *graph.Graph, id string) bool {
                if graph.IsRoot(id) {
                    return true
                }
                elemMeta, ok := g.Get(id)
            Severity: Major
            Found in render/preprocessor/preprocessor.go - About 40 mins to fix

              Method pipelineGen.PlanNode has 6 return statements (exceeds 4 allowed).
              Open

              func (g *pipelineGen) PlanNode(ctx context.Context, taski interface{}) (interface{}, error) {
                  twrapper, ok := taski.(taskWrapper)
                  if !ok {
                      asResult, ok := taski.(*Result)
                      if ok {
              Severity: Major
              Found in plan/pipeline.go - About 40 mins to fix

                Method commandIOContext.exec has 6 return statements (exceeds 4 allowed).
                Open

                func (c *commandIOContext) exec(script string) (results *CommandResults, err error) {
                    results = &CommandResults{
                        Stdin: script,
                    }
                
                
                Severity: Major
                Found in resource/shell/command_executor.go - About 40 mins to fix

                  Method Network.Apply has 6 return statements (exceeds 4 allowed).
                  Open

                  func (n *Network) Apply(context.Context) (resource.TaskStatus, error) {
                      status := resource.NewStatus()
                  
                      var (
                          nw  *dc.Network
                  Severity: Major
                  Found in resource/docker/network/network.go - About 40 mins to fix

                    Function mergeMaybeUnresolvables has 6 return statements (exceeds 4 allowed).
                    Open

                    func mergeMaybeUnresolvables(err1, err2 error) error {
                        if err1 == nil {
                            return err2
                        }
                        if err2 == nil {
                    Severity: Major
                    Found in render/render.go - About 40 mins to fix

                      Method CommandResults.Eq has 6 return statements (exceeds 4 allowed).
                      Open

                      func (c *CommandResults) Eq(cmd *CommandResults) bool {
                          if c == nil || cmd == nil {
                              return false
                          }
                          if c.ExitStatus != cmd.ExitStatus {
                      Severity: Major
                      Found in resource/shell/command_results.go - About 40 mins to fix

                        Method Preparer.convertNumber has 6 return statements (exceeds 4 allowed).
                        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: Major
                        Found in resource/preparer.go - About 40 mins to fix

                          Method Server.newREST has 6 return statements (exceeds 4 allowed).
                          Open

                          func (s *Server) newREST(ctx context.Context, addr *url.URL) (*http.Server, error) {
                              opts, err := s.Security.Client()
                              if err != nil {
                                  return nil, errors.Wrap(err, "could not generate REST gateway security options")
                              }
                          Severity: Major
                          Found in rpc/server.go - About 40 mins to fix

                            Method Volume.Apply has 6 return statements (exceeds 4 allowed).
                            Open

                            func (v *Volume) Apply(context.Context) (resource.TaskStatus, error) {
                                status := resource.NewStatus()
                            
                                var (
                                    vol *dc.Volume
                            Severity: Major
                            Found in resource/docker/volume/volume.go - About 40 mins to fix

                              Function isExportedField has 6 return statements (exceeds 4 allowed).
                              Open

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

                                Method Printer.Show has 6 return statements (exceeds 4 allowed).
                                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: Major
                                Found in prettyprinters/prettyprinter.go - About 40 mins to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language