AndyObtiva/glimmer-dsl-swt

View on GitHub

Showing 378 of 378 total issues

File meta_sample.rb has 305 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'glimmer-dsl-swt'
require 'fileutils'
require 'yaml'
require 'net/http'

Severity: Minor
Found in samples/elaborate/meta_sample.rb - About 3 hrs to fix

    Method custom_shell_file has a Cognitive Complexity of 23 (exceeds 5 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: Minor
    Found in lib/glimmer/rake_task/scaffold.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 23 (exceeds 5 allowed). Consider refactoring.
    Open

          def initialize(keyword, *args, swt_dialog: nil)
            DisplayProxy.instance.auto_exec do
              dialog_class = self.class.dialog_class(keyword)
              if swt_dialog
                @swt_dialog = swt_dialog
    Severity: Minor
    Found in lib/glimmer/swt/dialog_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 setup_shape_painting has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

            def setup_shape_painting
              # TODO consider performance optimization relating to order of shape rendering (affecting only further shapes not previous ones)
              if @paint_listener_proxy.nil?
                shape_painter = lambda do |paint_event|
                  shape_painting_work = lambda do |paint_event|
    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 delegate_observation_request_to_radios has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

            def delegate_observation_request_to_radios(observation_request, &block)
              if observation_request != 'on_widget_disposed'
                radios.count.times do |index|
                  radio = radios[index]
                  label = labels[index]
    Severity: Minor
    Found in lib/glimmer/swt/custom/radio_group.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 calculate_paint_args! has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

            def calculate_paint_args!
              unless @calculated_paint_args
                if @name == 'pixel'
                  @name = 'point'
                  # optimized performance calculation for pixel points
    Severity: Minor
    Found in lib/glimmer/swt/custom/shape.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 calculate_args! has 77 lines of code (exceeds 25 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: Major
    Found in lib/glimmer/swt/custom/shape.rb - About 3 hrs to fix

      Method apply_property_arg_conversions has 77 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              def apply_property_arg_conversions(property, args)
                method_name = attribute_setter(property)
                args = args.dup
                the_java_method = org.eclipse.swt.graphics.GC.java_class.declared_instance_methods.detect {|m| m.name == method_name}
                return args if the_java_method.nil?
      Severity: Major
      Found in lib/glimmer/swt/custom/shape.rb - About 3 hrs to fix

        Method edit_tree_item has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
        Open

              def edit_tree_item(tree_item, before_write: nil, after_write: nil, after_cancel: nil)
                return if tree_item.nil?
                content {
                  @tree_editor_text_proxy = text {
                    focus true
        Severity: Minor
        Found in lib/glimmer/swt/tree_proxy.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

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

                    new(Time.new(2037, 10, 6, 12, 0),  'New York Yankees', 'Boston Red Sox', 'Free Bobblehead'),
                    new(Time.new(2037, 10, 7, 12, 0),  'New York Yankees', 'Boston Red Sox'),
                    new(Time.new(2037, 10, 8, 12, 0),  'Boston Red Sox', 'New York Yankees'),
                    new(Time.new(2037, 10, 9, 12, 0),  'Boston Red Sox', 'New York Yankees'),
                    new(Time.new(2037, 10, 10, 12, 0), 'Boston Red Sox', 'New York Yankees', 'Free Umbrella'),
        Severity: Major
        Found in samples/hello/hello_table.rb and 1 other location - About 2 hrs to fix
        samples/hello/hello_table.rb on lines 32..41

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

        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

                    new(Time.new(2037, 10, 6, 12, 0),  'Chicago Cubs', 'Milwaukee Brewers', 'Free Bobblehead'),
                    new(Time.new(2037, 10, 7, 12, 0),  'Chicago Cubs', 'Milwaukee Brewers'),
                    new(Time.new(2037, 10, 8, 12, 0),  'Milwaukee Brewers', 'Chicago Cubs'),
                    new(Time.new(2037, 10, 9, 12, 0),  'Milwaukee Brewers', 'Chicago Cubs'),
                    new(Time.new(2037, 10, 10, 12, 0), 'Milwaukee Brewers', 'Chicago Cubs', 'Free Umbrella'),
        Severity: Major
        Found in samples/hello/hello_table.rb and 1 other location - About 2 hrs to fix
        samples/hello/hello_table.rb on lines 44..53

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

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

          Class Line has 25 methods (exceeds 20 allowed). Consider refactoring.
          Open

                  class Line < Shape
                    include PathSegment
                    
                    class << self
                      def include?(x1, y1, x2, y2, x, y)
          Severity: Minor
          Found in lib/glimmer/swt/custom/shape/line.rb - About 2 hrs to fix

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

                  def evaluate_se_nw_diagonal_win
                    sw_ne_coordinates = [
                      [[0, 3], [1, 4], [2, 5], [3, 6]],
                      [[0, 2], [1, 3], [2, 4], [3, 5], [4, 6]],
                      [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6]],
            Severity: Major
            Found in samples/elaborate/connect4/model/grid.rb and 1 other location - About 2 hrs to fix
            samples/elaborate/connect4/model/grid.rb on lines 125..134

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

            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 evaluate_sw_ne_diagonal_win
                    sw_ne_coordinates = [
                      [[3, 0], [2, 1], [1, 2], [0, 3]],
                      [[4, 0], [3, 1], [2, 2], [1, 3], [0, 4]],
                      [[5, 0], [4, 1], [3, 2], [2, 3], [1, 4], [0, 5]],
            Severity: Major
            Found in samples/elaborate/connect4/model/grid.rb and 1 other location - About 2 hrs to fix
            samples/elaborate/connect4/model/grid.rb on lines 137..146

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

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

                    def code_text_widget
                      @styled_text_proxy = styled_text(swt_style) {
            #             custom_widget_property_owner # TODO implement to route properties here without declaring method_missing
                        layout_data :fill, :fill, true, true if lines
                        
            Severity: Major
            Found in lib/glimmer/swt/custom/code_text.rb - About 2 hrs to fix

              Method print has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
              Open

                    def print(gc=nil, job_name: nil)
                      if gc.is_a?(org.eclipse.swt.graphics.GC)
                        @swt_widget.print(gc)
                      else
                        image = Image.new(DisplayProxy.instance.swt_display, bounds)
              Severity: Minor
              Found in lib/glimmer/swt/widget_proxy.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

              Class Path has 24 methods (exceeds 20 allowed). Consider refactoring.
              Open

                      class Path < Shape
                        include PathSegment # a path may behave as a path segment in another path
                        
                        attr_reader :swt_path, :path_segments
                        attr_accessor :calculated_path_args
              Severity: Minor
              Found in lib/glimmer/swt/custom/shape/path.rb - About 2 hrs to fix

                Method custom_shell_gem has 65 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                        def custom_shell_gem(custom_shell_name, namespace)
                          gem_name = "glimmer-cs-#{compact_name(custom_shell_name)}"
                          gem_summary = "#{human_name(custom_shell_name)} - Glimmer Custom Shell"
                          begin
                            custom_shell_keyword = dsl_widget_name(custom_shell_name)
                Severity: Major
                Found in lib/glimmer/rake_task/scaffold.rb - About 2 hrs to fix

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

                        def sort!(internal_sort: false)
                          return unless sort_property && (sort_type || sort_block || sort_by_block)
                          original_array = array = model_binding.evaluate_property
                          array = array.sort_by(&:hash) # this ensures consistent subsequent sorting in case there are equivalent sorts to avoid an infinite loop
                          # Converting value to_s first to handle nil cases. Should work with numeric, boolean, and date fields
                  Severity: Minor
                  Found in lib/glimmer/swt/table_proxy.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

                  Severity
                  Category
                  Status
                  Source
                  Language