opal/opal-rspec

View on GitHub

Showing 24 of 37 total issues

Method patch has a Cognitive Complexity of 74 (exceeds 5 allowed). Consider refactoring.
Open

  def patch(src, patchset, direction = nil)
    # Normalize the patchset.
    has_changes, patchset = Diff::LCS::Internals.analyze_patchset(patchset)

    return src.respond_to?(:dup) ? src.dup : src unless has_changes
Severity: Minor
Found in lib-opal/opal/rspec/fixes/diff-lcs/lcs.rb - About 1 day 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 patch has 82 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def patch(src, patchset, direction = nil)
    # Normalize the patchset.
    has_changes, patchset = Diff::LCS::Internals.analyze_patchset(patchset)

    return src.respond_to?(:dup) ? src.dup : src unless has_changes
Severity: Major
Found in lib-opal/opal/rspec/fixes/diff-lcs/lcs.rb - About 3 hrs to fix

    Method error_message has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

          def error_message(expectation, args_for_multiple_calls)
            expected_args = format_args(expectation.expected_args)
            actual_args = format_received_args(args_for_multiple_calls)
    
            if RSpec::Support::RubyFeatures.distincts_kw_args_from_positional_hash? && expected_args == actual_args
    Severity: Minor
    Found in lib-opal/opal/rspec/fixes/rspec/mocks/error_generator.rb - About 2 hrs 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 append_opts_from_config_file has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

          def append_opts_from_config_file
            self.libs ||= []
            self.requires ||= []
    
            config_location = nil
    Severity: Minor
    Found in lib/opal/rspec/runner.rb - About 2 hrs 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 context_diff has 39 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def context_diff(last = false)
        s = encode("***************\n")
        s += encode("*** #{context_range(:old, ",", last)} ****\n")
        r = context_range(:new, ",", last)
    
    
    Severity: Minor
    Found in lib-opal/opal/rspec/fixes/diff-lcs/hunk.rb - About 1 hr to fix

      Method run_await has 39 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def run_await(example_group_instance, reporter)
              # added awaits
              @example_group_instance = example_group_instance
              @reporter = reporter
              RSpec.configuration.configure_example(self, hooks)
      Severity: Minor
      Found in lib-opal/opal/rspec/async/example.rb - About 1 hr to fix

        Method context_diff has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

          def context_diff(last = false)
            s = encode("***************\n")
            s += encode("*** #{context_range(:old, ",", last)} ****\n")
            r = context_range(:new, ",", last)
        
        
        Severity: Minor
        Found in lib-opal/opal/rspec/fixes/diff-lcs/hunk.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 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def initialize(&block)
                @legacy_server_proxy = LegacyServerProxy.new
                block.call(@legacy_server_proxy, self) if block_given? # for compatibility
        
                raise 'Cannot supply both a pattern and files!' if self.files \
        Severity: Minor
        Found in lib/opal/rspec/runner.rb - About 1 hr to fix

          Method unified_diff has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def unified_diff(last = false)
              # Calculate item number range.
              s = encode("@@ -#{unified_range(:old, last)} +#{unified_range(:new, last)} @@\n")
          
              # Outlist starts containing the hunk of the old file. Removing an item
          Severity: Minor
          Found in lib-opal/opal/rspec/fixes/diff-lcs/hunk.rb - About 1 hr to fix

            Method run_await has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                  def run_await(example_group_instance, reporter)
                    # added awaits
                    @example_group_instance = example_group_instance
                    @reporter = reporter
                    RSpec.configuration.configure_example(self, hooks)
            Severity: Minor
            Found in lib-opal/opal/rspec/async/example.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 append_opts_from_config_file has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  def append_opts_from_config_file
                    self.libs ||= []
                    self.requires ||= []
            
                    config_location = nil
            Severity: Minor
            Found in lib/opal/rspec/runner.rb - About 1 hr to fix

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

                    def initialize(&block)
                      @legacy_server_proxy = LegacyServerProxy.new
                      block.call(@legacy_server_proxy, self) if block_given? # for compatibility
              
                      raise 'Cannot supply both a pattern and files!' if self.files \
              Severity: Minor
              Found in lib/opal/rspec/runner.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

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

                def get_files_to_run(paths)
                  files = paths_to_check(paths).flat_map do |path|
                    path = path.gsub(File::ALT_SEPARATOR, File::SEPARATOR) if File::ALT_SEPARATOR
                    is_directory?(path) ? gather_directories(path) : extract_location(path)
                  end.uniq
              Severity: Minor
              Found in lib-opal/opal/rspec/fixes/rspec/core/configuration.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

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

                      def run_await(position, scope, example_or_group)
                        return if RSpec.configuration.dry_run?
              
                        if scope == :context
                          unless example_or_group.class.metadata[:skip]
              Severity: Minor
              Found in lib-opal/opal/rspec/async/hooks.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 print_example_failed has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                    def print_example_failed(pending_fixed, description, run_time, failure_id, exception, extra_content)
              Severity: Minor
              Found in lib-opal/opal/rspec/formatter/html_printer.rb - About 45 mins to fix

                Method run_await has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                      def self.run_await(reporter=RSpec::Core::NullReporter)
                        # added awaits
                        return if RSpec.world.wants_to_quit
                        reporter.example_group_started(self)
                
                
                Severity: Minor
                Found in lib-opal/opal/rspec/async/example_group.rb - About 35 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 get_opal_spec_requires has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                      def get_opal_spec_requires
                        if !@spec_files || @spec_files.empty?
                          files = get_matching_files_under(path: @default_path)
                        else
                          files = @spec_files.map do |file|
                Severity: Minor
                Found in lib/opal/rspec/locator.rb - About 35 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 convert_spec_opts has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    def self.convert_spec_opts(opts)
                      opts ||= ENV['SPEC_OPTS'] || {}
                
                      unless opts.is_a? Hash
                        opts = Shellwords.split(opts) if opts.is_a? String
                Severity: Minor
                Found in lib/opal/rspec.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 ensure_can_be_proxied! has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                      def ensure_can_be_proxied!(object)
                        return unless object.is_a?(Symbol) || object.frozen?
                        return if object.nil?
                
                        msg = "Cannot proxy frozen objects"
                Severity: Minor
                Found in lib-opal/opal/rspec/fixes/rspec/mocks/proxy.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 unified_diff has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                  def unified_diff(last = false)
                    # Calculate item number range.
                    s = encode("@@ -#{unified_range(:old, last)} +#{unified_range(:new, last)} @@\n")
                
                    # Outlist starts containing the hunk of the old file. Removing an item
                Severity: Minor
                Found in lib-opal/opal/rspec/fixes/diff-lcs/hunk.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