Showing 16 of 18 total issues
sliceArrayEncoder
has 23 methods (exceeds 20 allowed). Consider refactoring. Open
type sliceArrayEncoder struct {
elems []interface{}
}
Method DepGraph.computeSetGraphTraversal
has 72 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (g *DepGraph) computeSetGraphTraversal(log *logger.Logger, expr query.FuncExpr, direction traversalDirection, level Level) (nodeSet, error) {
args := expr.Args()
if len(args.Args()) == 0 {
return nil, &queryErr{
err: "expected at least one argument but received none",
Method tokenizer.next
has 69 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (t *tokenizer) next() (tkn token, err error) {
var s tokenString
var r rune
var p int64
Method DepGraph.computeSetGraphTraversal
has a Cognitive Complexity of 22 (exceeds 15 allowed). Consider refactoring. Open
func (g *DepGraph) computeSetGraphTraversal(log *logger.Logger, expr query.FuncExpr, direction traversalDirection, level Level) (nodeSet, error) {
args := expr.Args()
if len(args.Args()) == 0 {
return nil, &queryErr{
err: "expected at least one argument but received none",
- 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 parser.shiftPunctuation
has a Cognitive Complexity of 21 (exceeds 15 allowed). Consider refactoring. Open
func (p *parser) shiftPunctuation(next punctuationToken) (bool, error) {
switch next.(type) {
case *tokenComma:
if len(p.exprStack) == 0 {
return false, &parserError{
- 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 tokenizer.next
has a Cognitive Complexity of 21 (exceeds 15 allowed). Consider refactoring. Open
func (t *tokenizer) next() (tkn token, err error) {
var s tokenString
var r rune
var p int64
- 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 tokenizer.next
has 10 return statements (exceeds 5 allowed). Open
func (t *tokenizer) next() (tkn token, err error) {
var s tokenString
var r rune
var p int64
Method DepGraph.sharedFunc
has a Cognitive Complexity of 18 (exceeds 15 allowed). Consider refactoring. Open
func (g *DepGraph) sharedFunc(log *logger.Logger, expr query.FuncExpr, level Level) (nodeSet, error) {
args := expr.Args()
if len(args.Args()) != 1 {
return nil, &queryErr{
err: fmt.Sprintf("expected a single argument but received '%v'", len(args.Args())),
- 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 DepGraph.computeSetGraphTraversal
has 7 return statements (exceeds 5 allowed). Open
func (g *DepGraph) computeSetGraphTraversal(log *logger.Logger, expr query.FuncExpr, direction traversalDirection, level Level) (nodeSet, error) {
args := expr.Args()
if len(args.Args()) == 0 {
return nil, &queryErr{
err: "expected at least one argument but received none",
Method parser.parse
has 6 return statements (exceeds 5 allowed). Open
func (p *parser) parse() (Expr, error) {
for p.streamIdx < len(p.stream) {
r, err := p.shift(p.stream[p.streamIdx])
if err != nil {
return nil, err
Function GetGraph
has a Cognitive Complexity of 17 (exceeds 15 allowed). Consider refactoring. Open
func GetGraph(dl *logger.Builder, path string) (*DepGraph, error) {
if dl == nil {
dl = logger.NewBuilder(os.Stderr)
}
log := dl.Domain(logger.GraphDomain)
- 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 parser.shiftPunctuation
has 6 return statements (exceeds 5 allowed). Open
func (p *parser) shiftPunctuation(next punctuationToken) (bool, error) {
switch next.(type) {
case *tokenComma:
if len(p.exprStack) == 0 {
return false, &parserError{
Method HierarchicalDigraph.AddEdge
has 6 return statements (exceeds 5 allowed). Open
func (g *HierarchicalDigraph) AddEdge(src Node, dst Node) error {
if g == nil {
return ErrNilGraph
} else if nodeIsNil(src) || nodeIsNil(dst) {
return ErrNilNode
Method DepGraph.retrievePackageInfo
has a Cognitive Complexity of 17 (exceeds 15 allowed). Consider refactoring. Open
func (g *DepGraph) retrievePackageInfo(log *logger.Logger, pkgs []string) (imports []string, err error) {
stdout, _, err := util.RunCommand(log, g.Main.Info.Dir, "go", append([]string{"list", "-json", "-mod=mod"}, pkgs...)...)
if err != nil {
log.Error("Failed to list imports for packages.", zap.Strings("packages", pkgs), zap.Error(err))
return nil, err
- 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 graphClusters.clusterDepthMap
has a Cognitive Complexity of 16 (exceeds 15 allowed). Consider refactoring. Open
func (c *graphClusters) clusterDepthMap(nodeHash string) map[string]int {
if m, ok := c.cachedDepthMaps[nodeHash]; ok {
return m
}
- 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 DepGraph.buildImportGraph
has a Cognitive Complexity of 16 (exceeds 15 allowed). Consider refactoring. Open
func (g *DepGraph) buildImportGraph(dl *logger.Builder) error {
log := dl.Domain(logger.PackageInfoDomain)
log.Debug("Building initial dependency graph based on the import graph.")
err := g.retrieveTransitiveImports(log, []string{fmt.Sprintf("%s/...", g.Main.Info.Path)})
- 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"