soumya92/barista

View on GitHub

Showing 92 of 92 total issues

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

func (alsaImpl) snd_mixer_selem_get_playback_volume(arg_elem *ctyp_snd_mixer_elem_t, arg_channel ctyp_snd_mixer_selem_channel_id_t, arg_value *int64) 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.long)(arg_value)
    result_c := C.snd_mixer_selem_get_playback_volume(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 104..110

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

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

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

          func openPulseAudio() (*dbus.Conn, error) {
              // Pulse defaults to creating its socket in a well-known place under
              // XDG_RUNTIME_DIR. For Pulse instances created by systemd, this is the
              // only reliable way to contact Pulse via D-Bus, since Pulse is created
              // on a per-user basis, but the session bus is created once for every
          Severity: Major
          Found in modules/volume/pulseaudio/pulse.go - About 35 mins to fix

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

            func (alsaImpl) snd_mixer_detach(arg_mixer *ctyp_snd_mixer_t, arg_name string) int32 {
                tmp_arg_mixer := (*C.snd_mixer_t)(arg_mixer)
                tmp_arg_name := C.CString(arg_name)
                defer C.free(unsafe.Pointer(tmp_arg_name))
                result_c := C.snd_mixer_detach(tmp_arg_mixer, tmp_arg_name)
            Severity: Minor
            Found in modules/volume/alsa/alsa_capi.go and 1 other location - About 35 mins to fix
            modules/volume/alsa/alsa_capi.go on lines 59..65

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

            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

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

            func (alsaImpl) snd_mixer_selem_set_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_set_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 35 mins to fix
            modules/volume/alsa/alsa_capi.go on lines 165..171

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

            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

            Method paModule.Worker has 5 return statements (exceeds 4 allowed).
            Open

            func (m *paModule) Worker(s *value.ErrorValue) {
                conn, err := openPulseAudio()
                if s.Error(err) {
                    return
                }
            Severity: Major
            Found in modules/volume/pulseaudio/pulse.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 SI has 5 return statements (exceeds 4 allowed).
                Open

                func SI(v float64, unit string) Value {
                    if v < 0 {
                        inv := SI(-v, unit)
                        inv.number = "-" + inv.number
                        return inv
                Severity: Major
                Found in format/units.go - About 35 mins to fix

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

                  func (alsaImpl) snd_mixer_selem_set_playback_volume(arg_elem *ctyp_snd_mixer_elem_t, arg_channel ctyp_snd_mixer_selem_channel_id_t, arg_value int64) 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.long(arg_value)
                      result_c := C.snd_mixer_selem_set_playback_volume(tmp_arg_elem, tmp_arg_channel, tmp_arg_value)
                  Severity: Minor
                  Found in modules/volume/alsa/alsa_capi.go and 1 other location - About 35 mins to fix
                  modules/volume/alsa/alsa_capi.go on lines 152..158

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

                  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

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

                      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

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

                        func (alsaImpl) snd_mixer_attach(arg_mixer *ctyp_snd_mixer_t, arg_name string) int32 {
                            tmp_arg_mixer := (*C.snd_mixer_t)(arg_mixer)
                            tmp_arg_name := C.CString(arg_name)
                            defer C.free(unsafe.Pointer(tmp_arg_name))
                            result_c := C.snd_mixer_attach(tmp_arg_mixer, tmp_arg_name)
                        Severity: Minor
                        Found in modules/volume/alsa/alsa_capi.go and 1 other location - About 35 mins to fix
                        modules/volume/alsa/alsa_capi.go on lines 71..77

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

                        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

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

                        func (n *Node) AppendText(texts ...string) *Node {
                            nodes := make([]*Node, len(texts))
                            for i, t := range texts {
                                nodes[i] = &Node{nodeType: ntText, content: t}
                            }
                        Severity: Minor
                        Found in pango/pango.go and 1 other location - About 35 mins to fix
                        pango/pango.go on lines 131..137

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

                        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

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

                        func (n *Node) ConcatText(texts ...string) *Node {
                            nodes := make([]*Node, len(texts))
                            for i, t := range texts {
                                nodes[i] = &Node{nodeType: ntText, content: t}
                            }
                        Severity: Minor
                        Found in pango/pango.go and 1 other location - About 35 mins to fix
                        pango/pango.go on lines 95..101

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

                        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

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

                                if remainingSegments == 1 {
                                    if !isSet(s.HasSeparator()) && g.attrSet&sgaOuterSeparator != 0 {
                                        s.Separator(g.outerSeparator)
                                    }
                                    if !isSet(s.GetPadding()) && g.attrSet&sgaOuterPadding != 0 {
                        Severity: Minor
                        Found in outputs/group.go and 1 other location - About 30 mins to fix
                        outputs/group.go on lines 193..200

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

                        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