droidlabs/motion-prime

View on GitHub

Showing 126 of 136 total issues

Method draw_rect_in_context has 38 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def draw_rect_in_context(context, options)
      rect = options.fetch(:rect)
      radius = options.fetch(:radius, 0)
      rounded_corners = options[:rounded_corners] || [:top_left, :top_right, :bottom_right, :bottom_left]

Severity: Minor
Found in motion-prime/elements/draw/_draw_background_mixin.rb - About 1 hr to fix

    Method set_layer_options has 37 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def set_layer_options(key, value)
            if key == 'rounded_corners'
              layer_bounds = bounds
              if value[:overlap]
                size = layer_bounds.size
    Severity: Minor
    Found in motion-prime/views/view_styler.rb - About 1 hr to fix

      Method set_text_options has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

            def set_text_options(key, value)
              if key == 'content_horizontal_alignment' && value.is_a?(Symbol) && %[left right center fill].include?(value.to_s)
                view.setValue class_factory("UIControlContentHorizontalAlignment_#{value.camelize}"), forKey: camelize_factory(key)
                true
              elsif key == 'content_vertical_alignment' && value.is_a?(Symbol) && %[top bottom center fill].include?(value.to_s)
      Severity: Minor
      Found in motion-prime/views/view_styler.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 draw_in_context has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          def draw_in_context(context)
            return if computed_options[:hidden]
            size_to_fit_if_needed
            set_text_position
      
      
      Severity: Minor
      Found in motion-prime/elements/draw/label.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 preload_sections_schedule_from has 35 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def preload_sections_schedule_from(index, load_count)
            service = preloader_index_service
      
            @preloader_queue ||= []
      
      
      Severity: Minor
      Found in motion-prime/sections/_async_table_mixin.rb - About 1 hr to fix

        Method compute_cell_style_options has 34 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def compute_cell_style_options(style_sources, additional_suffixes)
              base_styles = {common: [], specific: []}
              suffixes = {common: [], specific: []}
              all_styles = []
        
        
        Severity: Minor
        Found in motion-prime/services/element_computed_options.rb - About 1 hr to fix

          Method load_image has 34 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def load_image
                return if @loading || image_data || !computed_options[:url]
                @loading = true
          
                refs = strong_references
          Severity: Minor
          Found in motion-prime/elements/draw/image.rb - About 1 hr to fix

            Method find_keys has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                  def find_keys(*arg)
                    if arg[0].is_a?(Hash)
                      options = arg[0]
                      if arg[1] && arg[1].is_a?(Hash)
                        sort_options = arg[1][:sort] || {}
            Severity: Minor
            Found in motion-prime/models/_finder_mixin.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 generate has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                def self.generate(obj, parametrize = true)
                  if parametrize && obj.is_a?(Hash)
                    obj.each do |key, value|
                      obj[key] = value.to_s if PARAMETRIZE_CLASSES.include?(value.class)
                    end
            Severity: Minor
            Found in motion-prime/models/json.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 setup_fonts has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                  def setup_fonts
                    return unless @base_config
                    colors = @base_config.fonts.to_hash.inject({}) do |res, (font, value)|
                      if [:system, :bold, :italic, :monospace].include?(value)
                        value = Symbol.uifont[value]
            Severity: Minor
            Found in motion-prime/config/config.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 compute_style_options has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                def compute_style_options(*style_sources)
                  @styles = []
                  if element.cell_section?
                    # FIXME: sometimes cause error: undefined method `style_suffixes' for instance of BaseSection's subclass
                    begin
            Severity: Minor
            Found in motion-prime/services/element_computed_options.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 set_option has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                def set_option(key, value)
                  # return if value.nil?
                  # ignore options
                  return if ignore_option?(key) || value.nil?
            
            
            Severity: Minor
            Found in motion-prime/views/view_styler.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 create_navigation_button has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                def create_navigation_button(title, args = {}, &block)
                  args[:style]  ||= UIBarButtonItemStylePlain
                  args[:action] ||= block || nil
                  # TODO: Find better place for this code, may be just create custom control
                  if title.is_a?(UIButton)
            Severity: Minor
            Found in motion-prime/screens/extensions/_navigation_bar_mixin.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 update_with_url has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                def update_with_url(url, options = {}, &block)
                  use_callback = block_given?
                  filtered_attributes = filtered_updatable_attributes(options)
            
                  attributes = attributes_to_post_data(model_name, filtered_attributes)
            Severity: Minor
            Found in motion-prime/models/_sync_mixin.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 prepare_for_store has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                def prepare_for_store(object, options = {})
                  if object.is_a?(Array)
                    object.map { |entity| prepare_for_store(entity, options) }.compact
                  else
                    object.bag_key = self.key
            Severity: Minor
            Found in motion-prime/models/_nano_bag_mixin.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 inspect_hash has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

              def inspect_hash(hash, depth = 0)
                return '{}' if hash.blank?
                res = hash.map.with_index do |(key, value), i|
                  k = "#{'  '*depth}#{i.zero? ? '{' : ' '}#{key.inspect}=>"
                  pair = if value.is_a?(Hash)
            Severity: Minor
            Found in motion-prime/core_ext/kernel.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 draw_in_context has 31 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def draw_in_context(context)
                  return if computed_options[:hidden]
                  size_to_fit_if_needed
                  set_text_position
            
            
            Severity: Minor
            Found in motion-prime/elements/draw/label.rb - About 1 hr to fix

              Method fetch_has_many_with_attributes has 31 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def fetch_has_many_with_attributes(key, data, sync_options = {})
                    # TODO: should we skip add/delete/save unless should_save?
                    should_save = sync_options[:save]
              
                    models_to_add = []
              Severity: Minor
              Found in motion-prime/models/_sync_mixin.rb - About 1 hr to fix

                Method draw_options has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    def draw_options
                      options = computed_options
                      text = (options[:html] || options[:text]).to_s.gsub(/\A[\n\r]+/, '')
                      text_color = (options[:text_color] || :black).uicolor
                      font = (extract_font_from(options) || :system).uifont
                Severity: Minor
                Found in motion-prime/elements/draw/label.rb - About 1 hr to fix

                  Method extract_attributed_string_options has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      def extract_attributed_string_options(options)
                        attributes = {}
                        line_height = options[:line_height]
                        line_spacing = options[:line_spacing]
                        text_alignment = options[:text_alignment]
                  Severity: Minor
                  Found in motion-prime/elements/_text_mixin.rb - About 1 hr to fix
                    Severity
                    Category
                    Status
                    Source
                    Language