Showing 419 of 503 total issues

Method join has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  def join(*args)
    return self if args.empty?
    result = args.pop
    result = Pathname.new(result) unless Pathname === result
    return result if result.absolute?
Severity: Minor
Found in stdlib/pathname.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

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

  def grep(pattern, &block)
    result = []

    each do |*value|
      cmp = `comparableForPattern(value)`
Severity: Minor
Found in opal/corelib/enumerable.rb and 1 other location - About 55 mins to fix
opal/corelib/enumerable.rb on lines 549..565

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

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 new has 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

  def self.new(year = undefined, month = nil, day = nil, hour = nil, min = nil, sec = nil, utc_offset = nil)
Severity: Major
Found in opal/corelib/time.rb - About 50 mins to fix

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

                  z = @v[i][n-1]
                  @v[i][n-1] = q * z + p * @v[i][n]
                  @v[i][n] = q * @v[i][n] - p * z
    Severity: Minor
    Found in stdlib/matrix/eigenvalue_decomposition.rb and 1 other location - About 50 mins to fix
    stdlib/matrix/eigenvalue_decomposition.rb on lines 551..553

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

    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

                  z = @h[i][n-1]
                  @h[i][n-1] = q * z + p * @h[i][n]
                  @h[i][n] = q * @h[i][n] - p * z
    Severity: Minor
    Found in stdlib/matrix/eigenvalue_decomposition.rb and 1 other location - About 50 mins to fix
    stdlib/matrix/eigenvalue_decomposition.rb on lines 559..561

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

    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

      def then(&block)
        prom = nil
        blk = gen_tracing_proc(block) do |val|
          prom.instance_variable_set(:@realized, :resolve)
          prom.instance_variable_set(:@value_set, true)
    Severity: Minor
    Found in stdlib/promise/v2.rb and 1 other location - About 50 mins to fix
    stdlib/promise/v2.rb on lines 240..251

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

    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

      def fail(&block)
        prom = nil
        blk = gen_tracing_proc(block) do |val|
          prom.instance_variable_set(:@realized, :resolve)
          prom.instance_variable_set(:@value_set, true)
    Severity: Minor
    Found in stdlib/promise/v2.rb and 1 other location - About 50 mins to fix
    stdlib/promise/v2.rb on lines 221..232

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

    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 first has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def first(count = undefined)
          iter = self.begin || -`inf`
    
          return _lesser_than_end?(iter) ? iter : nil unless count
    
    
    Severity: Minor
    Found in opal/corelib/enumerator/arithmetic_sequence.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

    Function send2 has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

      Opal.send2 = function(recv, body, method, args, block, blockopts) {
    Severity: Minor
    Found in opal/corelib/runtime.js - About 45 mins to fix

      Function refined_send has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

        Opal.refined_send = function(refinement_groups, recv, method, args, block, blockopts) {
      Severity: Minor
      Found in opal/corelib/runtime.js - About 45 mins to fix

        Method inspect has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def inspect
              if @receiver_num
                args = if @step_arg2
                         "(#{@topfx}#{@step_arg1.inspect}, #{@bypfx}#{@step_arg2.inspect})"
                       elsif @step_arg1
        Severity: Minor
        Found in opal/corelib/enumerator/arithmetic_sequence.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 pop has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

          def pop(count = undefined)
            `$deny_frozen_access(self)`
        
            if `count === undefined`
              return if `self.length === 0`
        Severity: Minor
        Found in opal/corelib/array.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 handle_additional_switch_rules has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

              def handle_additional_switch_rules(additional_rules)
                switch_additional_rules = []
                while additional_rules
                  match = SWITCH_BRANCH_TEST_MATCH.match(additional_rules) || SWITCH_BRANCH_TEST_MATCH_CONTINUED.match(additional_rules)
                  return false unless match
        Severity: Minor
        Found in lib/opal/nodes/if.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 inspect has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

          def inspect
            result = "#<#{self.class}"
        
            if @type
              result += ":#{@type}" unless %i[opal resolve reject].include? @type
        Severity: Minor
        Found in stdlib/promise/v2.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 compile has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

              def compile
                compile_body_or_shortcut
        
                blockopts = {}
        
        
        Severity: Minor
        Found in lib/opal/nodes/def.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 each has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

          def each(which = :all) # :yield: e
            return to_enum :each, which unless block_given?
            last = column_count - 1
            case which
            when :all
        Severity: Minor
        Found in stdlib/matrix.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 each_with_index has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

          def each_with_index(which = :all) # :yield: e, row, column
            return to_enum :each_with_index, which unless block_given?
            last = column_count - 1
            case which
            when :all
        Severity: Minor
        Found in stdlib/matrix.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 call has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

              def self.call(data)
                (data[:options] ||= {})[:env] = { 'NODE_PATH' => node_modules }
        
                argv = data[:argv].dup.to_a
                argv.unshift('--') if argv.any?
        Severity: Minor
        Found in lib/opal/cli_runners/nodejs.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 compile_assignment has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

              def compile_assignment(child, array, idx, len = nil)
                assign =
                  if !len || idx >= len
                    s(:js_tmp, "(#{array}[#{idx}] == null ? nil : #{array}[#{idx}])")
                  else
        Severity: Minor
        Found in lib/opal/nodes/masgn.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

        Avoid deeply nested control flow statements.
        Open

                        if (x.abs > (z.abs + q.abs))
                          @h[i+1][n-1] = (-ra - w * @h[i][n-1] + q * @h[i][n]) / x
                          @h[i+1][n] = (-sa - w * @h[i][n] - q * @h[i][n-1]) / x
                        else
                          cdivr, cdivi = cdiv(-r-y*@h[i][n-1], -s-y*@h[i][n], z, q)
        Severity: Major
        Found in stdlib/matrix/eigenvalue_decomposition.rb - About 45 mins to fix
          Severity
          Category
          Status
          Source
          Language