droidlabs/motion-prime

View on GitHub

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

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

                  if !top.nil? && !bottom.nil?
                    frame.origin.y = top
                    if options[:height_to_fit].nil? && height.nil?
                      height = max_height - top - bottom
                    end
            Severity: Major
            Found in motion-prime/views/_frame_calculator_mixin.rb and 1 other location - About 1 hr to fix
            motion-prime/views/_frame_calculator_mixin.rb on lines 62..73

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

            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

                  if !left.nil? && !right.nil?
                    frame.origin.x = left
                    if options[:height_to_fit].nil? && width.nil?
                      width = max_width - left - right
                    end
            Severity: Major
            Found in motion-prime/views/_frame_calculator_mixin.rb and 1 other location - About 1 hr to fix
            motion-prime/views/_frame_calculator_mixin.rb on lines 76..87

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

            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 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 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 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 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 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 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 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 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_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
                Severity
                Category
                Status
                Source
                Language