soumya92/barista

View on GitHub

Showing 45 of 92 total issues

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

func main() {
    material.Load(home("Github/material-design-icons"))
    mdi.Load(home("Github/MaterialDesign-Webfont"))
    typicons.Load(home("Github/typicons.font"))
    fontawesome.Load(home("Github/Font-Awesome"))
Severity: Major
Found in samples/sample-bar/sample-bar.go - About 1 day to fix

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

    func main() {
        material.Load(home("Github/material-design-icons"))
        mdi.Load(home("Github/MaterialDesign-Webfont"))
        typicons.Load(home("Github/typicons.font"))
        fontawesome.Load(home("Github/Font-Awesome"))
    Severity: Major
    Found in samples/simple/simple.go - About 1 day to fix

      Function main has a Cognitive Complexity of 57 (exceeds 20 allowed). Consider refactoring.
      Open

      func main() {
          material.Load(home("Github/material-design-icons"))
          mdi.Load(home("Github/MaterialDesign-Webfont"))
          typicons.Load(home("Github/typicons.font"))
          fontawesome.Load(home("Github/Font-Awesome"))
      Severity: Minor
      Found in samples/sample-bar/sample-bar.go - About 6 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

      Method SegmentGroup.Segments has a Cognitive Complexity of 48 (exceeds 20 allowed). Consider refactoring.
      Open

      func (g *SegmentGroup) Segments() []*bar.Segment {
          var segments []*bar.Segment
          for _, o := range g.outputs {
              for _, s := range o.Segments() {
                  segments = append(segments, s.Clone())
      Severity: Minor
      Found in outputs/group.go - About 4 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

      Method Watcher.tryWatch has a Cognitive Complexity of 47 (exceeds 20 allowed). Consider refactoring.
      Open

      func (w *Watcher) tryWatch(restarted bool) error {
          currentLvl := -1
          for lvl, p := range w.hierarchy {
              err := w.fswatcher.Add(p)
              if err == nil {
      Severity: Minor
      Found in base/watchers/file/file.go - About 4 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 main has a Cognitive Complexity of 45 (exceeds 20 allowed). Consider refactoring.
      Open

      func main() {
          material.Load(home("Github/material-design-icons"))
          mdi.Load(home("Github/MaterialDesign-Webfont"))
          typicons.Load(home("Github/typicons.font"))
          fontawesome.Load(home("Github/Font-Awesome"))
      Severity: Minor
      Found in samples/simple/simple.go - About 4 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

      File sample-bar.go has 594 lines of code (exceeds 500 allowed). Consider refactoring.
      Open

      // Copyright 2017 Google Inc.
      //
      // Licensed under the Apache License, Version 2.0 (the "License");
      // you may not use this file except in compliance with the License.
      // You may obtain a copy of the License at
      Severity: Minor
      Found in samples/sample-bar/sample-bar.go - About 4 hrs to fix

        Segment has 29 methods (exceeds 20 allowed). Consider refactoring.
        Open

        func (s *Segment) Text(content string) *Segment {
            s.text = content
            s.pango = false
            return s
        }
        Severity: Minor
        Found in bar/segment.go - About 3 hrs to fix

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

          func main() {
              colors.LoadFromMap(map[string]string{
                  "good":     "#0f0",
                  "bad":      "#f00",
                  "degraded": "#ff0",
          Severity: Major
          Found in samples/i3status/i3status.go - About 3 hrs to fix

            Function main has a Cognitive Complexity of 36 (exceeds 20 allowed). Consider refactoring.
            Open

            func main() {
                colors.LoadFromMap(map[string]string{
                    "good":     "#0f0",
                    "bad":      "#f00",
                    "degraded": "#ff0",
            Severity: Minor
            Found in samples/i3status/i3status.go - About 2 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

            Method parse_args has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
            Open

            def parse_args(signature)
              in_fn_ptr = 0
              curr = ''
              args = []
              signature.each_char do |c|
            Severity: Minor
            Found in testing/capi/funcs.rb - About 2 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 main has 28 return statements (exceeds 4 allowed).
            Open

            func main() {
                material.Load(home("Github/material-design-icons"))
                mdi.Load(home("Github/MaterialDesign-Webfont"))
                typicons.Load(home("Github/typicons.font"))
                fontawesome.Load(home("Github/Font-Awesome"))
            Severity: Major
            Found in samples/sample-bar/sample-bar.go - About 2 hrs to fix

              alsaImpl has 21 methods (exceeds 20 allowed). Consider refactoring.
              Open

              type alsaImpl struct{}
              Severity: Minor
              Found in modules/volume/alsa/alsa_capi.go - About 2 hrs to fix

                Method write_test_file has 50 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                def write_test_file(library, package, c_functions)
                  write_go_file("#{library}_capi_for_test.go") do |out|
                    out.puts "package #{package}"
                    out.puts(<<~PREAMBLE)
                      import "sync"
                Severity: Minor
                Found in testing/capi/generators.rb - About 2 hrs to fix

                  Method Watcher.tryWatch has 72 lines of code (exceeds 50 allowed). Consider refactoring.
                  Open

                  func (w *Watcher) tryWatch(restarted bool) error {
                      currentLvl := -1
                      for lvl, p := range w.hierarchy {
                          err := w.fswatcher.Add(p)
                          if err == nil {
                  Severity: Minor
                  Found in base/watchers/file/file.go - About 1 hr to fix

                    Function main has 17 return statements (exceeds 4 allowed).
                    Open

                    func main() {
                        material.Load(home("Github/material-design-icons"))
                        mdi.Load(home("Github/MaterialDesign-Webfont"))
                        typicons.Load(home("Github/typicons.font"))
                        fontawesome.Load(home("Github/Font-Awesome"))
                    Severity: Major
                    Found in samples/simple/simple.go - About 1 hr to fix

                      Function batteryInfo has 62 lines of code (exceeds 50 allowed). Consider refactoring.
                      Open

                      func batteryInfo(name string) Info {
                          batteryPath := fmt.Sprintf("/sys/class/power_supply/%s/uevent", name)
                          l.Fine("Reading from %s", batteryPath)
                          f, err := fs.Open(batteryPath)
                          if err != nil {
                      Severity: Minor
                      Found in modules/battery/battery.go - About 1 hr to fix

                        Function fetch has 58 lines of code (exceeds 50 allowed). Consider refactoring.
                        Open

                        func fetch(srv *calendar.Service, conf config) ([]Event, error) {
                            timeMin := timing.Now()
                            timeMax := timeMin.Add(conf.lookahead)
                        
                            req := srv.Events.List(conf.calendarID)
                        Severity: Minor
                        Found in modules/gsuite/calendar/calendar.go - About 1 hr to fix

                          Function Run has 58 lines of code (exceeds 50 allowed). Consider refactoring.
                          Open

                          func Run(modules ...bar.Module) error {
                              // Oauth configs are setup by modules when they're created.
                              // Now that all modules are created, the oauth system knows about all providers.
                              // So if the 'setup-oauth' arg was given, enter interactive setup instead.
                              // (InteractiveSetup calls os.Exit, so the rest of the bar will not run).
                          Severity: Minor
                          Found in barista.go - About 1 hr to fix

                            Function allBatteriesInfo has 57 lines of code (exceeds 50 allowed). Consider refactoring.
                            Open

                            func allBatteriesInfo() Info {
                                dir, err := fs.Open("/sys/class/power_supply")
                                if err != nil {
                                    l.Log("No batteries: %s", err)
                                    return Info{Status: Disconnected}
                            Severity: Minor
                            Found in modules/battery/battery.go - About 1 hr to fix
                              Severity
                              Category
                              Status
                              Source
                              Language