AndyObtiva/glimmer-dsl-tk

View on GitHub

Showing 117 of 117 total issues

Method launch has a Cognitive Complexity of 85 (exceeds 5 allowed). Consider refactoring.
Open

  def launch
    @root = root {
      title 'Hello, Text!'
      width 1280
      height 800
Severity: Minor
Found in samples/hello/hello_text.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

File widget_proxy.rb has 598 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'yaml'
require 'glimmer/data_binding/tk/one_time_observer'
require 'glimmer/tk/widget'
require 'glimmer/tk/draggable_and_droppable'

Severity: Major
Found in lib/glimmer/tk/widget_proxy.rb - About 1 day to fix

    Class WidgetProxy has 52 methods (exceeds 20 allowed). Consider refactoring.
    Open

        class WidgetProxy
          class << self
            def create(keyword, parent, args, &block)
              widget_proxy_class(keyword).new(keyword, parent, args, &block)
            end
    Severity: Major
    Found in lib/glimmer/tk/widget_proxy.rb - About 7 hrs to fix

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

        def launch
          @root = root {
            title 'Hello, Text!'
            width 1280
            height 800
      Severity: Major
      Found in samples/hello/hello_text.rb - About 6 hrs to fix

        File text_proxy.rb has 368 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        require 'glimmer/tk/widget_proxy'
        
        module Glimmer
          module Tk
            # Proxy for Tk::Text
        Severity: Minor
        Found in lib/glimmer/tk/text_proxy.rb - About 4 hrs to fix

          Class TextProxy has 34 methods (exceeds 20 allowed). Consider refactoring.
          Open

              class TextProxy < WidgetProxy
                ALL_TAG = '__all__'
                FORMAT_DEFAULT_MAP = {
                  'justify' => 'left',
                }
          Severity: Minor
          Found in lib/glimmer/tk/text_proxy.rb - About 4 hrs to fix

            Method handle_listener has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
            Open

                  def handle_listener(listener_name, &listener)
                    listener_name = listener_name.to_s
                    # TODO return a listener registration object that has a deregister method
                    if listener_name == 'destroy'
                      # 'destroy' is a more reliable alternative listener binding to '<Destroy>'
            Severity: Minor
            Found in lib/glimmer/tk/widget_proxy.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

            Method make_draggable has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
            Open

                  def make_draggable
                    drag_event = nil
                    bind("<DropAcceptedEvent>", proc { |event| drag_event.drop_accepted = true })
                    bind("B1-Motion", proc { |tk_event|
                      if drag_event.nil?
            Severity: Minor
            Found in lib/glimmer/tk/draggable_and_droppable.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

            Method grid has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
            Open

                  def grid(options = {})
                    @_visible = true
                    options = options.stringify_keys
                    options['rowspan'] = options.delete('row_span') if options.keys.include?('row_span')
                    options['columnspan'] = options.delete('column_span') if options.keys.include?('column_span')
            Severity: Minor
            Found in lib/glimmer/tk/widget_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

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

                class MenuItemProxy < WidgetProxy
                  ACCELERATOR_MODIFIER_EVENT_MAP = {
                    'Command' => 'Command',
                    'Cmd' => 'Command',
                    'Meta' => 'Command',
            Severity: Minor
            Found in lib/glimmer/tk/menu_item_proxy.rb - About 3 hrs to fix

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

                  menu(label: 'Options', underline: 0) {
                    menu_item(:checkbutton, label: 'Enabled', underline: 0) {
                      on('command') do
                        @select_one_menu.children.each { |menu_item| menu_item.state = menu_item.state == 'disabled' ? 'normal' : 'disabled' }
                        @select_multiple_menu.children.each { |menu_item| menu_item.state = menu_item.state == 'disabled' ? 'normal' : 'disabled' }
              Severity: Major
              Found in samples/hello/hello_menu_bar.rb and 1 other location - About 3 hrs to fix
              samples/hello/hello_contextual_menu.rb on lines 57..85

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

              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

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

                  menu(label: 'Options', underline: 0) {
                    menu_item(:checkbutton, label: 'Enabled', underline: 0) {
                      on('command') do
                        @select_one_menu.children.each { |menu_item| menu_item.state = menu_item.state == 'disabled' ? 'normal' : 'disabled' }
                        @select_multiple_menu.children.each { |menu_item| menu_item.state = menu_item.state == 'disabled' ? 'normal' : 'disabled' }
              Severity: Major
              Found in samples/hello/hello_contextual_menu.rb and 1 other location - About 3 hrs to fix
              samples/hello/hello_menu_bar.rb on lines 125..153

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

              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

              Class ToplevelProxy has 27 methods (exceeds 20 allowed). Consider refactoring.
              Open

                  class ToplevelProxy < WidgetProxy
                    REGEX_GEOMETRY = /[x+-]/
                    DEFAULT_WIDTH = 190
                    DEFAULT_HEIGHT = 0
                    
              Severity: Minor
              Found in lib/glimmer/tk/toplevel_proxy.rb - About 3 hrs to fix

                Method widget_custom_attribute_mapping has 76 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                      def widget_custom_attribute_mapping
                        # TODO consider extracting to modules/subclasses
                        @widget_custom_attribute_mapping ||= {
                          ::Tk::Tile::TButton => {
                            'image' => {
                Severity: Major
                Found in lib/glimmer/tk/widget_proxy.rb - About 3 hrs to fix

                  Method widget_attribute_listener_installers has 75 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                        def widget_attribute_listener_installers
                          # TODO consider extracting to modules/subclasses
                          @tk_widget_attribute_listener_installers ||= {
                            ::Tk::Tile::TCheckbutton => {
                              'variable' => lambda do |observer|
                  Severity: Major
                  Found in lib/glimmer/tk/widget_proxy.rb - About 3 hrs to fix

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

                      def launch
                        root {
                          title 'Hello, Label!'
                          
                          notebook {
                    Severity: Major
                    Found in samples/hello/hello_label.rb - About 2 hrs to fix

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

                        def launch
                          root {
                            title 'Hello, Theme!'
                            
                            labelframe {
                      Severity: Major
                      Found in samples/hello/hello_theme.rb - About 2 hrs to fix

                        Method launch has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                        Open

                          def launch
                            @root = root {
                              title 'Glimmer Meta-Sample'
                              width 1280
                              height 720
                        Severity: Minor
                        Found in samples/elaborate/meta_sample.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 launch has 63 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          def launch
                            root {
                              text 'Hello, Progressbar!'
                              
                              progressbar {
                        Severity: Major
                        Found in samples/hello/hello_progressbar.rb - About 2 hrs to fix

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

                            def launch
                              @root = root {
                                title 'Glimmer Meta-Sample'
                                width 1280
                                height 720
                          Severity: Major
                          Found in samples/elaborate/meta_sample.rb - About 2 hrs to fix
                            Severity
                            Category
                            Status
                            Source
                            Language