cloudfoundry-community/bosh-cloudstack-cpi

View on GitHub
go_agent/src/code.google.com/p/go.tools/godoc/index.go

Summary

Maintainability
D
2 days
Test Coverage

File index.go has 1081 lines of code (exceeds 500 allowed). Consider refactoring.
Open

// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

// This file contains the infrastructure to create an
Severity: Major
Found in go_agent/src/code.google.com/p/go.tools/godoc/index.go - About 1 day to fix

    Method Corpus.NewIndex has 90 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func (c *Corpus) NewIndex() *Index {
        // initialize Indexer
        // (use some reasonably sized maps to start)
        x := &Indexer{
            c:           c,
    Severity: Major
    Found in go_agent/src/code.google.com/p/go.tools/godoc/index.go - About 2 hrs to fix

      Method Indexer.indexDocs has 57 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func (x *Indexer) indexDocs(dirname string, filename string, astFile *ast.File) {
          pkgName := astFile.Name.Name
          if pkgName == "main" {
              return
          }
      Severity: Minor
      Found in go_agent/src/code.google.com/p/go.tools/godoc/index.go - About 1 hr to fix

        Method Indexer.indexDocs has a Cognitive Complexity of 25 (exceeds 20 allowed). Consider refactoring.
        Open

        func (x *Indexer) indexDocs(dirname string, filename string, astFile *ast.File) {
            pkgName := astFile.Name.Name
            if pkgName == "main" {
                return
            }
        Severity: Minor
        Found in go_agent/src/code.google.com/p/go.tools/godoc/index.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 Index.ReadFrom has 6 return statements (exceeds 4 allowed).
        Open

        func (x *Index) ReadFrom(r io.Reader) (n int64, err error) {
            // We use the ability to read bytes as a plausible surrogate for buffering.
            if _, ok := r.(io.ByteReader); !ok {
                r = bufio.NewReader(r)
            }
        Severity: Major
        Found in go_agent/src/code.google.com/p/go.tools/godoc/index.go - About 40 mins to fix

          Method Corpus.readIndex has 6 return statements (exceeds 4 allowed).
          Open

          func (c *Corpus) readIndex(filenames string) error {
              matches, err := filepath.Glob(filenames)
              if err != nil {
                  return err
              } else if matches == nil {
          Severity: Major
          Found in go_agent/src/code.google.com/p/go.tools/godoc/index.go - About 40 mins to fix

            Method Indexer.visitFile has 6 return statements (exceeds 4 allowed).
            Open

            func (x *Indexer) visitFile(dirname string, fi os.FileInfo) {
                if fi.IsDir() || !x.c.IndexEnabled {
                    return
                }
            
            
            Severity: Major
            Found in go_agent/src/code.google.com/p/go.tools/godoc/index.go - About 40 mins to fix

              Method Index.WriteTo has 5 return statements (exceeds 4 allowed).
              Open

              func (x *Index) WriteTo(w io.Writer) (n int64, err error) {
                  w = countingWriter{&n, w}
                  fulltext := false
                  if x.suffixes != nil {
                      fulltext = true
              Severity: Major
              Found in go_agent/src/code.google.com/p/go.tools/godoc/index.go - About 35 mins to fix

                Method Index.LookupRegexp has a Cognitive Complexity of 21 (exceeds 20 allowed). Consider refactoring.
                Open

                func (x *Index) LookupRegexp(r *regexp.Regexp, n int) (found int, result []FileLines) {
                    if x.suffixes == nil || n <= 0 {
                        return
                    }
                    // n > 0
                Severity: Minor
                Found in go_agent/src/code.google.com/p/go.tools/godoc/index.go - About 25 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

                There are no issues that match your filters.

                Category
                Status