AndyObtiva/glimmer-dsl-swt

View on GitHub

Showing 401 of 401 total issues

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

      def evaluate_sw_ne_diagonal_win
        sw_ne_coordinates = [
          [[3, 0], [2, 1], [1, 2], [0, 3]],
          [[4, 0], [3, 1], [2, 2], [1, 3], [0, 4]],
          [[5, 0], [4, 1], [3, 2], [2, 3], [1, 4], [0, 5]],
Severity: Major
Found in samples/elaborate/connect4/model/grid.rb and 1 other location - About 2 hrs to fix
samples/elaborate/connect4/model/grid.rb on lines 137..146

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

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 evaluate_se_nw_diagonal_win
        sw_ne_coordinates = [
          [[0, 3], [1, 4], [2, 5], [3, 6]],
          [[0, 2], [1, 3], [2, 4], [3, 5], [4, 6]],
          [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6]],
Severity: Major
Found in samples/elaborate/connect4/model/grid.rb and 1 other location - About 2 hrs to fix
samples/elaborate/connect4/model/grid.rb on lines 125..134

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

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 print has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

      def print(gc=nil, job_name: nil)
        if gc.is_a?(org.eclipse.swt.graphics.GC)
          @swt_widget.print(gc)
        else
          image = Image.new(DisplayProxy.instance.swt_display, bounds)
Severity: Minor
Found in lib/glimmer/swt/widget_proxy.rb - About 2 hrs 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 same_table_data? has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

      def same_table_data?(new_model_collection)
        (["text"] + TABLE_ITEM_PROPERTIES).all? do |table_item_property|
          table_cells = @table.swt_widget.items.map do |item|
            model = item.get_data
            @table.column_properties.each_with_index.map do |column_property, i|
Severity: Minor
Found in lib/glimmer/data_binding/table_items_binding.rb - About 2 hrs 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

Class Path has 24 methods (exceeds 20 allowed). Consider refactoring.
Open

        class Path < Shape
          include PathSegment # a path may behave as a path segment in another path
          
          attr_reader :swt_path, :path_segments
          attr_accessor :calculated_path_args
Severity: Minor
Found in lib/glimmer/swt/custom/shape/path.rb - About 2 hrs to fix

    Method custom_shell_gem has 65 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            def custom_shell_gem(custom_shell_name, namespace)
              gem_name = "glimmer-cs-#{compact_name(custom_shell_name)}"
              gem_summary = "#{human_name(custom_shell_name)} - Glimmer Custom Shell"
              begin
                custom_shell_keyword = dsl_widget_name(custom_shell_name)
    Severity: Major
    Found in lib/glimmer/rake_task/scaffold.rb - About 2 hrs to fix

      Method apply_shape_arg_conversions! has a Cognitive Complexity of 19 (exceeds 5 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 2 hrs 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 start has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

              def start
                return if @start_number > 0 && started?
                @start_number += 1
                @start_time = Time.now
                @duration = 0
      Severity: Minor
      Found in lib/glimmer/swt/custom/animation.rb - About 2 hrs 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

      File tetromino.rb has 271 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      require_relative 'block'
      
      require 'matrix'
      
      class Tetris
      Severity: Minor
      Found in samples/elaborate/tetris/model/tetromino.rb - About 2 hrs to fix

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

              def initialize(parent, *args, swt_transform: nil, multiply: false)
                Glimmer::SWT::DisplayProxy.instance.auto_exec do
                  @parent = parent
                  @multiply = multiply
                  if swt_transform.nil?
        Severity: Minor
        Found in lib/glimmer/swt/transform_proxy.rb - About 2 hrs 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 handle_observation_request has 60 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                def handle_observation_request(observation_request, source_observation_request: nil, &block)
                  if observation_request.to_s == 'on_shape_disposed'
                    @on_shape_disposed_handlers ||= []
                    @on_shape_disposed_handlers << block
                    return ShapeListenerProxy.new(shape: self, drawable: drawable, shape_listener_block: block, observation_request: 'on_shape_disposed')
        Severity: Major
        Found in lib/glimmer/swt/custom/shape.rb - About 2 hrs to fix

          File hello_table.rb has 266 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          require 'glimmer-dsl-swt'
          
          class HelloTable
            class BaseballGame
              class << self
          Severity: Minor
          Found in samples/hello/hello_table.rb - About 2 hrs to fix

            Method call has 59 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  def call(*args)
                    options = args.last.is_a?(Hash) ? args.pop : {}
                    internal_sort = options[:internal_sort] || false
                    new_model_collection = args.first
                    Glimmer::SWT::DisplayProxy.instance.auto_exec(override_sync_exec: @model_binding.binding_options[:sync_exec], override_async_exec: @model_binding.binding_options[:async_exec]) do
            Severity: Major
            Found in lib/glimmer/data_binding/table_items_binding.rb - About 2 hrs to fix

              Class Polygon has 22 methods (exceeds 20 allowed). Consider refactoring.
              Open

                      class Polygon < Shape
                        def parameter_names
                          [:point_array]
                        end
                        
              Severity: Minor
              Found in lib/glimmer/swt/custom/shape/polygon.rb - About 2 hrs to fix

                Method for has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                Open

                        def for(underscored_custom_shape_name)
                          unless flyweight_custom_shape_classes.keys.include?(underscored_custom_shape_name)
                            begin
                              extracted_namespaces = underscored_custom_shape_name.
                                to_s.
                Severity: Minor
                Found in lib/glimmer/ui/custom_shape.rb - About 2 hrs 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 for has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                Open

                        def for(underscored_custom_widget_name)
                          unless flyweight_custom_widget_classes.keys.include?(underscored_custom_widget_name)
                            begin
                              extracted_namespaces = underscored_custom_widget_name.
                                to_s.
                Severity: Minor
                Found in lib/glimmer/ui/custom_widget.rb - About 2 hrs 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 custom_shell_gem has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                Open

                        def custom_shell_gem(custom_shell_name, namespace)
                          gem_name = "glimmer-cs-#{compact_name(custom_shell_name)}"
                          gem_summary = "#{human_name(custom_shell_name)} - Glimmer Custom Shell"
                          begin
                            custom_shell_keyword = dsl_widget_name(custom_shell_name)
                Severity: Minor
                Found in lib/glimmer/rake_task/scaffold.rb - About 2 hrs 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 a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                Open

                      def initialize(parent, args)
                        index = args.delete(args.last) if args.last.is_a?(Numeric)
                        styles = args.map(&:to_sym)
                        if !styles.include?(:bar) && !parent.swt_widget.is_a?(Menu)
                          styles = styles.unshift(:pop_up)
                Severity: Minor
                Found in lib/glimmer/swt/menu_proxy.rb - About 2 hrs 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 delegate_observation_request_to_checkboxes has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                Open

                        def delegate_observation_request_to_checkboxes(observation_request, &block)
                          if observation_request != 'on_widget_disposed'
                            checkboxes.count.times do |index|
                              checkbox = checkboxes[index]
                              label = labels[index]
                Severity: Minor
                Found in lib/glimmer/swt/custom/checkbox_group.rb - About 2 hrs 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 17 (exceeds 5 allowed). Consider refactoring.
                Open

                        def configure_sorting
                          @table_proxy.sort_strategy = lambda do
                            new_sort = @table_proxy.sort_block || @table_proxy.sort_by_block || @table_proxy.sort_property
                            new_sort_direction = @table_proxy.sort_direction
                            return if new_sort == @last_sort && new_sort_direction == @last_sort_direction
                Severity: Minor
                Found in lib/glimmer/swt/custom/refined_table.rb - About 2 hrs 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