clearwater-rb/clearwater

View on GitHub

Showing 7 of 12 total issues

File svg_component.rb has 390 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'clearwater/component'
require 'clearwater/virtual_dom'

module Clearwater
  module SVGComponent
Severity: Minor
Found in opal/clearwater/svg_component.rb - About 5 hrs to fix

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

      class Router
        attr_reader :window, :location, :history
        attr_accessor :application
    
        def initialize options={}, &block
    Severity: Minor
    Found in shared/clearwater/router.rb - About 2 hrs to fix

      Method sanitize_attributes has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def self.sanitize_attributes attributes
            return attributes unless `!!attributes.$$is_hash`
      
            attributes.each do |key, value|
              if `key.slice(0, 2)` == 'on'
      Severity: Minor
      Found in opal/clearwater/component.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

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

            def match key, other_parts=[]
              if key && (key == self.key || param_key?)
                if Array(other_parts).any?
                  [self, nested_routes[other_parts]]
                else
      Severity: Minor
      Found in shared/clearwater/router/route.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 set_outlets has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def set_outlets targets=targets_for_path(current_path)
            return unless application.component.respond_to? :outlet=
      
            trigger_routing_callbacks(path: current_path, previous_path: self.class.previous_path)
      
      
      Severity: Minor
      Found in shared/clearwater/router.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 sanitize_attributes has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def sanitize_attributes attributes
              return attributes unless attributes.is_a? Hash
      
              if attributes.key? :class_name or attributes.key? :className
                attributes[:class] ||= attributes.delete(:class_name) || attributes.delete(:className)
      Severity: Minor
      Found in lib/clearwater/component.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 sanitize_attributes has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def self.sanitize_attributes attributes
            return attributes unless `attributes.$$is_hash`
      
            sanitized = attributes.each_with_object({}) do |(key, value), hash|
              if svg_attr = SVG_ATTRIBUTES[key]
      Severity: Minor
      Found in opal/clearwater/svg_component.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

      Severity
      Category
      Status
      Source
      Language