clearwater-rb/clearwater

View on GitHub

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

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

            it '/parent/child => /parent/sibling' do
              router.trigger_routing_callbacks previous_path: '/parent/child', path: '/parent/sibling'
      
              expect(sibling.route_to).to eq(1)
              expect(child.route_from).to eq(1)
      Severity: Minor
      Found in spec-opal/clearwater/router_spec.rb and 1 other location - About 35 mins to fix
      spec-opal/clearwater/router_spec.rb on lines 167..173

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

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

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

            it '/parent/1/dynamic_child => /parent/2/dynamic_child' do
              router.trigger_routing_callbacks previous_path: '/parent/1/dynamic_child', path: '/parent/2/dynamic_child'
      
              expect(dynamic_child.route_from).to eq(1)
              expect(dynamic_child.route_to).to eq(1)
      Severity: Minor
      Found in spec-opal/clearwater/router_spec.rb and 1 other location - About 35 mins to fix
      spec-opal/clearwater/router_spec.rb on lines 123..129

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

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

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

            it '/parent/1 => /parent/2/dynamic_child' do
              router.trigger_routing_callbacks previous_path: '/parent/1', path: '/parent/2/dynamic_child'
      
              expect(dynamic_child.route_to).to eq(1)
              expect(dynamic.route_from).to eq(1)
      Severity: Minor
      Found in spec-opal/clearwater/router_spec.rb and 2 other locations - About 25 mins to fix
      spec-opal/clearwater/router_spec.rb on lines 107..112
      spec-opal/clearwater/router_spec.rb on lines 115..120

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

      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 3 locations. Consider refactoring.
      Open

            it '/parent => /parent/child' do
              router.trigger_routing_callbacks previous_path: '/parent', path: '/parent/child'
      
              expect(child.route_to).to eq(1)
              expect(parent.route_to).to eq(0)
      Severity: Minor
      Found in spec-opal/clearwater/router_spec.rb and 2 other locations - About 25 mins to fix
      spec-opal/clearwater/router_spec.rb on lines 115..120
      spec-opal/clearwater/router_spec.rb on lines 159..164

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

      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 3 locations. Consider refactoring.
      Open

            it '/parent/child => /parent' do
              router.trigger_routing_callbacks previous_path: '/parent/child', path: '/parent'
      
              expect(child.route_from).to eq(1)
              expect(parent.route_to).to eq(0)
      Severity: Minor
      Found in spec-opal/clearwater/router_spec.rb and 2 other locations - About 25 mins to fix
      spec-opal/clearwater/router_spec.rb on lines 107..112
      spec-opal/clearwater/router_spec.rb on lines 159..164

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

      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

      Severity
      Category
      Status
      Source
      Language