AndyObtiva/glimmer-dsl-swt

View on GitHub

Showing 401 of 401 total issues

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

            radio: {
              widget_value_property: :selection,
              editor_gui: lambda do |args, model, property, table_proxy|
                first_time = true
                table_proxy.table_editor.minimumHeight = 25
Severity: Major
Found in lib/glimmer/swt/table_proxy.rb and 1 other location - About 1 hr to fix
lib/glimmer/swt/table_proxy.rb on lines 111..133

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

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

            checkbox: {
              widget_value_property: :selection,
              editor_gui: lambda do |args, model, property, table_proxy|
                first_time = true
                table_proxy.table_editor.minimumHeight = 25
Severity: Major
Found in lib/glimmer/swt/table_proxy.rb and 1 other location - About 1 hr to fix
lib/glimmer/swt/table_proxy.rb on lines 198..220

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

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 games has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def games
      if @games.nil?
        @games = []
        baseball_team_combinations = BaseballTeam.all.combination(2).to_a
        current_day = first_day
Severity: Minor
Found in samples/hello/hello_refined_table.rb - About 1 hr to fix

    Method launch has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def launch(application, jruby_options: [], env_vars: {}, glimmer_options: {})
            jruby_options_string = jruby_options.join(' ') + ' ' if jruby_options.any?
            env_vars = env_vars.merge(glimmer_option_env_vars(glimmer_options))
            env_vars.each do |k,v|
              ENV[k] = v
    Severity: Minor
    Found in lib/glimmer/launcher.rb - About 1 hr to fix

      Method drag_and_move= has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              def drag_and_move=(drag_and_move_value)
                deregister_drag_listeners if @drag_source
                drag_and_move_old_value = @drag_and_move
                @drag_and_move = drag_and_move_value
                if @drag_and_move && !drag_and_move_old_value
      Severity: Minor
      Found in lib/glimmer/swt/custom/shape.rb - About 1 hr to fix

        Method can_handle_drag_observation_request? has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

              def can_handle_drag_observation_request?(observation_request)
                auto_exec do
                  return false unless swt_widget.is_a?(Control)
                  potential_drag_source = @drag_source_proxy.nil?
                  ensure_drag_source_proxy
        Severity: Minor
        Found in lib/glimmer/swt/widget_proxy.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 set_attribute has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

              def set_attribute(attribute_name, *args)
                swt_widget_operation = false
                result = nil
                Glimmer::SWT::DisplayProxy.instance.auto_exec do
                  result = if proxy_source_object&.respond_to?(attribute_setter(attribute_name))
        Severity: Minor
        Found in lib/glimmer/swt/proxy_properties.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 interpret has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

                def interpret(parent, keyword, *args, &block)
                  options = args.last.is_a?(Hash) ? args.last : {}
                  coordinate_args = args.size == (options.empty? ? 2 : 3)
                  args.unshift(parent) unless parent.nil? || options[:top_level]
                  @create_pixel_by_pixel = coordinate_args && block&.parameters&.count == 2
        Severity: Minor
        Found in lib/glimmer/dsl/swt/image_expression.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 rotate! has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

              def rotate!(direction)
                return if stopped?
                can_rotate = nil
                new_blocks = nil
                game.hypothetical do
        Severity: Minor
        Found in samples/elaborate/tetris/model/tetromino.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 method_missing has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

                def method_missing(method_name, *args, &block)
                  dsl_mode = @dsl_mode || args.last.is_a?(Hash) && args.last[:dsl]
                  if dsl_mode
                    args.pop 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 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 config has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                def config
                  project_name = File.basename(File.expand_path('.'))
                  if !File.exists?('config/warble.rb')
                    puts 'Generating JAR configuration (config/warble.rb) to use with Warbler...'
                    FileUtils.mkdir_p('config')
        Severity: Minor
        Found in lib/glimmer/rake_task/package.rb - About 1 hr to fix

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

                def place_ship!(ship)
                  begin
                    old_ship_top_left_cell = ship.top_left_cell
                    old_ship_orientation = ship.orientation
                    ship.top_left_cell = self
          Severity: Minor
          Found in samples/elaborate/battleship/model/cell.rb - About 1 hr to fix

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

                  def populate_table(model_collection, parent, column_properties, internal_sort: false)
                    selected_table_item_models = parent.swt_widget.getSelection.map(&:get_data)
                    parent.finish_edit!
                    dispose_start_index = @last_model_collection_attribute_values &&
                                          (model_collection.count < @last_model_collection_attribute_values.count) &&
            Severity: Minor
            Found in lib/glimmer/data_binding/table_items_binding.rb - About 1 hr to fix

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

                      def calculate_paint_args!
                        unless @calculated_paint_args
                          if @name == 'pixel'
                            @name = 'point'
                            # optimized performance calculation for pixel points
              Severity: Minor
              Found in lib/glimmer/swt/custom/shape.rb - About 1 hr to fix

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

                        def delegate_observation_request_to_radios(observation_request, &block)
                          if observation_request != 'on_widget_disposed'
                            radios.count.times do |index|
                              radio = radios[index]
                              label = labels[index]
                Severity: Minor
                Found in lib/glimmer/swt/custom/radio_group.rb - About 1 hr to fix

                  Method calculate_points has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    def calculate_points
                      puts "Background calculation activated at zoom #{zoom}" if @background
                      if @points_calculated
                        puts "Points calculated already. Returning previously calculated points..."
                        return @points
                  Severity: Minor
                  Found in samples/elaborate/mandelbrot_fractal.rb - About 1 hr to fix

                    Method countdown_group_button_composite has 26 lines of code (exceeds 25 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 1 hr to fix

                      Method enemy_attack! has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                            def enemy_attack!
                              begin
                                cell = nil
                                if @enemy_moves.any? && @enemy_moves.last.hit? && !@enemy_moves.last.ship.sunk?
                                  if @enemy_moves[-2].nil? || !@enemy_moves[-2].hit?
                      Severity: Minor
                      Found in samples/elaborate/battleship/model/game.rb - About 1 hr to fix

                        Method drag_source= has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                                def drag_source=(drag_source_value)
                                  deregister_drag_listeners if @drag_and_move
                                  drag_source_old_value = @drag_source
                                  @drag_source = drag_source_value
                                  if @drag_source && !drag_source_old_value
                        Severity: Minor
                        Found in lib/glimmer/swt/custom/shape.rb - About 1 hr to fix

                          Method apply_shape_arg_conversions! has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                                  def apply_shape_arg_conversions!
                                    if @args.size > 1 && (['polygon', 'polyline'].include?(@name))
                                      @args[0] = @args.dup
                                      @args[1..-1] = []
                                    end
                          Severity: Minor
                          Found in lib/glimmer/swt/custom/shape.rb - About 1 hr to fix
                            Severity
                            Category
                            Status
                            Source
                            Language