opal/corelib/range.rb

Summary

Maintainability
D
1 day
Test Coverage

Method cover? has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
Open

  def cover?(value)
    compare = ->(a, b) {
      a <=> b || 1
    }

Severity: Minor
Found in opal/corelib/range.rb - About 3 hrs 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 step has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

  def step(n = undefined)
    %x{
      function coerceStepSize() {
        if (n == null) {
          n = 1;
Severity: Minor
Found in opal/corelib/range.rb - About 3 hrs 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 step has 79 lines of code (exceeds 30 allowed). Consider refactoring.
Open

  def step(n = undefined)
    %x{
      function coerceStepSize() {
        if (n == null) {
          n = 1;
Severity: Major
Found in opal/corelib/range.rb - About 2 hrs to fix

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

      def include?(val)
        if `self.begin.$$is_number || self.end.$$is_number` ||
           @begin.is_a?(::Time) || @end.is_a?(::Time) ||
           ::Integer.try_convert(@begin) || ::Integer.try_convert(@end)
          return cover?(val)
    Severity: Minor
    Found in opal/corelib/range.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 each has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

      def each(&block)
        return enum_for(:each) { size } unless block_given?
    
        %x{
          var i, limit;
    Severity: Minor
    Found in opal/corelib/range.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 size has 31 lines of code (exceeds 30 allowed). Consider refactoring.
    Open

      def size
        %x{
          var b = this.begin, e = this.end;
    
          // If begin is Numeric
    Severity: Minor
    Found in opal/corelib/range.rb - About 1 hr to fix

      Method min has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Wontfix

        def min
          if @begin.nil?
            ::Kernel.raise ::RangeError, 'cannot get the minimum of beginless range'
          elsif block_given?
            super
      Severity: Minor
      Found in opal/corelib/range.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 max has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Wontfix

        def max
          if @end.nil?
            ::Kernel.raise ::RangeError, 'cannot get the maximum of endless range'
          elsif block_given?
            super
      Severity: Minor
      Found in opal/corelib/range.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 true if @end.nil?
      Severity: Major
      Found in opal/corelib/range.rb - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

              return !val_max.nil? && compare.call(val_max, @end) <= 0
        Severity: Major
        Found in opal/corelib/range.rb - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

              return false if @begin && compare.call(@begin, value) > 0
          Severity: Major
          Found in opal/corelib/range.rb - About 30 mins to fix

            There are no issues that match your filters.

            Category
            Status