Showing 419 of 503 total issues

Method chrome_executable has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

      def chrome_executable
        ENV['GOOGLE_CHROME_BINARY'] ||
          if OS.windows?
            [
              'C:/Program Files/Google/Chrome Dev/Application/chrome.exe',
Severity: Minor
Found in lib/opal/cli_runners/chrome.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 laplace_expansion has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

  def laplace_expansion(row: nil, column: nil)
    num = row || column

    if !num || (row && column)
      raise ArgumentError, "exactly one the row or column arguments must be specified"
Severity: Minor
Found in stdlib/matrix.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 index has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

  def index(*args)
    raise ArgumentError, "wrong number of arguments(#{args.size} for 0-2)" if args.size > 2
    which = (args.size == 2 || SELECTORS.include?(args.last)) ? args.pop : :all
    return to_enum :find_index, which, *args unless block_given? || args.size == 1
    if args.size == 1
Severity: Minor
Found in stdlib/matrix.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 permutation? has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

  def permutation?
    Matrix.Raise ErrDimensionMismatch unless square?
    cols = Array.new(column_count)
    rows.each_with_index do |row, i|
      found = false
Severity: Minor
Found in stdlib/matrix.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 round has 48 lines of code (exceeds 30 allowed). Consider refactoring.
Open

  def round(ndigits = undefined)
    if ::Integer === self
      if `ndigits == null`
        return self
      end
Severity: Minor
Found in opal/corelib/number.rb - About 1 hr to fix

    Method irb has 48 lines of code (exceeds 30 allowed). Consider refactoring.
    Open

      def irb
        ::Opal::IRB.ensure_loaded('opal-replutils')
    
        silencer = ::Opal::IRB::Silencer.new
    
    
    Severity: Minor
    Found in opal/corelib/irb.rb - About 1 hr to fix

      Method eval_and_print has 48 lines of code (exceeds 30 allowed). Consider refactoring.
      Open

        def eval_and_print(func, mode, colorize, binding = nil)
          printer = if colorize
                      ->(i) do
                        ColorPrinter.default(i)
                      rescue => e
      Severity: Minor
      Found in stdlib/opal-replutils.rb - About 1 hr to fix

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

              var key_hash = key.$$is_string ? key.valueOf() : (hash.$$by_identity ? Opal.id(key) : key.$hash()),
                  objects = hash.$$keys.get(key_hash),
                  object;
        Severity: Major
        Found in opal/corelib/runtime.js and 1 other location - About 1 hr to fix
        opal/corelib/runtime.js on lines 2357..2359

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

        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

              var key_hash = key.$$is_string ? key.valueOf() : (hash.$$by_identity ? Opal.id(key) : key.$hash()),
                  objects = hash.$$keys.get(key_hash),
                  object;
        Severity: Major
        Found in opal/corelib/runtime.js and 1 other location - About 1 hr to fix
        opal/corelib/runtime.js on lines 2388..2390

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

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

            def initialize(options = nil)
              options ||= {}
        
              # Runner
              @runner_type    = options.delete(:runner)         || :nodejs
        Severity: Minor
        Found in lib/opal/cli.rb - About 1 hr to fix

          Method compile has 47 lines of code (exceeds 30 allowed). Consider refactoring.
          Open

                def compile
                  case value.type
                  when :self, :nil, :false, :true
                    push value.type.to_s.inspect
                  when :lvasgn, :ivasgn, :gvasgn, :cvasgn, :casgn, :op_asgn, :or_asgn, :and_asgn
          Severity: Minor
          Found in lib/opal/nodes/defined.rb - About 1 hr to fix

            Method each_with_index has 47 lines of code (exceeds 30 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 1 hr to fix

              Method slice_before has 46 lines of code (exceeds 30 allowed). Consider refactoring.
              Open

                def slice_before(pattern = undefined, &block)
                  if `pattern === undefined && block === nil`
                    ::Kernel.raise ::ArgumentError, 'both pattern and block are given'
                  end
              
              
              Severity: Minor
              Found in opal/corelib/enumerable.rb - About 1 hr to fix

                Method solve has 46 lines of code (exceeds 30 allowed). Consider refactoring.
                Open

                    def solve b
                      if (singular?)
                        Matrix.Raise Matrix::ErrNotRegular, "Matrix is singular."
                      end
                      if b.is_a? Matrix
                Severity: Minor
                Found in stdlib/matrix/lup_decomposition.rb - About 1 hr to fix

                  Method each has 46 lines of code (exceeds 30 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 1 hr to fix

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

                      def +(m)
                        case m
                        when Numeric
                          Matrix.Raise ErrOperationNotDefined, "+", self.class, m.class
                        when Vector
                    Severity: Major
                    Found in stdlib/matrix.rb and 1 other location - About 1 hr to fix
                    stdlib/matrix.rb on lines 953..971

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

                    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 -(m)
                        case m
                        when Numeric
                          Matrix.Raise ErrOperationNotDefined, "-", self.class, m.class
                        when Vector
                    Severity: Major
                    Found in stdlib/matrix.rb and 1 other location - About 1 hr to fix
                    stdlib/matrix.rb on lines 926..944

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

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

                        def eval_ruby(code)
                          builder = Opal::Builder.new
                          silencer = Silencer.new
                    
                          code = "#{@incomplete}#{code}"
                    Severity: Minor
                    Found in lib/opal/repl.rb - About 1 hr to fix

                      Method _racc_yyparse_rb has 45 lines of code (exceeds 30 allowed). Consider refactoring.
                      Open

                          def _racc_yyparse_rb(recv, mid, arg, c_debug)
                            action_table, action_check, action_default, action_pointer,
                            _,             _,            _,              _,
                            _,            _,            token_table,    _,
                            _,            _,            * = arg
                      Severity: Minor
                      Found in stdlib/racc/parser.rb - About 1 hr to fix

                        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

                        Severity
                        Category
                        Status
                        Source
                        Language