Showing 419 of 503 total issues

Method / has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

  def /(other)
    if ::Complex === other
      if (::Number === @real && @real.nan?) || (::Number === @imag && @imag.nan?) ||
         (::Number === other.real && other.real.nan?) || (::Number === other.imag && other.imag.nan?)
        ::Complex.new(::Float::NAN, ::Float::NAN)
Severity: Minor
Found in opal/corelib/complex.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 initialize has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    def initialize(range, step = undefined, creation_method = :step)
      @creation_method = creation_method
      if range.is_a? ::Array
        @step_arg1, @step_arg2, @topfx, @bypfx = *range
        @receiver_num = step
Severity: Minor
Found in opal/corelib/enumerator/arithmetic_sequence.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 cycle has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

  def cycle(n = nil, &block)
    unless block_given?
      return enum_for(:cycle, n) do
        if n.nil?
          ::Float::INFINITY
Severity: Minor
Found in opal/corelib/array.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 compile_to_directory has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

      def compile_to_directory(dir = nil, single_file: nil, with_source_map: true)
        raise ArgumentError, 'no directory provided' if dir.nil? && single_file.nil?

        catch(:file) do
          index = []
Severity: Minor
Found in lib/opal/builder/directory.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 compile_body_or_shortcut has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

      def compile_body_or_shortcut
        # The shortcuts don't check arity. If we want to check arity,
        # we can't use them.
        return compile_body if compiler.arity_check?

Severity: Minor
Found in lib/opal/nodes/node_with_args/shortcuts.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 fork_entrypoint has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

        def fork_entrypoint(io)
          # Ensure we can work with our forks async...
          Fiber.set_scheduler(nil) if Fiber.respond_to? :set_scheduler

          @in_fork = io
Severity: Minor
Found in lib/opal/builder/scheduler/prefork.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 compile has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

      def compile
        is_lambda! if scope.lambda_definition?

        compile_body_or_shortcut

Severity: Minor
Found in lib/opal/nodes/iter.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 DelegateClass has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

def DelegateClass(superclass, &block)
  klass = Class.new(Delegator)
  ignores = [*::Delegator.public_api, :to_s, :inspect, :=~, :!~, :===]
  protected_instance_methods = superclass.protected_instance_methods
  protected_instance_methods -= ignores
Severity: Minor
Found in stdlib/delegate.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 relative_path_from has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

  def relative_path_from(base_directory)
    dest_directory = cleanpath.to_s
    base_directory = base_directory.cleanpath.to_s
    dest_prefix = dest_directory
    dest_names = []
Severity: Minor
Found in stdlib/pathname.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

Function hash has 44 lines of code (exceeds 30 allowed). Consider refactoring.
Open

  Opal.hash = function () {
    var arguments_length = arguments.length,
      args,
      hash,
      i,
Severity: Minor
Found in opal/corelib/runtime.js - About 1 hr to fix

    Method == has 43 lines of code (exceeds 30 allowed). Consider refactoring.
    Open

      def ==(other)
        %x{
          var recursed = {};
    
          function _eqeq(array, other) {
    Severity: Minor
    Found in opal/corelib/array.rb - About 1 hr to fix

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

              if (Opal.is_method(prop)) {
                var method = proto[prop];
      
                if (!method.$$stub) {
                  var method_name = prop.slice(1);
      Severity: Major
      Found in opal/corelib/runtime.js and 1 other location - About 1 hr to fix
      opal/corelib/runtime.js on lines 989..996

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

      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

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

            if (Opal.is_method(prop)) {
              var method = proto[prop];
      
              if (!method.$$stub) {
                var method_name = prop.slice(1);
      Severity: Major
      Found in opal/corelib/runtime.js and 1 other location - About 1 hr to fix
      opal/corelib/runtime.js on lines 961..968

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

      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 pack has 42 lines of code (exceeds 30 allowed). Consider refactoring.
      Open

        def pack(format)
          format = ::Opal.coerce_to!(format, ::String, :to_str).gsub(/\s/, '').delete("\000")
      
          %x{
            var output = '';
      Severity: Minor
      Found in opal/corelib/array/pack.rb - About 1 hr to fix

        Method initialize has 42 lines of code (exceeds 30 allowed). Consider refactoring.
        Open

            def initialize a
              raise TypeError, "Expected Matrix but got #{a.class}" unless a.is_a?(Matrix)
              # Use a "left-looking", dot-product, Crout/Doolittle algorithm.
              @lu = a.to_a
              @row_count = a.row_count
        Severity: Minor
        Found in stdlib/matrix/lup_decomposition.rb - About 1 hr to fix

          Method cycle has 41 lines of code (exceeds 30 allowed). Consider refactoring.
          Open

            def cycle(n = nil, &block)
              unless block_given?
                return enum_for(:cycle, n) do
                  if n.nil?
                    respond_to?(:size) ? ::Float::INFINITY : nil
          Severity: Minor
          Found in opal/corelib/enumerable.rb - About 1 hr to fix

            Method gets has 41 lines of code (exceeds 30 allowed). Consider refactoring.
            Open

              def gets(sep = false, limit = nil, opts = {})
                if `sep.$$is_number` && !limit
                  sep, limit, opts = false, sep, limit
                end
                if `sep.$$is_hash` && !limit && opts == {}
            Severity: Minor
            Found in opal/corelib/io.rb - About 1 hr to fix

              Method product has 41 lines of code (exceeds 30 allowed). Consider refactoring.
              Open

                def product(*args, &block)
                  %x{
                    var result = #{block_given?} ? null : [],
                        n = args.length + 1,
                        counters = new Array(n),
              Severity: Minor
              Found in opal/corelib/array.rb - About 1 hr 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 any? has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                Open

                  def any?(pattern = undefined, &block)
                    if `pattern !== undefined`
                      each do |*value|
                        comparable = `comparableForPattern(value)`
                
                
                Severity: Minor
                Found in opal/corelib/enumerable.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

                Severity
                Category
                Status
                Source
                Language