AndyObtiva/glimmer-dsl-libui

View on GitHub

Showing 156 of 312 total issues

Method add_content has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

        def add_content(custom_control, keyword, *args, &block)
          options = args.last.is_a?(Hash) ? args.last : {}
          options[:post_add_content] = true if !options.include?(:post_add_content)
          # TODO consider avoiding source_location
          if block.source_location == custom_control.content&.__getobj__&.source_location
Severity: Minor
Found in lib/glimmer/dsl/libui/custom_control_expression.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 perfect_shape has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

        def perfect_shape
          require 'perfect-shape'
          the_perfect_shape_dependencies = perfect_shape_dependencies
          if the_perfect_shape_dependencies != @perfect_shape_dependencies
            draw_fill_mode, _ = @perfect_shape_dependencies = the_perfect_shape_dependencies
Severity: Minor
Found in lib/glimmer/libui/control_proxy/path_proxy.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

Avoid deeply nested control flow statements.
Open

              if hours > 0
                @hour_spinbox.value = hours -= 1
                @min_spinbox.value = minutes = MINUTE_MAX
                @sec_spinbox.value = seconds = SECOND_MAX
              end
Severity: Major
Found in examples/timer2.rb - About 45 mins to fix

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

            def post_add_content
              if area_image?
                @shapes = nil
                super
                if @parent_proxy.nil? && AreaProxy.current_area_draw_params
    Severity: Minor
    Found in lib/glimmer/libui/control_proxy/image_proxy.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 destroy has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

            def destroy
              Fiddle.free @red unless @red.nil?
              Fiddle.free @green unless @green.nil?
              Fiddle.free @blue unless @blue.nil?
              Fiddle.free @alpha unless @alpha.nil?
    Severity: Minor
    Found in lib/glimmer/libui/control_proxy/color_button_proxy.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 extent_height has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

            def extent_height
              if @extent_height.to_f > 0
                @extent_height
              else # TODO auto calculate extents
                children_max_size = children.map(&:font).map {|font| font[:size] if font.respond_to?(:[]) }.compact.max
    Severity: Minor
    Found in lib/glimmer/libui/control_proxy/text_proxy.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 checked has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

              def checked(value = nil)
                if value.nil?
                  super()
                else
                  super
    Severity: Minor
    Found in lib/glimmer/libui/control_proxy/menu_item_proxy/radio_menu_item_proxy.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

    Avoid deeply nested control flow statements.
    Open

                  if hours > 0
                    self.hour = hours -= 1
                    self.min = minutes = MINUTE_MAX
                    self.sec = seconds = SECOND_MAX
                  end
    Severity: Major
    Found in examples/timer.rb - About 45 mins to fix

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

              def post_initialize_child(child)
                child.left = 0 if child.left.nil?
                child.top = 0 if child.top.nil?
                child.xspan = 1 if child.xspan.nil?
                child.yspan = 1 if child.yspan.nil?
      Severity: Minor
      Found in lib/glimmer/libui/control_proxy/grid_proxy.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 hex_to_rgb has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

            def hex_to_rgb(value)
              if value.is_a?(String)
                value = value[2..-1] if value.start_with?('0x')
                value = value[1..-1] if value.start_with?('#')
                value = value.chars.map {|char| [char, char]}.flatten.join if value.length == 3
      Severity: Minor
      Found in lib/glimmer/libui.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

      Avoid deeply nested control flow statements.
      Open

                        if new_row_data != last_cell_row_for(row) && model
                          ::LibUI.table_model_row_changed(model, row)
                          notify_custom_listeners('on_changed', row, :changed, new_row_data)
                        end
      Severity: Major
      Found in lib/glimmer/libui/control_proxy/table_proxy.rb - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                      if hours == 0 && minutes == 0 && seconds == 0
                        @start_button.enabled = true
                        @stop_button.enabled = false
                        @started = false
                        unless @played
        Severity: Major
        Found in examples/timer2.rb - About 45 mins to fix

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

              def sort
                selected_data = table_presenter.selection_mode == :zero_or_many ? table_presenter.selected_rows : table_presenter.selected_row
                toggle_sort_indicator
                table_presenter.data.sort_by! { |row_data| row_data[column] }
                table_presenter.data.reverse! if sort_indicator == :descending
          Severity: Minor
          Found in examples/basic_table_selection2.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

          Avoid deeply nested control flow statements.
          Open

                        if hours == 0 && minutes == 0 && seconds == 0
                          self.started = false
                          unless @played
                            play_alarm
                            msg_box('Alarm', 'Countdown Is Finished!')
          Severity: Major
          Found in examples/timer.rb - About 45 mins to fix

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

                  def initialize(keyword, parent, args, &block)
                    @keyword = keyword
                    @custom_control = CustomControl.custom_controls_being_interpreted.last
                    @parent_custom_control = parent if parent.is_a?(CustomControl)
                    @parent_proxy = parent.is_a?(CustomControl) ? parent.body_root : parent
            Severity: Minor
            Found in lib/glimmer/libui/control_proxy.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 initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                  def initialize(keyword, parent, args, options, &content)
            Severity: Minor
            Found in lib/glimmer/libui/custom_shape.rb - About 35 mins to fix

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

                    def initialize(keyword, parent, args, options, &content)
              Severity: Minor
              Found in lib/glimmer/libui/custom_control.rb - About 35 mins to fix

                Method setup_circle_factory has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                  def setup_circle_factory
                    consumer = Proc.new do
                      unless @game_over
                        if @circles_data.empty?
                          # start with 3 circles to make more challenging
                Severity: Minor
                Found in examples/color_the_circles.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 register_column_listeners has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                        def register_column_listeners
                          # register accumulated column listeners after table content is closed
                          return if @columns.nil? || @columns.empty?
                          if @columns.any? {|column| column.is_a?(Column)}
                            ::LibUI.table_header_on_clicked(@libui) do |_, column_index|
                Severity: Minor
                Found in lib/glimmer/libui/control_proxy/table_proxy.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 configure_sorting has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                        def configure_sorting
                          if sortable?
                            columns.each do |column_object|
                              next unless column_object.is_a?(Column) && !column_object.is_a?(Column::ButtonColumnProxy)
                              column_object.on_clicked do |column_proxy, column|
                Severity: Minor
                Found in lib/glimmer/libui/control_proxy/table_proxy.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

                Severity
                Category
                Status
                Source
                Language