stamm/dep_radar

View on GitHub

Showing 10 of 57 total issues

Function Prepare has a Cognitive Complexity of 62 (exceeds 20 allowed). Consider refactoring.
Open

func Prepare(ctx context.Context, apps <-chan dep_radar.IApp, detector *providers.Detector, rec dep_radar.MapRecommended) TemplateStruct {
    appsMap, libsMap := app.GetTags(ctx, apps, detector)
    appsMap = app.AddVersionLibToApp(appsMap, libsMap)

    // Sort libraries
Severity: Minor
Found in html/prepare.go - About 7 hrs 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 Prepare has 105 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func Prepare(ctx context.Context, apps <-chan dep_radar.IApp, detector *providers.Detector, rec dep_radar.MapRecommended) TemplateStruct {
    appsMap, libsMap := app.GetTags(ctx, apps, detector)
    appsMap = app.AddVersionLibToApp(appsMap, libsMap)

    // Sort libraries
Severity: Major
Found in html/prepare.go - About 3 hrs to fix

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

    func handlerAPI(w http.ResponseWriter, r *http.Request) {
        w.Header().Add("Access-Control-Allow-Origin", "*")
        githubProv := github.New(github.NewHTTPWrapper(os.Getenv("GITHUB_TOKEN"), 10))
        provDetector := providers.NewDetector().AddProvider(githubProv)
        depDetector := deps.DefaultDetector()
    Severity: Minor
    Found in cmd/dep_radar/main.go - About 1 hr to fix

      Function RestoreAsset has 6 return statements (exceeds 4 allowed).
      Open

      func RestoreAsset(dir, name string) error {
          data, err := Asset(name)
          if err != nil {
              return err
          }
      Severity: Major
      Found in html/templates/bindata.go - About 40 mins to fix

        Function New has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        func New(ctx context.Context, pkg dep_radar.Pkg, branch string, detector dep_radar.IProviderDetector, depDetector dep_radar.IDepDetector) (*App, error) {
        Severity: Minor
        Found in app/app.go - About 35 mins to fix

          Method Detector.Deps has 5 return statements (exceeds 4 allowed).
          Open

          func (d *Detector) Deps(ctx context.Context, app dep_radar.IApp) (dep_radar.AppDeps, error) {
              var (
                  errs []string
                  wg   sync.WaitGroup
                  mx   sync.Mutex
          Severity: Major
          Found in deps/detect.go - About 35 mins to fix

            Function LibsHTML has 5 return statements (exceeds 4 allowed).
            Open

            func LibsHTML(ctx context.Context, apps <-chan dep_radar.IApp, detector *providers.Detector, rec dep_radar.MapRecommended) ([]byte, error) {
                var buf bytes.Buffer
                raw, err := templates.Asset("src/html/templates/libs.html")
                if err != nil {
                    return buf.Bytes(), err
            Severity: Major
            Found in html/libs.go - About 35 mins to fix

              Function Compare has 5 return statements (exceeds 4 allowed).
              Open

              func Compare(recomends, actual string) (bool, error) {
                  if recomends == "" || actual == "" {
                      return false, nil
                  }
                  for _, recommended := range strings.Split(recomends, "|") {
              Severity: Major
              Found in version/compare.go - About 35 mins to fix

                Method Client.Get has 5 return statements (exceeds 4 allowed).
                Open

                func (c *Client) Get(ctx context.Context, uri string) ([]byte, error) {
                    log.Printf("Start getting url %s\n", uri)
                    c.limitCh <- struct{}{}
                    defer func() {
                        <-c.limitCh
                Severity: Major
                Found in http/client.go - About 35 mins to fix

                  Function AppsHTML has 5 return statements (exceeds 4 allowed).
                  Open

                  func AppsHTML(ctx context.Context, apps <-chan dep_radar.IApp, detector *providers.Detector, rec dep_radar.MapRecommended) ([]byte, error) {
                      var buf bytes.Buffer
                      raw, err := templates.Asset("src/html/templates/apps.html")
                      if err != nil {
                          return buf.Bytes(), err
                  Severity: Major
                  Found in html/apps.go - About 35 mins to fix
                    Severity
                    Category
                    Status
                    Source
                    Language