go_agent/src/code.google.com/p/go.tools/godoc/index.go
File index.go
has 1081 lines of code (exceeds 500 allowed). Consider refactoring. Open
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
Method Corpus.NewIndex
has 90 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (c *Corpus) NewIndex() *Index {
// initialize Indexer
// (use some reasonably sized maps to start)
x := &Indexer{
c: c,
Method Indexer.indexDocs
has 57 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (x *Indexer) indexDocs(dirname string, filename string, astFile *ast.File) {
pkgName := astFile.Name.Name
if pkgName == "main" {
return
}
Method Indexer.indexDocs
has a Cognitive Complexity of 25 (exceeds 20 allowed). Consider refactoring. Open
Open
func (x *Indexer) indexDocs(dirname string, filename string, astFile *ast.File) {
pkgName := astFile.Name.Name
if pkgName == "main" {
return
}
- Read upRead up
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
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)
}
Method Corpus.readIndex
has 6 return statements (exceeds 4 allowed). Open
Open
func (c *Corpus) readIndex(filenames string) error {
matches, err := filepath.Glob(filenames)
if err != nil {
return err
} else if matches == nil {
Method Indexer.visitFile
has 6 return statements (exceeds 4 allowed). Open
Open
func (x *Indexer) visitFile(dirname string, fi os.FileInfo) {
if fi.IsDir() || !x.c.IndexEnabled {
return
}
Method Index.WriteTo
has 5 return statements (exceeds 4 allowed). Open
Open
func (x *Index) WriteTo(w io.Writer) (n int64, err error) {
w = countingWriter{&n, w}
fulltext := false
if x.suffixes != nil {
fulltext = true
Method Index.LookupRegexp
has a Cognitive Complexity of 21 (exceeds 20 allowed). Consider refactoring. Open
Open
func (x *Index) LookupRegexp(r *regexp.Regexp, n int) (found int, result []FileLines) {
if x.suffixes == nil || n <= 0 {
return
}
// n > 0
- Read upRead up
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"