soumya92/barista

View on GitHub

Showing 92 of 92 total issues

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 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 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 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

              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

                    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

                    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

                      Identical blocks of code found in 2 locations. Consider refactoring.
                      Open

                      func whereami() (lat float64, lng float64, err error) {
                          resp, err := http.Get("https://freegeoip.app/json/")
                          if err != nil {
                              return 0, 0, err
                          }
                      Severity: Minor
                      Found in samples/simple/simple.go and 1 other location - About 50 mins to fix
                      samples/sample-bar/sample-bar.go on lines 164..175

                      Duplicated Code

                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                      Tuning

                      This issue has a mass of 121.

                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                      Refactorings

                      Further Reading

                      Identical blocks of code found in 2 locations. Consider refactoring.
                      Open

                      func whereami() (lat float64, lng float64, err error) {
                          resp, err := http.Get("https://freegeoip.app/json/")
                          if err != nil {
                              return 0, 0, err
                          }
                      Severity: Minor
                      Found in samples/sample-bar/sample-bar.go and 1 other location - About 50 mins to fix
                      samples/simple/simple.go on lines 121..132

                      Duplicated Code

                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                      Tuning

                      This issue has a mass of 121.

                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                      Refactorings

                      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

                          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

                            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 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 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

                                Similar blocks of code found in 2 locations. Consider refactoring.
                                Open

                                func (alsaImpl) snd_mixer_selem_get_playback_switch(arg_elem *ctyp_snd_mixer_elem_t, arg_channel ctyp_snd_mixer_selem_channel_id_t, arg_value *int32) int32 {
                                    tmp_arg_elem := (*C.snd_mixer_elem_t)(arg_elem)
                                    tmp_arg_channel := C.snd_mixer_selem_channel_id_t(arg_channel)
                                    tmp_arg_value := (*C.int)(arg_value)
                                    result_c := C.snd_mixer_selem_get_playback_switch(tmp_arg_elem, tmp_arg_channel, tmp_arg_value)
                                Severity: Minor
                                Found in modules/volume/alsa/alsa_capi.go and 1 other location - About 40 mins to fix
                                modules/volume/alsa/alsa_capi.go on lines 111..117

                                Duplicated Code

                                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                Tuning

                                This issue has a mass of 111.

                                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                Refactorings

                                Further Reading

                                Severity
                                Category
                                Status
                                Source
                                Language