kaspernj/pulseaudio

View on GitHub

Showing 40 of 40 total issues

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

        Method initialize has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

          def initialize(args = {})
            raise "An instance already exists." if @@events_instance
            
            @args = args
            @connects = {}
        Severity: Minor
        Found in include/pulseaudio_events.rb - About 1 hr 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 initialize has 35 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def initialize(args = {})
            raise "An instance already exists." if @@events_instance
            
            @args = args
            @connects = {}
        Severity: Minor
        Found in include/pulseaudio_events.rb - About 1 hr to fix

          Method list has 33 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def self.list
              list = %x[pactl list sinks]
              sinks = [] unless block_given?
              
              list.scan(/(\n|^)Sink #(\d+)\s+([\s\S]+?)Formats:\s+(.+?)\n/) do |match|
          Severity: Minor
          Found in include/pulseaudio_sink.rb - About 1 hr to fix

            Method list has 29 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def self.list
                list = %x[pactl list sink-inputs]
                inputs = [] unless block_given?
                
                list.scan(/(\n|^)Sink Input #(\d+)\s+([\s\S]+?)(\n\n|\Z)/) do |match|
            Severity: Minor
            Found in include/pulseaudio_sink_input.rb - About 1 hr to fix

              Method list has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def self.list
                  list = %x[pactl list sources]
                  sources = [] unless block_given?
                  
                  list.scan(/(\n|^)Source #(\d+)\s+([\s\S]+?)Formats:\s+(.+?)\n/) do |match|
              Severity: Minor
              Found in include/pulseaudio_source.rb - About 1 hr 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 call has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def call(args)
                      @connects_mutex.synchronize do
                        @connects.each do |id, connect_data|
                          call = true
                          
                  Severity: Minor
                  Found in include/pulseaudio_events.rb - 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 list has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def self.list
                      list = %x[pactl list sink-inputs]
                      inputs = [] unless block_given?
                      
                      list.scan(/(\n|^)Sink Input #(\d+)\s+([\s\S]+?)(\n\n|\Z)/) do |match|
                  Severity: Minor
                  Found in include/pulseaudio_sink_input.rb - 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 list has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def self.list
                      list = %x[pacmd list-source-outputs]
                      
                      outputs = [] unless block_given?
                      
                  Severity: Minor
                  Found in include/pulseaudio_source_output.rb - 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 list has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def self.list
                      list = %x[pactl list sources]
                      sources = [] unless block_given?
                      
                      list.scan(/(\n|^)Source #(\d+)\s+([\s\S]+?)Formats:\s+(.+?)\n/) do |match|
                  Severity: Minor
                  Found in include/pulseaudio_source.rb - 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 list has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def self.list
                      list = %x[pactl list sinks]
                      sinks = [] unless block_given?
                      
                      list.scan(/(\n|^)Sink #(\d+)\s+([\s\S]+?)Formats:\s+(.+?)\n/) do |match|
                  Severity: Minor
                  Found in include/pulseaudio_sink.rb - 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

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

                    def on_tvSources_cursor_changed
                      return nil if @reloading
                      sel = @ui["tvSources"].sel
                      return nil if !sel
                      
                  Severity: Minor
                  Found in gui/choose_active_sink/choose_active_sink.rb and 1 other location - About 50 mins to fix
                  gui/choose_active_sink/choose_active_sink.rb on lines 55..69

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

                  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_tvSinks_cursor_changed
                      return nil if @reloading
                      sel = @ui["tvSinks"].sel
                      return nil if !sel
                      
                  Severity: Minor
                  Found in gui/choose_active_sink/choose_active_sink.rb and 1 other location - About 50 mins to fix
                  gui/choose_active_sink/choose_active_sink.rb on lines 72..86

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

                  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_sources
                      @reloading = true
                      
                      @ui["tvSources"].model.clear
                      PulseAudio::Source.list do |source|
                  Severity: Minor
                  Found in gui/choose_active_sink/choose_active_sink.rb and 1 other location - About 50 mins to fix
                  gui/choose_active_sink/choose_active_sink.rb on lines 26..37

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

                  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
                      @ui["tvSinks"].model.clear
                      PulseAudio::Sink.list do |sink|
                        append_data = @ui["tvSinks"].append([sink.sink_id, sink.args[:props]["description"]])
                  Severity: Minor
                  Found in gui/choose_active_sink/choose_active_sink.rb and 1 other location - About 50 mins to fix
                  gui/choose_active_sink/choose_active_sink.rb on lines 40..52

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

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

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

                    def self.auto_redirect_new_outputs_to_default_source
                      raise "Already redirecting!" if @auto_redirect_connect_id
                      
                      @auto_redirect_connect_id = PulseAudio::Events.instance.connect(:event => :new, :element => "source-output") do |data|
                        begin
                  Severity: Minor
                  Found in include/pulseaudio_source_output.rb and 1 other location - About 45 mins to fix
                  include/pulseaudio_sink_input.rb on lines 11..18

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

                  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