orisano/impast

View on GitHub

Showing 4 of 4 total issues

Method Importer.GetMethodsDeep has a Cognitive Complexity of 29 (exceeds 20 allowed). Consider refactoring.
Open

func (i *Importer) GetMethodsDeep(pkg *ast.Package, name string) ([]*ast.FuncDecl, error) {
    var t *ast.StructType

    m := map[string]*ast.FuncDecl{}
    for _, f := range pkg.Files {
Severity: Minor
Found in impast.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

Function main has 66 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func main() {
    interfaceName := flag.String("out", "", "generate interface name (required)")
    pkgName := flag.String("pkg", "", "generate interface package name")

    flag.Parse()
Severity: Minor
Found in cmd/interfacer/main.go - About 1 hr to fix

    Method Importer.ImportPackage has 6 return statements (exceeds 4 allowed).
    Open

    func (i *Importer) ImportPackage(importPath string) (*ast.Package, error) {
        if i.EnableCache {
            if v, ok := i.cache.Load(importPath); ok {
                return v.(*ast.Package), nil
            }
    Severity: Major
    Found in impast.go - About 40 mins to fix

      Method Importer.GetMethodsDeep has 5 return statements (exceeds 4 allowed).
      Open

      func (i *Importer) GetMethodsDeep(pkg *ast.Package, name string) ([]*ast.FuncDecl, error) {
          var t *ast.StructType
      
          m := map[string]*ast.FuncDecl{}
          for _, f := range pkg.Files {
      Severity: Major
      Found in impast.go - About 35 mins to fix
        Severity
        Category
        Status
        Source
        Language