AndyObtiva/glimmer-dsl-swt

View on GitHub
lib/glimmer/swt/custom/code_text.rb

Summary

Maintainability
D
2 days
Test Coverage
F
25%

Method code_text_widget has a Cognitive Complexity of 68 (exceeds 5 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: Minor
Found in lib/glimmer/swt/custom/code_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 code_text.rb has 306 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'glimmer/ui/custom_widget'

module Glimmer
  module SWT
    module Custom
Severity: Minor
Found in lib/glimmer/swt/custom/code_text.rb - About 3 hrs to fix

    Method code_text_widget has 76 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 3 hrs to fix

      Class CodeText has 26 methods (exceeds 20 allowed). Consider refactoring.
      Open

            class CodeText
              include Glimmer::UI::CustomWidget
              
              class << self
                def languages
      Severity: Minor
      Found in lib/glimmer/swt/custom/code_text.rb - About 3 hrs to fix

        Method method_missing has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

                def method_missing(method_name, *args, &block)
                  dsl_mode = @dsl_mode || args.last.is_a?(Hash) && args.last[:dsl]
                  if dsl_mode
                    args.pop if args.last.is_a?(Hash) && args.last[:dsl]
                    super(method_name, *args, &block)
        Severity: Minor
        Found in lib/glimmer/swt/custom/code_text.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 respond_to? has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

                def respond_to?(method_name, *args, &block)
                  dsl_mode = @dsl_mode || args.last.is_a?(Hash) && args.last[:dsl]
                  if dsl_mode
                    args = args[0...-1] if args.last.is_a?(Hash) && args.last[:dsl]
                    super(method_name, *args, &block)
        Severity: Minor
        Found in lib/glimmer/swt/custom/code_text.rb - About 45 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 hex_color_to_swt_color has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

                def hex_color_to_swt_color(color_data, default_color)
                  color_data = "##{color_data.chars.drop(1).map {|c| c*2}.join}" if color_data.is_a?(String) && color_data.start_with?('#') && color_data&.size == 4
                  color_data = color_data.match(REGEX_COLOR_HEX6).to_a.drop(1).map {|c| "0x#{c}".hex}.to_a if color_data.is_a?(String) && color_data.start_with?('#')
                  color_data = [color_data] unless color_data.nil? || color_data.empty? || color_data.is_a?(Array)
                  color_data = default_color if color_data.nil? || color_data.empty?
        Severity: Minor
        Found in lib/glimmer/swt/custom/code_text.rb - About 35 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

        There are no issues that match your filters.

        Category
        Status