Freshly/spicerack

View on GitHub

Showing 11 of 58 total issues

Method collection_wrap_on has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

        def collection_wrap_on(*methods)
          methods.each do |method_name|
            around_method(method_name, prevent_double_wrapping_for: PROXY_MODULE_NAME) do |*args, **opts, &block|
              # TODO: replace with `super(*args, **opts, &block)` when <= 2.6 support is dropped
              result = if RUBY_VERSION < "2.7" && opts.blank?
Severity: Minor
Found in collectible/lib/collectible/collection/wraps_collection_methods.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 collection_wrap_values_on has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

        def collection_wrap_values_on(*methods)
          methods.each do |method_name|
            around_method(method_name, prevent_double_wrapping_for: PROXY_MODULE_NAME) do |*args, **opts, &block|
              # TODO: replace with `super(...)` when <= 2.6 support is dropped
              result = if RUBY_VERSION < "2.7" && opts.blank?
Severity: Minor
Found in collectible/lib/collectible/collection/wraps_collection_methods.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 disallow_when_sorted has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

        def disallow_when_sorted(*methods)
          methods.each do |method_name|
            around_method(method_name, prevent_double_wrapping_for: "MaintainSortingOrder") do |*args, **opts, &block|
              raise Collectible::MethodNotAllowedError, "cannot call #{method_name} when sorted" if maintain_sort_order?

Severity: Minor
Found in collectible/lib/collectible/collection/maintain_sort_order.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 conjugate_with has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

      def conjugate_with(junction, method_name)
        conjunction = explicit_conjunctions[junction.try(:junction_key)] || Nexus.conjugate(self, junction: junction)
        return conjunction if conjunction.present?

        return if Conjunction.config.nexus_use_disables_implicit_lookup && Nexus.couples?(junction)
Severity: Minor
Found in conjunction/lib/conjunction/conjunctive.rb - About 55 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 couple has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def couple(conjunctive, to:, bidirectional: false)
        raise TypeError, "#{conjunctive} is not a valid conjunctive" unless conjunctive.respond_to?(:conjugate)
        raise TypeError, "#{to} is not a valid junction" unless to.respond_to?(:junction_key)

        if bidirectional
Severity: Minor
Found in conjunction/lib/conjunction/nexus.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 format_value_for_log has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def format_value_for_log(value)
        # `#to_log_string` is idiomatic to Technologic and is the most explicit way to specify how an object is logged.
        return value.to_log_string if value.respond_to?(:to_log_string)

        return value.to_s if value.is_a?(Enumerator)
Severity: Minor
Found in technologic/lib/technologic/logger.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 prototype_name has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def prototype_name
        output = name
        output = output.delete_prefix(conjunction_prefix) if conjunction_prefix?
        output = output.delete_suffix(conjunction_suffix) if conjunction_suffix?
        output unless output == name
Severity: Minor
Found in conjunction/lib/conjunction/junction.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 memoize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def memoize(*method_names, observes: :itself)
      method_names.map(&:to_sym).each do |method_name|
        add_memoized_observers(method_name, observes)

        around_method(
Severity: Minor
Found in short_circu_it/lib/short_circu_it.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

Avoid too many return statements within this method.
Open

        return value.map { |element| format_value_for_log(element) } if value.respond_to?(:map)
Severity: Major
Found in technologic/lib/technologic/logger.rb - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

            return value.transform_values { |element| format_value_for_log(element) } if value.respond_to?(:transform_values)
    Severity: Major
    Found in technologic/lib/technologic/logger.rb - About 30 mins to fix

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

            def conjunction_name_for(other_prototype, other_prototype_name)
              other_prototype_name = other_prototype.prototype_name if other_prototype.respond_to?(:prototype_name)
              return if other_prototype_name.blank?
      
              [ conjunction_prefix, other_prototype_name, conjunction_suffix ].compact.join if conjunctive?
      Severity: Minor
      Found in conjunction/lib/conjunction/junction.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