AndyObtiva/glimmer-dsl-libui

View on GitHub

Showing 312 of 312 total issues

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

        def x(value = nil)
          if value.nil?
            @args.size > 3 ? @args[1] : (@options[:x] || 0)
          else
            if @args.size > 3
Severity: Minor
Found in lib/glimmer/libui/control_proxy/image_proxy.rb and 1 other location - About 45 mins to fix
lib/glimmer/libui/control_proxy/image_proxy.rb on lines 115..127

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

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

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

                    unless background.nil?
                      background_attribute = ::LibUI.new_background_attribute(@background[:r].to_f / 255.0, @background[:g].to_f / 255.0, @background[:b].to_f / 255.0, @background[:a] || 1.0)
                      ::LibUI.attributed_string_set_attribute(@parent_proxy.attributed_string, background_attribute, @start, @start + @string.bytesize)
            Severity: Minor
            Found in lib/glimmer/libui/attributed_string.rb and 1 other location - About 45 mins to fix
            lib/glimmer/libui/attributed_string.rb on lines 148..150

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

            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

                    unless color.nil?
                      color_attribute = ::LibUI.new_color_attribute(@color[:r].to_f / 255.0, @color[:g].to_f / 255.0, @color[:b].to_f / 255.0, @color[:a] || 1.0)
                      ::LibUI.attributed_string_set_attribute(@parent_proxy.attributed_string, color_attribute, @start, @start + @string.bytesize)
            Severity: Minor
            Found in lib/glimmer/libui/attributed_string.rb and 1 other location - About 45 mins to fix
            lib/glimmer/libui/attributed_string.rb on lines 152..154

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

            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

                    vertical_box {
                      address_form(address: @address2) {
                        header {
                          label('Billing Address') {
                            stretchy false
            Severity: Minor
            Found in examples/class_based_custom_control_slots.rb and 1 other location - About 45 mins to fix
            examples/class_based_custom_control_slots.rb on lines 88..109

            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

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

              def initialize
                @contacts = [
                  Contact.new('Lisa Sky', 'lisa@sky.com', '720-523-4329', 'Denver', 'CO'),
                  Contact.new('Jordan Biggins', 'jordan@biggins.com', '617-528-5399', 'Boston', 'MA'),
                  Contact.new('Mary Glass', 'mary@glass.com', '847-589-8788', 'Elk Grove Village', 'IL'),
            Severity: Major
            Found in examples/form_table.rb and 2 other locations - About 45 mins to fix
            examples/form_table2.rb on lines 10..17
            examples/form_table3.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

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

              def sort_zero_or_one_table_column(tc, column)
                puts "Clicked column #{column}: #{tc.name}"
                selected_row = @zero_or_one_table.selection && @zero_or_one_table_data[@zero_or_one_table.selection]
                tc.toggle_sort_indicator
                @zero_or_one_table_data.sort_by! { |row_data| row_data[column] }
            Severity: Minor
            Found in examples/basic_table_selection3.rb and 1 other location - About 45 mins to fix
            examples/basic_table_selection3.rb on lines 272..278

            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