AndyObtiva/glimmer-dsl-swt

View on GitHub

Showing 401 of 401 total issues

Method call has a Cognitive Complexity of 36 (exceeds 5 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: Minor
Found in lib/glimmer/data_binding/table_items_binding.rb - About 5 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_file has 131 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        def custom_shell_file(custom_shell_name, namespace, shell_type, shell_options = {})
          namespace_type = class_name(namespace) == class_name(current_dir_name) ? 'class' : 'module'
    
          custom_shell_file_content = <<-MULTI_LINE_STRING
#{namespace_type} #{class_name(namespace)}
Severity: Major
Found in lib/glimmer/rake_task/scaffold.rb - About 5 hrs to fix

    Class TableProxy has 37 methods (exceeds 20 allowed). Consider refactoring.
    Open

        class TableProxy < Glimmer::SWT::WidgetProxy
          include Glimmer
          
          module TableListenerEvent
            def table_item
    Severity: Minor
    Found in lib/glimmer/swt/table_proxy.rb - About 4 hrs to fix

      Method constant has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
      Open

              def constant(symbol)
                return symbol unless symbol.is_a?(Symbol) || symbol.is_a?(String)
                symbol_string, negative = extract_symbol_string_negativity(symbol)
                swt_constant_symbol = symbol_string.downcase == symbol_string ? symbol_string.upcase.to_sym : symbol_string.to_sym
                bit_value = constant_source_class.const_get(swt_constant_symbol)
      Severity: Minor
      Found in lib/glimmer/swt/style_constantizable.rb - About 4 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 Game has 34 methods (exceeds 20 allowed). Consider refactoring.
      Open

          class Game
            PLAYFIELD_WIDTH = 10
            PLAYFIELD_HEIGHT = 20
            PREVIEW_PLAYFIELD_WIDTH = 4
            PREVIEW_PLAYFIELD_HEIGHT = 2
      Severity: Minor
      Found in samples/elaborate/tetris/model/game.rb - About 4 hrs to fix

        Method update_table_item_properties_from_model has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
        Open

              def update_table_item_properties_from_model(table_item, row_index, column_index, model, model_attribute)
                Glimmer::SWT::DisplayProxy.instance.sync_exec do
                  old_table_item_values = @last_model_collection_attribute_values &&
                    @last_model_collection_attribute_values[row_index] &&
                    model_attribute_values_for_index(@last_model_collection_attribute_values[row_index], column_index)
        Severity: Minor
        Found in lib/glimmer/data_binding/table_items_binding.rb - About 4 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

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

                def custom_widget_gem(custom_widget_name, namespace)
                  gem_name = "glimmer-cw-#{compact_name(custom_widget_name)}"
                  gem_summary = "#{human_name(custom_widget_name)} - Glimmer Custom Widget"
                  if namespace
                    gem_name += "-#{compact_name(namespace)}"
        Severity: Major
        Found in lib/glimmer/rake_task/scaffold.rb and 1 other location - About 4 hrs to fix
        lib/glimmer/rake_task/scaffold.rb on lines 349..385

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

        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 custom_shape_gem(custom_shape_name, namespace)
                  gem_name = "glimmer-cp-#{compact_name(custom_shape_name)}"
                  gem_summary = "#{human_name(custom_shape_name)} - Glimmer Custom Shape"
                  if namespace
                    gem_name += "-#{compact_name(namespace)}"
        Severity: Major
        Found in lib/glimmer/rake_task/scaffold.rb and 1 other location - About 4 hrs to fix
        lib/glimmer/rake_task/scaffold.rb on lines 310..346

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

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

                def calculate_args!
                  return @args if parent.is_a?(Drawable) && !default_x? && !default_y? && !default_width? && !default_height? && !max_width? && !max_height?
                  calculated_args_dependencies = [
                    x,
                    y,
        Severity: Minor
        Found in lib/glimmer/swt/custom/shape.rb - About 4 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 mandelbrot_fractal.rb has 333 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        require 'glimmer-dsl-swt'
        require 'complex'
        require 'concurrent/executor/fixed_thread_pool'
        require 'concurrent/utility/processor_counter'
        require 'concurrent/array'
        Severity: Minor
        Found in samples/elaborate/mandelbrot_fractal.rb - About 4 hrs to fix

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

                def sort_by_column!(table_column_proxy=nil)
                  index = nil
                  auto_exec do
                    index = swt_widget.columns.to_a.index(table_column_proxy.swt_widget) unless table_column_proxy.nil?
                  end
          Severity: Minor
          Found in lib/glimmer/swt/table_proxy.rb - About 3 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 reset_logger! has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
          Open

                def reset_logger!
                  if logger_type == :logger
                    reset_logger_without_glimmer_dsl_swt!
                  else
                    require 'logging'
          Severity: Minor
          Found in lib/ext/glimmer/config.rb - About 3 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 paint_pixel_by_pixel has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
          Open

                  def paint_pixel_by_pixel(width = nil, height = nil, &each_pixel_color)
                    if @image_double_buffered
                      work = lambda do |paint_event|
                        width ||= swt_drawable.bounds.width
                        height ||= swt_drawable.bounds.height
          Severity: Minor
          Found in lib/glimmer/swt/custom/drawable.rb - About 3 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 26 (exceeds 5 allowed). Consider refactoring.
          Open

                def initialize(*args, &content)
                  @args = args
                  @parent_proxy = nil
                  if @args.first.is_a?(WidgetProxy)
                    @parent_proxy = @args.shift
          Severity: Minor
          Found in lib/glimmer/swt/image_proxy.rb - About 3 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 sort! has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
          Open

                def sort!(internal_sort: false)
                  return unless sort_property && (sort_type || sort_block || sort_by_block)
                  if sort_strategy
                    sort_strategy.call
                  else
          Severity: Minor
          Found in lib/glimmer/swt/table_proxy.rb - About 3 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 widget_custom_attribute_mapping has 92 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def widget_custom_attribute_mapping
                  # TODO scope per widget class type just like other mappings
                  @swt_widget_custom_attribute_mapping ||= {
                    'drag_source' => {
                      getter: {name: 'getShell', invoker: lambda { |widget, args|
          Severity: Major
          Found in lib/glimmer/swt/widget_proxy.rb - About 3 hrs to fix

            Class Animation has 30 methods (exceeds 20 allowed). Consider refactoring.
            Open

                  class Animation
                    include Properties
                    include Glimmer::DataBinding::ObservableModel
                    
                    class << self
            Severity: Minor
            Found in lib/glimmer/swt/custom/animation.rb - About 3 hrs to fix

              Method enemy_attack! has a Cognitive Complexity of 25 (exceeds 5 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 3 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 draw_frame has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
              Open

                      def draw_frame(start_number)
                        if stopped? or
                            (start_number != @start_number) or
                            (frame_count_limited? && @frame_index == @frame_count) or
                            (cycle_limited? && @cycle_count_index == @cycle_count) or
              Severity: Minor
              Found in lib/glimmer/swt/custom/animation.rb - About 3 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 config has a Cognitive Complexity of 24 (exceeds 5 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 3 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