kaspernj/pulseaudio

View on GitHub
gui/choose_active_sink_gtk3/choose_active_sink_gtk3.rb

Summary

Maintainability
D
1 day
Test Coverage

Class Choose_active_sink_gtk3 has 28 methods (exceeds 20 allowed). Consider refactoring.
Open

class PulseAudio::Gui::Choose_active_sink_gtk3
  attr_reader :ui
  
  def initialize
    @ui = Gtk3assist::Builder.new.add_from_file("#{File.dirname(__FILE__)}/choose_active_sink.glade")
Severity: Minor
Found in gui/choose_active_sink_gtk3/choose_active_sink_gtk3.rb - About 3 hrs to fix

    File choose_active_sink_gtk3.rb has 302 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    class PulseAudio::Gui::Choose_active_sink_gtk3
      attr_reader :ui
      
      def initialize
        @ui = Gtk3assist::Builder.new.add_from_file("#{File.dirname(__FILE__)}/choose_active_sink.glade")
    Severity: Minor
    Found in gui/choose_active_sink_gtk3/choose_active_sink_gtk3.rb - About 3 hrs to fix

      Method initialize has 51 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def initialize
          @ui = Gtk3assist::Builder.new.add_from_file("#{File.dirname(__FILE__)}/choose_active_sink.glade")
          @ui.connect_signals{|h| method(h)}
          
          #Init treeviews.
      Severity: Major
      Found in gui/choose_active_sink_gtk3/choose_active_sink_gtk3.rb - About 2 hrs to fix

        Consider simplifying this complex logical expression.
        Open

              if !vol_closest or (vol_perc < level and diff = (level - vol_perc) and diff < vol_closest_dif) or (vol_perc >= level and diff = (vol_perc - level) and diff < vol_closest_dif)
                vol_closest = level
                vol_closest_dif = diff
              end
        Severity: Major
        Found in gui/choose_active_sink_gtk3/choose_active_sink_gtk3.rb - About 1 hr to fix

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

            def on_tvSinks_cursor_changed(*args)
              begin
                return nil if @reloading or !@tv_sinks
                sel = @tv_sinks.sel
                return nil if !sel
          Severity: Minor
          Found in gui/choose_active_sink_gtk3/choose_active_sink_gtk3.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 update_icon has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

            def update_icon
              #Get the current active sink which should be manipulated.
              return nil if !@sink
              
              
          Severity: Minor
          Found in gui/choose_active_sink_gtk3/choose_active_sink_gtk3.rb - 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

          Method on_remove has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            def on_remove(args)
              event, ele, ele_id = args[:args][:event].to_sym, args[:args][:element].to_s, args[:args][:element_id].to_i
              
              if ele == "sink"
                tv = @tv_sinks
          Severity: Minor
          Found in gui/choose_active_sink_gtk3/choose_active_sink_gtk3.rb - About 25 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

            def reload_sources
              @reloading = true
              
              @tv_sources.model.clear
              PulseAudio::Source.list do |source|
          Severity: Minor
          Found in gui/choose_active_sink_gtk3/choose_active_sink_gtk3.rb and 1 other location - About 30 mins to fix
          gui/choose_active_sink_gtk3/choose_active_sink_gtk3.rb on lines 249..261

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

          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

            def reload_sinks
              @reloading = true
              @tv_sinks.model.clear
              PulseAudio::Sink.list do |sink|
                append_data = self.add_sink(sink)
          Severity: Minor
          Found in gui/choose_active_sink_gtk3/choose_active_sink_gtk3.rb and 1 other location - About 30 mins to fix
          gui/choose_active_sink_gtk3/choose_active_sink_gtk3.rb on lines 269..282

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

          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 3 locations. Consider refactoring.
          Open

              @tv_sources = Gtk3assist::Treeview.new(
                :tv => @ui["tvSources"],
                :model => :liststore,
                :sort_col => :name,
                :cols => [
          Severity: Minor
          Found in gui/choose_active_sink_gtk3/choose_active_sink_gtk3.rb and 2 other locations - About 20 mins to fix
          gui/choose_active_sink_gtk3/choose_active_sink_gtk3.rb on lines 9..17
          gui/choose_active_sink_gtk3/choose_active_sink_gtk3.rb on lines 33..41

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

          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 3 locations. Consider refactoring.
          Open

              @tv_applications = Gtk3assist::Treeview.new(
                :tv => @ui["tvApplications"],
                :model => :liststore,
                :sort_col => :name,
                :cols => [
          Severity: Minor
          Found in gui/choose_active_sink_gtk3/choose_active_sink_gtk3.rb and 2 other locations - About 20 mins to fix
          gui/choose_active_sink_gtk3/choose_active_sink_gtk3.rb on lines 9..17
          gui/choose_active_sink_gtk3/choose_active_sink_gtk3.rb on lines 21..29

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

          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 3 locations. Consider refactoring.
          Open

              @tv_sinks = Gtk3assist::Treeview.new(
                :tv => @ui["tvSinks"],
                :model => :liststore,
                :sort_col => :name,
                :cols => [
          Severity: Minor
          Found in gui/choose_active_sink_gtk3/choose_active_sink_gtk3.rb and 2 other locations - About 20 mins to fix
          gui/choose_active_sink_gtk3/choose_active_sink_gtk3.rb on lines 21..29
          gui/choose_active_sink_gtk3/choose_active_sink_gtk3.rb on lines 33..41

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

          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

            def on_hscaleSinkVolume_change_value
              GLib.source_remove(@timeout_sink_volume_change) if @timeout_sink_volume_change
              
              @timeout_sink_volume_change = GLib.timeout_add(GLib::PRIORITY_DEFAULT_IDLE, 50, proc{
                @timeout_sink_volume_change = nil
          Severity: Minor
          Found in gui/choose_active_sink_gtk3/choose_active_sink_gtk3.rb and 1 other location - About 15 mins to fix
          gui/choose_active_sink_gtk3/choose_active_sink_gtk3.rb on lines 199..205

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

          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

            def on_hscaleSourceVolume_change_value
              GLib.source_remove(@timeout_source_volume_change) if @timeout_source_volume_change
              
              @timeout_source_volume_change = GLib.timeout_add(GLib::PRIORITY_DEFAULT_IDLE, 50, proc{
                @timeout_source_volume_change = nil
          Severity: Minor
          Found in gui/choose_active_sink_gtk3/choose_active_sink_gtk3.rb and 1 other location - About 15 mins to fix
          gui/choose_active_sink_gtk3/choose_active_sink_gtk3.rb on lines 190..196

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

          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

          There are no issues that match your filters.

          Category
          Status