AndyObtiva/glimmer-dsl-swt

View on GitHub

Showing 235 of 401 total issues

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

          def dispose(dispose_images: true, dispose_patterns: true, redraw: true)
            Glimmer::SWT::DisplayProxy.instance.auto_exec do
              # including classes could override to dispose of resources first
              # afterwards, parent removes from its path segments with post_dispose_content
              parent.post_dispose_content(self) if parent.is_a?(Path)
Severity: Minor
Found in lib/glimmer/swt/custom/shape/path_segment.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 add_to_swt_path has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

          def add_to_swt_path(swt_path)
            the_path_segment_args = path_segment_args.dup
            the_path_segment_args = the_path_segment_args.first if the_path_segment_args.size == 1 && the_path_segment_args.first.is_a?(Array)
            if !is_a?(Point) && self.class != Path
              if !previous_point_connected?
Severity: Minor
Found in lib/glimmer/swt/custom/shape/path_segment.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 default_width has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

        def default_width
          default_width_dependencies = [shapes.empty? && max_width, shapes.size == 1 && shapes.first.max_width? && parent.size.x, shapes.size >= 1 && !shapes.first.max_width? && shapes.map {|s| s.max_width? ? 0 : s.x_end}]
          if default_width_dependencies != @default_width_dependencies
            # Do not repeat calculations
            max_width, parent_size_x, x_ends = @default_width_dependencies = default_width_dependencies
Severity: Minor
Found in lib/glimmer/swt/custom/shape.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 default_height has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

        def default_height
          default_height_dependencies = [shapes.empty? && max_height, shapes.size == 1 && shapes.first.max_height? && parent.size.y, shapes.size >= 1 && !shapes.first.max_height? && shapes.map {|s| s.max_height? ? 0 : s.y_end}]
          if default_height_dependencies != @default_height_dependencies
            # Do not repeat calculations
            max_height, parent_size_y, y_ends = @default_height_dependencies = default_height_dependencies
Severity: Minor
Found in lib/glimmer/swt/custom/shape.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 countdown_group_button_composite has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def countdown_group_button_composite
    composite {
      row_layout {
        margin_width 0
        margin_height 0
Severity: Minor
Found in samples/elaborate/timer.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 interpret has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

        def interpret(parent, keyword, *args, &block)
          # TODO reconcile this with the actual org.eclipse.swt.widgets.Dialog widget (maybe rename this as dialog_shell)
          if keyword == 'dialog'
            args = [parent] + args unless parent.nil?
            args += [:dialog_trim, :application_modal]
Severity: Minor
Found in lib/glimmer/dsl/swt/dialog_expression.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 get_attribute has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def get_attribute(attribute_name)
        widget_custom_attribute = widget_custom_attribute_mapping[attribute_name.to_s]
        swt_widget_operation = false
        result = nil
        auto_exec do
Severity: Minor
Found in lib/glimmer/swt/widget_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 deregister has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def deregister
        return if @swt_widget&.is_disposed || @swt_display&.is_disposed
        if @swt_display
          if @filter
            @swt_display.removeFilter(@event_type, @swt_listener)
Severity: Minor
Found in lib/glimmer/swt/widget_listener_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

                negative ? ~bit_value : bit_value
Severity: Major
Found in lib/glimmer/swt/style_constantizable.rb - About 45 mins to fix

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

          def place_enemy_ships!
            ship_collection = @ship_collections[:enemy]
            ship_collection.ships.values.each do |ship|
              until ship.top_left_cell
                random_row_index = (rand * Grid::HEIGHT).to_i
    Severity: Minor
    Found in samples/elaborate/battleship/model/game.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 add_to_geometry has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

              def add_to_geometry(geometry)
                the_path_segment_geometry_args = path_segment_geometry_args.dup
                if !is_a?(Point) && self.class != Path
                  if !previous_point_connected?
                    if the_path_segment_geometry_args.count == default_path_segment_arg_count
    Severity: Minor
    Found in lib/glimmer/swt/custom/shape/path_segment.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 printer.start_page
                      printer_gc.drawImage(image, 0, 0)
                      printer.end_page
                    else
                      success = false
    Severity: Major
    Found in lib/glimmer/swt/widget_proxy.rb - About 45 mins to fix

      Method include? has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

                  def include?(x1, y1, x2, y2, x, y)
      Severity: Minor
      Found in lib/glimmer/swt/custom/shape/line.rb - About 45 mins to fix

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

                def amend_method_name_options_based_on_properties!
                  @original_method_name = @method_name
                  return if @name == 'point'
                  if (@name != 'text' && @name != 'string' && has_some_background? && !has_some_foreground?) || (@name == 'path' && has_some_background?)
                    @options[:fill] = true
        Severity: Minor
        Found in lib/glimmer/swt/custom/shape.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 respond_to? has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

                def respond_to?(method_name, *args, &block)
                  dsl_mode = @dsl_mode || args.last.is_a?(Hash) && args.last[:dsl]
                  if dsl_mode
                    args = args[0...-1] if args.last.is_a?(Hash) && args.last[:dsl]
                    super(method_name, *args, &block)
        Severity: Minor
        Found in lib/glimmer/swt/custom/code_text.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 move_by has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

                def move_by(x_delta, y_delta)
                  if respond_to?(:x) && respond_to?(:y) && respond_to?(:x=) && respond_to?(:y=)
                    if default_x?
                      self.x_delta += x_delta
                    else
        Severity: Minor
        Found in lib/glimmer/swt/custom/shape.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 absolute_point_array has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

                  def absolute_point_array
                    point_array = args.size > 1 ? args : self.point_array
                    if parent.is_a?(Shape)
                      point_array.each_with_index.map do |coordinate, i|
                        if i.even?
        Severity: Minor
        Found in lib/glimmer/swt/custom/shape/polyline.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

        Consider simplifying this complex logical expression.
        Open

                  if (@name != 'text' && @name != 'string' && has_some_background? && !has_some_foreground?) || (@name == 'path' && has_some_background?)
                    @options[:fill] = true
                  elsif !has_some_background? && has_some_foreground?
                    @options[:fill] = false
                  elsif @name == 'rectangle' && has_some_background? && has_some_foreground?
        Severity: Major
        Found in lib/glimmer/swt/custom/shape.rb - About 40 mins to fix

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

                def update_table_item_properties_from_model(table_item, row_index, column_index, model, model_attribute)
          Severity: Minor
          Found in lib/glimmer/data_binding/table_items_binding.rb - About 35 mins to fix

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

              def stick_figure(x, y, width, height, &block)
            Severity: Minor
            Found in samples/hello/hello_shape.rb - About 35 mins to fix
              Severity
              Category
              Status
              Source
              Language