Showing 359 of 503 total issues

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

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

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

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

                          def sample(count = undefined, options = undefined)
                            return at ::Kernel.rand(`self.length`) if `count === undefined`
                        
                            if `options === undefined`
                              if (o = ::Opal.coerce_to? count, ::Hash, :to_hash)
                        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 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 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_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 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 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

                        Severity
                        Category
                        Status
                        Source
                        Language