Showing 359 of 503 total issues

Avoid too many return statements within this method.
Open

        return false unless valid_switch_body?(true_body)
Severity: Major
Found in lib/opal/nodes/if.rb - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

            return false unless switch_variable == @switch_variable
    Severity: Major
    Found in lib/opal/nodes/if.rb - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

                        return expand_path(*parts)
      Severity: Major
      Found in lib/opal/nodes/call/require.rb - About 30 mins to fix

        Method clone has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def clone(freeze: nil)
            unless freeze.nil? || freeze == true || freeze == false
              raise ArgumentError, "unexpected value for freeze: #{freeze.class}"
            end
        
        
        Severity: Minor
        Found in opal/corelib/class.rb - About 25 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 repeated_permutation has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def repeated_permutation(n)
            num = ::Opal.coerce_to! n, ::Integer, :to_int
            return enum_for(:repeated_permutation, num) { num >= 0 ? size**num : 0 } unless block_given?
        
            %x{
        Severity: Minor
        Found in opal/corelib/array.rb - About 25 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 write has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def write(object = @object)
              if idx = @cache.index(object.object_id)
                write_object_link(idx)
              elsif object.respond_to?(:marshal_dump)
                write_usr_marshal(object)
        Severity: Minor
        Found in opal/corelib/marshal/write_buffer.rb - About 25 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 absolute_path has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def absolute_path(path, basedir = nil)
              sep = SEPARATOR
              sep_chars = `$sep_chars()`
              new_parts = []
        
        
        Severity: Minor
        Found in opal/corelib/file.rb - About 25 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 uniq has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def uniq(&block)
            hash = {}
        
            each do |*args|
              value = ::Opal.destructure(args)
        Severity: Minor
        Found in opal/corelib/enumerable.rb - About 25 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 round has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def round(precision = 0)
            return with_precision(:round, precision) unless precision == 0
            return 0 if @num == 0
            return @num if @den == 1
        
        
        Severity: Minor
        Found in opal/corelib/rational.rb - About 25 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 create_builder has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def create_builder
              builder = Opal::Builder.new(
                stubs: stubs,
                compiler_options: compiler_options,
                missing_require_severity: missing_require_severity,
        Severity: Minor
        Found in lib/opal/cli.rb - About 25 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 normal? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def normal?
            Matrix.Raise ErrDimensionMismatch unless square?
            rows.each_with_index do |row_i, i|
              rows.each_with_index do |row_j, j|
                s = 0
        Severity: Minor
        Found in stdlib/matrix.rb - About 25 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 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def inspect
            result = '#<struct '
        
            if `inspect_stack`.include? __id__
              result + ':...>'
        Severity: Minor
        Found in opal/corelib/struct.rb - About 25 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_defined_send has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

              def compile_defined_send(node)
                recv, method_name, *args = *node
                mid = mid_to_jsid(method_name.to_s)
        
                if recv
        Severity: Minor
        Found in lib/opal/nodes/defined.rb - About 25 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_body has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

              def compile_body
                inline_params = nil
                scope_name = nil
        
                in_scope do
        Severity: Minor
        Found in lib/opal/nodes/def.rb - About 25 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 segment_from_fragment has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def segment_from_fragment(fragment, generated_column)
            source_index     = 0                          # always 0, we're dealing with a single file
            original_line    = (fragment.line || 0) - 1   # fragments have 1-based lines
            original_line    = 0 if original_line < 0     # line 0 (-1) for fragments in source maps will crash
                                                          # browsers devtools and the webpack build process
        Severity: Minor
        Found in lib/opal/source_map/file.rb - About 25 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_arguments has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

              def compile_arguments(skip_comma = false)
                push ', ' unless skip_comma
        
                if @with_writer_temp
                  push @with_writer_temp
        Severity: Minor
        Found in lib/opal/nodes/call.rb - About 25 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 run has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

              def run
                mktmpdir do |dir|
                  with_http_server(dir) do |http_port, server_thread|
                    with_safari_driver do
                      prepare_files_in(dir)
        Severity: Minor
        Found in lib/opal/cli_runners/safari.rb - About 25 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 first_minor has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def first_minor(row, column)
            raise RuntimeError, "first_minor of empty matrix is not defined" if empty?
        
            unless 0 <= row && row < row_count
              raise ArgumentError, "invalid row (#{row.inspect} for 0..#{row_count - 1})"
        Severity: Minor
        Found in stdlib/matrix.rb - About 25 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 with_http_server has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

              def with_http_server(dir)
                port = safari_driver_port.to_i + 1
                server_thread = Thread.new do
                  server = WEBrick::HTTPServer.new(Port: port, DocumentRoot: dir, Logger: WEBrick::Log.new('/dev/null'), AccessLog: [])
                  server.mount_proc('/log') do |req, res|
        Severity: Minor
        Found in lib/opal/cli_runners/safari.rb - About 25 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 source_location has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

              def source_location
                expr = @sexp.loc.expression
                if expr.respond_to? :source_buffer
                  file = expr.source_buffer.name
                  file = "<internal:#{file}>" if file.start_with?("corelib/")
        Severity: Minor
        Found in lib/opal/nodes/base.rb - About 25 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

        Severity
        Category
        Status
        Source
        Language