lighttroupe/luz

View on GitHub
gui/gui_default.rb

Summary

Maintainability
F
5 days
Test Coverage

File gui_default.rb has 616 lines of code (exceeds 250 allowed). Consider refactoring.
Open

multi_require 'gui_pointer_behavior', 'gui_object', 'gui_value', 'gui_string', 'gui_numeric', 'gui_label', 'gui_box', 'gui_window', 'gui_hbox', 'gui_vbox', 'gui_list', 'gui_list_select', 'gui_scrollbar', 'gui_grid', 'gui_message_bar', 'gui_beat_monitor', 'gui_time_control', 'gui_button', 'gui_float', 'gui_toggle', 'gui_curve', 'gui_curve_increasing', 'gui_theme', 'gui_integer', 'gui_select', 'gui_actor', 'gui_director', 'gui_event', 'gui_variable', 'gui_font_select', 'gui_engine_button', 'gui_engine_button_renderer', 'gui_engine_slider', 'gui_engine_slider_renderer', 'gui_radio_buttons', 'gui_object_renderer', 'gui_main_menu', 'gui_settings_window', 'gui_actor_view', 'gui_director_view', 'gui_user_object_editor', 'gui_delete_button', 'gui_enter_exit_button', 'gui_enter_exit_popup', 'gui_add_window', 'gui_interface', 'gui_director_menu', 'gui_actors_flyout', 'gui_variables_flyout', 'gui_message_bus_monitor', 'gui_file_dialog', 'gui_directory_dialog', 'gui_image_dialog', 'gui_confirmation_dialog', 'keyboard', 'gui_user_object_renderer', 'gui_user_object_class_renderer', 'gui_child_user_object_renderer', 'gui_project_effect_renderer', 'gui_actor_renderer', 'gui_actor_effect_renderer', 'gui_director_renderer', 'gui_event_renderer', 'gui_event_input_renderer', 'gui_variable_renderer', 'gui_variable_input_renderer', 'gui_curve_renderer', 'gui_curve_increasing_renderer', 'gui_theme_renderer', 'gui_style_renderer', 'gui_list_popup', 'gui_output_view_button', 'gui_actor_class_flyout', 'gui_director_edit_button', 'gui_director_view_button', 'cartesian_scaffolding', 'camera', 'gui_object_renderer_button', 'gui_file_object', 'gui_class_instance_renderer_button', 'gui_actor_class_button'
load_directory(Dir.pwd + '/gui/addons/', '**.rb')        # Addons to existing objects

class GuiDefault < GuiInterface
    ACTOR_BACKGROUND_COLOR    = [0,0,0,0]
Severity: Major
Found in gui/gui_default.rb - About 1 day to fix

    Class GuiDefault has 71 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class GuiDefault < GuiInterface
        ACTOR_BACKGROUND_COLOR    = [0,0,0,0]
        DIRECTOR_BACKGROUND_COLOR = [0,0,0,0]
        ACTOR_VIEW_COLOR = [1,0.5,0.5,1]
        DIRECTOR_VIEW_COLOR = [0.5,1,0.5,1]
    Severity: Major
    Found in gui/gui_default.rb - About 1 day to fix

      Method on_key_press has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
      Open

          def on_key_press(key)
              if key.control?
                  case key
                  when 'f8'
                      launch_project_directory_browser
      Severity: Minor
      Found in gui/gui_default.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 on_key_press has 88 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def on_key_press(key)
              if key.control?
                  case key
                  when 'f8'
                      launch_project_directory_browser
      Severity: Major
      Found in gui/gui_default.rb - About 3 hrs to fix

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

            def build_editor_for(user_object, options={})
                return unless user_object
        
                # extract options
                grab_keyboard_focus = options.delete(:grab_keyboard_focus)
        Severity: Minor
        Found in gui/gui_default.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 create! has 58 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def create!
                @actor_view = GuiActorView.new
                @director_view = GuiDirectorView.new
        
                #
        Severity: Major
        Found in gui/gui_default.rb - About 2 hrs to fix

          Method save_project has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

              def save_project
                  if $engine.project.path
                      if $engine.project.save
                          positive_message 'Project Saved'
                          yield if block_given?
          Severity: Minor
          Found in gui/gui_default.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 trash! has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

              def trash!(user_object)
                  case user_object
                  when Actor
                      if user_object == self.chosen_director.offscreen_render_actor.actor
                          self.chosen_director.offscreen_render_actor.actor = nil
          Severity: Minor
          Found in gui/gui_default.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 build_editor_for has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def build_editor_for(user_object, options={})
                  return unless user_object
          
                  # extract options
                  grab_keyboard_focus = options.delete(:grab_keyboard_focus)
          Severity: Minor
          Found in gui/gui_default.rb - About 1 hr to fix

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

                def hide_something!
                    if @directors_menu.visible?
                        close_directors_menu!
                        default_focus!
                        true
            Severity: Minor
            Found in gui/gui_default.rb - About 25 mins 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 choose_project_path has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def choose_project_path
                    @dialog_container << dialog = GuiDirectoryDialog.new('Choose Directory for New project.luz')        # TODO: convert to a save-file-to-directory situation
                    dialog.on_closed { dialog.remove_from_parent! }
                    dialog.on_selected { |path|
                        dialog.remove_from_parent!
            Severity: Minor
            Found in gui/gui_default.rb - About 25 mins 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 14 locations. Consider refactoring.
            Open

                    self << @project_menu_button = GuiButton.new.set(:scale_x => 0.04, :scale_y => 0.06, :offset_x => -0.48, :offset_y => 0.47, :background_image => $engine.load_image('images/corner.png'), :background_image_hover => $engine.load_image('images/corner-hover.png'), :background_image_click => $engine.load_image('images/corner-click.png'))
            Severity: Major
            Found in gui/gui_default.rb and 13 other locations - About 20 mins to fix
            gui/gui_beat_monitor.rb on lines 31..31
            gui/gui_beat_monitor.rb on lines 34..34
            gui/gui_default.rb on lines 253..253
            gui/gui_default.rb on lines 259..259
            gui/gui_director_menu.rb on lines 24..24
            gui/gui_director_menu.rb on lines 30..30
            gui/gui_director_menu.rb on lines 35..35
            gui/gui_directory_dialog.rb on lines 22..22
            gui/gui_file_dialog.rb on lines 93..93
            gui/gui_main_menu.rb on lines 13..13
            gui/gui_main_menu.rb on lines 16..16
            gui/gui_main_menu.rb on lines 39..39
            gui/gui_main_menu.rb on lines 50..50

            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

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

                    self << (@actors_button = GuiButton.new.set(:scale_x => -0.04, :scale_y => -0.06, :offset_x => 0.48, :offset_y => -0.47, :background_image => $engine.load_image('images/corner.png'), :background_image_hover => $engine.load_image('images/corner-hover.png'), :background_image_click => $engine.load_image('images/corner-click.png')))
            Severity: Major
            Found in gui/gui_default.rb and 13 other locations - About 20 mins to fix
            gui/gui_beat_monitor.rb on lines 31..31
            gui/gui_beat_monitor.rb on lines 34..34
            gui/gui_default.rb on lines 259..259
            gui/gui_default.rb on lines 280..280
            gui/gui_director_menu.rb on lines 24..24
            gui/gui_director_menu.rb on lines 30..30
            gui/gui_director_menu.rb on lines 35..35
            gui/gui_directory_dialog.rb on lines 22..22
            gui/gui_file_dialog.rb on lines 93..93
            gui/gui_main_menu.rb on lines 13..13
            gui/gui_main_menu.rb on lines 16..16
            gui/gui_main_menu.rb on lines 39..39
            gui/gui_main_menu.rb on lines 50..50

            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

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

                    self << (@directors_button = GuiButton.new.set(:scale_x => -0.04, :scale_y => 0.06, :offset_x => 0.48, :offset_y => 0.47, :background_image => $engine.load_image('images/corner.png'), :background_image_hover => $engine.load_image('images/corner-hover.png'), :background_image_click => $engine.load_image('images/corner-click.png')))
            Severity: Major
            Found in gui/gui_default.rb and 13 other locations - About 20 mins to fix
            gui/gui_beat_monitor.rb on lines 31..31
            gui/gui_beat_monitor.rb on lines 34..34
            gui/gui_default.rb on lines 253..253
            gui/gui_default.rb on lines 280..280
            gui/gui_director_menu.rb on lines 24..24
            gui/gui_director_menu.rb on lines 30..30
            gui/gui_director_menu.rb on lines 35..35
            gui/gui_directory_dialog.rb on lines 22..22
            gui/gui_file_dialog.rb on lines 93..93
            gui/gui_main_menu.rb on lines 13..13
            gui/gui_main_menu.rb on lines 16..16
            gui/gui_main_menu.rb on lines 39..39
            gui/gui_main_menu.rb on lines 50..50

            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