asteris-llc/converge

View on GitHub

Showing 247 of 615 total issues

Function TestDiff has 53 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func TestDiff(t *testing.T) {
    t.Parallel()

    src, err := ioutil.TempFile("", "unarchive_test.txt")
    require.NoError(t, err)
Severity: Minor
Found in resource/unarchive/unarchive_test.go - About 1 hr to fix

    Method Fetch.applyWithContext has 53 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func (f *Fetch) applyWithContext(context.Context) (resource.TaskStatus, error) {
        var (
            hsh      hash.Hash
            err      error
            status   = resource.NewStatus()
    Severity: Minor
    Found in resource/file/fetch/fetch.go - About 1 hr to fix

      Function TestAptInstallPackage has 52 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func TestAptInstallPackage(t *testing.T) {
          t.Parallel()
      
          t.Run("when installed", func(t *testing.T) {
              pkg := "foo1"
      Severity: Minor
      Found in resource/package/apt/package_manager_test.go - About 1 hr to fix

        Function TestIsTrue has 52 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func TestIsTrue(t *testing.T) {
            t.Run("errors-when-unrendered", func(t *testing.T) {
                g := sampleGraph()
                meta, _ := g.Get("root/b")
                _, err := conditional.IsTrue(meta)
        Severity: Minor
        Found in graph/node/conditional/conditional_test.go - About 1 hr to fix

          Method Printer.FinishPP has 52 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          func (p *Printer) FinishPP(g *graph.Graph) (pp.Renderable, error) {
              tmpl, err := p.template(`{{if .Errors}}Errors:
          {{range .Errors}} * {{.}}
          {{end}}
          {{end}}
          Severity: Minor
          Found in prettyprinters/human/human.go - About 1 hr to fix

            Method Network.Apply has 51 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

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

              Function TestDependencyResolverHandlesConditionalMetadata has 51 lines of code (exceeds 50 allowed). Consider refactoring.
              Open

              func TestDependencyResolverHandlesConditionalMetadata(t *testing.T) {
                  t.Parallel()
                  type test struct {
                      Value int
                  }
              Severity: Minor
              Found in load/dependencyresolver_test.go - About 1 hr to fix

                Function zipFiles has 10 return statements (exceeds 4 allowed).
                Open

                func zipFiles(source, destination string) error {
                    base := ""
                
                    zipFile, err := os.Create(destination)
                    if err != nil {
                Severity: Major
                Found in resource/unarchive/unarchive_test.go - About 1 hr to fix

                  Method Renderer.lookup has 9 return statements (exceeds 4 allowed).
                  Open

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

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

                    func (p *Preparer) Prepare(ctx context.Context, render resource.Renderer) (resource.Task, error) {
                        if strings.TrimSpace(p.Source) == "" {
                            return nil, errors.New("\"source\" must contain a value")
                        }
                    
                    
                    Severity: Major
                    Found in resource/unarchive/preparer.go - About 55 mins to fix

                      Method User.Apply has 9 return statements (exceeds 4 allowed).
                      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: Major
                      Found in resource/user/user.go - About 55 mins to fix

                        Method RPCProvider.VertexGetLabel has 9 return statements (exceeds 4 allowed).
                        Open

                        func (p RPCProvider) VertexGetLabel(e graphviz.GraphEntity) (pp.VisibleRenderable, error) {
                            var name string
                        
                            if e.Name == rootNodeID {
                                name = "/"
                        Severity: Major
                        Found in prettyprinters/graphviz/providers/rpc.go - About 55 mins to fix

                          Method Printer.InitColors has 9 return statements (exceeds 4 allowed).
                          Open

                          func (p *Printer) InitColors() {
                              reset := "\x1b[0m"
                              p.funcsMapWrite("bold", p.styled(func(in string) string { return "\x1b[1m" + in + reset }))
                              p.funcsMapWrite("black", p.styled(func(in string) string { return "\x1b[30m" + in + reset }))
                              p.funcsMapWrite("red", p.styled(func(in string) string { return "\x1b[31m" + in + reset }))
                          Severity: Major
                          Found in prettyprinters/human/human.go - About 55 mins to fix

                            Method ExtendedTemplate.New has 9 return statements (exceeds 4 allowed).
                            Open

                            func (tmpl *ExtendedTemplate) New(source string) (*template.Template, error) {
                                reset := "\x1b[0m"
                                funcs := map[string]interface{}{
                                    // colors
                                    "black":   tmpl.styled(func(in string) string { return "\x1b[30m" + in + reset }),
                            Severity: Major
                            Found in prettyprinters/tmpltools/tmpltools.go - About 55 mins to fix

                              Function loadKeyring has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring.
                              Open

                              func loadKeyring(ks *Keystore) (openpgp.KeyRing, error) {
                                  var keyring openpgp.EntityList
                                  trustedKeys := make(map[string]*openpgp.Entity)
                              
                                  for _, p := range []string{ks.SystemPath, ks.UserPath, ks.LocalPath} {
                              Severity: Minor
                              Found in keystore/keystore.go - About 55 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.Prepare has 9 return statements (exceeds 4 allowed).
                              Open

                              func (p *Preparer) Prepare(ctx context.Context, render resource.Renderer) (resource.Task, error) {
                                  if strings.TrimSpace(p.Source) == "" {
                                      return nil, errors.New("\"source\" must contain a value")
                                  }
                                  _, err := url.Parse(p.Source)
                              Severity: Major
                              Found in resource/file/fetch/preparer.go - About 55 mins to fix

                                Method Preparer.getValueForField has 8 return statements (exceeds 4 allowed).
                                Open

                                func (p *Preparer) getValueForField(r Renderer, field reflect.StructField) (reflect.Value, error) {
                                    // get the field name for use in future lookups
                                    name := p.getFieldName(field)
                                    raw, isSet := p.Source[name]
                                
                                
                                Severity: Major
                                Found in resource/preparer.go - About 50 mins to fix

                                  Method Node.Validate has 8 return statements (exceeds 4 allowed).
                                  Open

                                  func (n *Node) Validate() error {
                                      if n == nil {
                                          return errors.New("node is empty, check for bad input")
                                      }
                                  
                                  
                                  Severity: Major
                                  Found in parse/node.go - About 50 mins to fix

                                    Method Unarchive.setDirsAndContents has 8 return statements (exceeds 4 allowed).
                                    Open

                                    func (u *Unarchive) setDirsAndContents() (bool, error) {
                                        var err error
                                    
                                        // set the unarchive destination directory
                                        u.destDir, err = os.Open(u.Destination)
                                    Severity: Major
                                    Found in resource/unarchive/unarchive.go - About 50 mins to fix

                                      Function ExportedFields has 8 return statements (exceeds 4 allowed).
                                      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: Major
                                      Found in resource/field_extractor.go - About 50 mins to fix
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language