AndyObtiva/glimmer-dsl-swt

View on GitHub
lib/glimmer/swt/table_proxy.rb

Summary

Maintainability
F
6 days
Test Coverage
B
85%

File table_proxy.rb has 537 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'glimmer/swt/widget_proxy'

module Glimmer
  module SWT
    class TableProxy < Glimmer::SWT::WidgetProxy
Severity: Major
Found in lib/glimmer/swt/table_proxy.rb - About 1 day to fix

    Method edit_table_item has a Cognitive Complexity of 55 (exceeds 5 allowed). Consider refactoring.
    Open

          def edit_table_item(table_item, column_index, before_write: nil, after_write: nil, after_cancel: nil, write_on_cancel: false)
            return if table_item.nil?
            model = table_item.data
            property = column_properties[column_index]
            cancel_edit!
    Severity: Minor
    Found in lib/glimmer/swt/table_proxy.rb - About 1 day 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 editors has 185 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            def editors
              @editors ||= {
                # ensure editor can work with string keys not just symbols (leave one string in for testing)
                'text' => {
                  widget_value_property: :text,
    Severity: Major
    Found in lib/glimmer/swt/table_proxy.rb - About 7 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 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 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 edit_table_item has 71 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def edit_table_item(table_item, column_index, before_write: nil, after_write: nil, after_cancel: nil, write_on_cancel: false)
                return if table_item.nil?
                model = table_item.data
                property = column_properties[column_index]
                cancel_edit!
        Severity: Major
        Found in lib/glimmer/swt/table_proxy.rb - About 2 hrs to fix

          Method sort_by_column! has 41 lines of code (exceeds 25 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 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

              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

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

                          date_drop_down: {
                            widget_value_property: :date_time,
                            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 2 other locations - About 1 hr to fix
              lib/glimmer/swt/table_proxy.rb on lines 135..154
              lib/glimmer/swt/table_proxy.rb on lines 177..196

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

              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 3 locations. Consider refactoring.
              Open

                          date: {
                            widget_value_property: :date_time,
                            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 2 other locations - About 1 hr to fix
              lib/glimmer/swt/table_proxy.rb on lines 156..175
              lib/glimmer/swt/table_proxy.rb on lines 177..196

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

              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 3 locations. Consider refactoring.
              Open

                          time: {
                            widget_value_property: :date_time,
                            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 2 other locations - About 1 hr to fix
              lib/glimmer/swt/table_proxy.rb on lines 135..154
              lib/glimmer/swt/table_proxy.rb on lines 156..175

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

              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

                              table_editor_widget_proxy = spinner(*args) {
                                selection model.send(property)
                                focus true
                                on_focus_lost {
                                  table_proxy.finish_edit!
              Severity: Minor
              Found in lib/glimmer/swt/table_proxy.rb and 1 other location - About 35 mins to fix
              lib/glimmer/swt/table_proxy.rb on lines 65..76

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

              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

                              table_editor_widget_proxy = text(*args) {
                                text model.send(property)
                                focus true
                                on_focus_lost {
                                  table_proxy.finish_edit!
              Severity: Minor
              Found in lib/glimmer/swt/table_proxy.rb and 1 other location - About 35 mins to fix
              lib/glimmer/swt/table_proxy.rb on lines 227..238

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

              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 property_type_converters
                      super.merge({
                        selection: lambda do |value|
                          if value.is_a?(Array)
                            search {|ti| value.include?(ti.getData) }
              Severity: Minor
              Found in lib/glimmer/swt/table_proxy.rb and 1 other location - About 20 mins to fix
              lib/glimmer/swt/tree_proxy.rb on lines 127..135

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

              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

              There are no issues that match your filters.

              Category
              Status