soumya92/barista

View on GitHub

Showing 43 of 105 total issues

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

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

    Method SegmentGroup.Segments has 54 lines of code (exceeds 50 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 1 hr to fix

      Method write_capi_file has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      def write_capi_file(library, package, pkg_config, header_filename, c_functions)
        aliases = Set.new(
          c_functions.flat_map { |fn| [fn.type] + fn.args.map(&:type) }
        ).map(&:aliases).reduce(&:merge)
      
      
      Severity: Minor
      Found in testing/capi/generators.rb - About 1 hr to fix

        Method alsaModule.Worker has 9 return statements (exceeds 4 allowed).
        Open

        func (m *alsaModule) Worker(s *value.ErrorValue) {
            // Structs for querying ALSA.
            var handle *ctyp_snd_mixer_t
            var sid *ctyp_snd_mixer_selem_id_t
            // Shortcut for error handling
        Severity: Major
        Found in modules/volume/alsa/alsa.go - About 55 mins to fix

          Function fetch has a Cognitive Complexity of 24 (exceeds 20 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 55 mins 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 Load has 8 return statements (exceeds 4 allowed).
          Open

          func Load(repoPath string) error {
              f, err := fs.Open(filepath.Join(repoPath, "scss/_variables.scss"))
              if err != nil {
                  return err
              }
          Severity: Major
          Found in pango/icons/mdi/mdi.go - About 50 mins to fix

            Function equalMarkup has 8 return statements (exceeds 4 allowed).
            Open

            func equalMarkup(a, b *html.Node) bool {
                if a == nil && b == nil {
                    return true
                }
                if a == nil || b == nil {
            Severity: Major
            Found in testing/pango/pango.go - About 50 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                  if !os.IsNotExist(err) {
                                      l.Log("%s: %v", l.ID(w), err)
                                      return err
                                  }
              Severity: Major
              Found in base/watchers/file/file.go - About 45 mins to fix

                Method write_capi_file has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                def write_capi_file(library, package, pkg_config, header_filename, c_functions)
                  aliases = Set.new(
                    c_functions.flat_map { |fn| [fn.type] + fn.args.map(&:type) }
                  ).map(&:aliases).reduce(&:merge)
                
                
                Severity: Minor
                Found in testing/capi/generators.rb - About 45 mins 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 provider.GetWeather has 7 return statements (exceeds 4 allowed).
                Open

                func (p *provider) GetWeather() (weather.Weather, error) {
                    response, err := http.Get(p.url)
                    if err != nil {
                        return weather.Weather{}, err
                    }
                Severity: Major
                Found in modules/weather/metar/metar.go - About 45 mins to fix

                  Method Watcher.tryWatch has 7 return statements (exceeds 4 allowed).
                  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: Major
                  Found in base/watchers/file/file.go - About 45 mins to fix

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

                    func typeName(typ reflect.Type) string {
                        if typ == nil {
                            return "nil"
                        }
                        name := typ.Name()
                    Severity: Major
                    Found in logging/id.go - About 40 mins to fix

                      Method TestBusObject.GoWithContext has 5 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                      func (t *TestBusObject) GoWithContext(ctx context.Context, method string, flags dbus.Flags, ch chan *dbus.Call, args ...interface{}) *dbus.Call {
                      Severity: Minor
                      Found in base/watchers/dbus/testobject.go - About 35 mins to fix

                        Method write_capi_file has 5 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                        def write_capi_file(library, package, pkg_config, header_filename, c_functions)
                        Severity: Minor
                        Found in testing/capi/generators.rb - About 35 mins to fix

                          Function allBatteriesInfo has a Cognitive Complexity of 22 (exceeds 20 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 35 mins 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 Load has 5 return statements (exceeds 4 allowed).
                          Open

                          func Load(repoPath string) error {
                              f, err := fs.Open(filepath.Join(repoPath, "metadata/icons.yml"))
                              if err != nil {
                                  return err
                              }
                          Severity: Major
                          Found in pango/icons/fontawesome/fontawesome.go - About 35 mins to fix

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

                            func updateTz(tzFile string) error {
                                if atomic.LoadUint32(&testMode) > 0 {
                                    return errTestMode
                                }
                                link, err := os.Readlink(tzFile)
                            Severity: Major
                            Found in base/watchers/localtz/localtz.go - About 35 mins to fix

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

                              func shorten(path string) string {
                                  // If path is a function, it can be something like some/package.(*Type).fn,
                                  // but we'll simplify it to some/package.Type.fn for logging.
                                  path = strings.Replace(path, "*", "", -1)
                                  path = strings.Replace(path, "(", "", -1)
                              Severity: Major
                              Found in logging/logging.go - About 35 mins to fix

                                Method Module.getNotifications has 5 return statements (exceeds 4 allowed).
                                Open

                                func (m *Module) getNotifications(client *http.Client) (Notifications, error) {
                                    req, _ := http.NewRequest("GET", "https://api.github.com/notifications", nil)
                                    if m.lastModified != "" {
                                        req.Header.Add("If-Modified-Since", m.lastModified)
                                    }
                                Severity: Major
                                Found in modules/github/github.go - About 35 mins to fix

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

                                  func getCondition(owmCondition int) weather.Condition {
                                      switch owmCondition {
                                      case 611, 612:
                                          return weather.Sleet
                                      case 701:
                                  Severity: Major
                                  Found in modules/weather/openweathermap/openweathermap.go - About 35 mins to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language