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_horizontal_win
        connections = nil
        last_slot_value = nil
        HEIGHT.times do |row_index|
          connections = nil
Severity: Major
Found in samples/elaborate/connect4/model/grid.rb and 1 other location - About 1 hr to fix
samples/elaborate/connect4/model/grid.rb on lines 104..122

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

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

class HelloFileDialog
  include Glimmer::UI::CustomShell
  
  attr_accessor :selected_file
  
Severity: Major
Found in samples/hello/hello_file_dialog.rb and 1 other location - About 1 hr to fix
samples/hello/hello_directory_dialog.rb on lines 24..55

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

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_widget(custom_widget_name, namespace)
          namespace ||= current_dir_name
          root_dir = File.exists?('app') ? 'app' : 'lib'
          parent_dir = "#{root_dir}/#{file_name(namespace)}/view"
          return puts("The file '#{parent_dir}/#{file_name(custom_widget_name)}.rb' already exists. Please either remove or pick a different name.") if File.exist?("#{parent_dir}/#{file_name(custom_widget_name)}.rb")
Severity: Major
Found in lib/glimmer/rake_task/scaffold.rb and 1 other location - About 1 hr to fix
lib/glimmer/rake_task/scaffold.rb on lines 227..233

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

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(custom_shape_name, namespace)
          namespace ||= current_dir_name
          root_dir = File.exists?('app') ? 'app' : 'lib'
          parent_dir = "#{root_dir}/#{file_name(namespace)}/view"
          return puts("The file '#{parent_dir}/#{file_name(custom_shape_name)}.rb' already exists. Please either remove or pick a different name.") if File.exist?("#{parent_dir}/#{file_name(custom_shape_name)}.rb")
Severity: Major
Found in lib/glimmer/rake_task/scaffold.rb and 1 other location - About 1 hr to fix
lib/glimmer/rake_task/scaffold.rb on lines 218..224

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

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

class HelloDirectoryDialog
  include Glimmer::UI::CustomShell
  
  attr_accessor :selected_directory
  
Severity: Major
Found in samples/hello/hello_directory_dialog.rb and 1 other location - About 1 hr to fix
samples/hello/hello_file_dialog.rb on lines 24..55

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

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

      def default_blocks
        case @letter
        when :I
          [
            [block, block, block, block]
Severity: Minor
Found in samples/elaborate/tetris/model/tetromino.rb - About 1 hr to fix

    Method parking_spot has 36 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def parking_spot(location_x, location_y, length, angle)
        parking_spot_letter = next_parking_spot_letter
        height = length
        width = (2.0/3)*length
        
    Severity: Minor
    Found in samples/elaborate/parking.rb - About 1 hr to fix

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

        Method swt_widget_class_for has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

              def self.swt_widget_class_for(underscored_widget_name)
                # TODO clear memoization for a keyword if a custom widget was defined with that keyword
                unless flyweight_swt_widget_classes.keys.include?(underscored_widget_name)
                  begin
                    underscored_widget_name = KEYWORD_ALIASES[underscored_widget_name] if KEYWORD_ALIASES[underscored_widget_name]
        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 12 (exceeds 5 allowed). Consider refactoring.
        Open

              def set_attribute(attribute_name, *args)
                # TODO consider refactoring/unifying this code with WidgetProxy and elsewhere
                if args.count == 1
                  if args.first.is_a?(Symbol) || args.first.is_a?(String)
                    args[0] = ColorProxy.new(args.first).swt_color
        Severity: Minor
        Found in lib/glimmer/swt/image_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 [] has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

                def [](*symbols)
                  symbols = symbols.first if symbols.size == 1 && symbols.first.is_a?(Array)
                  result = symbols.compact.map do |symbol|
                    constant(symbol).tap do |constant_value|
                      raise Glimmer::Error, symbol.to_s + error_message_invalid_style unless constant_value.is_a?(Integer)
        Severity: Minor
        Found in lib/glimmer/swt/style_constantizable.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 start_moving_tetrominos_down has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

          def start_moving_tetrominos_down
            Thread.new do
              @mutex.synchronize do
                loop do
                  time = Time.now
        Severity: Minor
        Found in samples/elaborate/tetris.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 find_listener has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

              def self.find_listener(swt_widget_class, underscored_listener_name)
                @listeners ||= {}
                listener_key = [swt_widget_class.name, underscored_listener_name]
                unless @listeners.has_key?(listener_key)
                  listener_method_name = underscored_listener_name.camelcase(:lower)
        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 custom_shape_gem has 35 lines of code (exceeds 25 allowed). 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: Minor
        Found in lib/glimmer/rake_task/scaffold.rb - About 1 hr to fix

          Method custom_widget_gem has 35 lines of code (exceeds 25 allowed). 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: Minor
          Found in lib/glimmer/rake_task/scaffold.rb - About 1 hr to fix

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

              Method build_radios has 33 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                      def build_radios
                        current_selection = selection
                        @composites.to_a.each(&:dispose)
                        @radios = []
                        @labels = []
              Severity: Minor
              Found in lib/glimmer/swt/custom/radio_group.rb - About 1 hr to fix

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

                  Method all has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                        def all
                          @all ||= [
                            {town: 'Chicago', name: 'White Sox', ballpark: 'Guaranteed Rate Field'},
                            {town: 'Cleveland', name: 'Indians', ballpark: 'Progressive Field'},
                            {town: 'Detroit', name: 'Tigers', ballpark: 'Comerica Park'},
                  Severity: Minor
                  Found in samples/hello/hello_refined_table.rb - About 1 hr to fix

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

                          def initialize(parent, *args, options, &content)
                            SWT::DisplayProxy.current_custom_widgets_and_shapes << self
                            @parent_proxy = @parent = parent
                            @parent_proxy = @parent&.get_data('proxy') if @parent.respond_to?(:get_data) && @parent.get_data('proxy')
                            @args = args
                    Severity: Minor
                    Found in lib/glimmer/ui/custom_shape.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

                    Severity
                    Category
                    Status
                    Source
                    Language