opal/opal-rspec

View on GitHub

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

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

              describe "eq" do
                it "matches when actual == expected" do
                  expect(:foo).to eq(:foo)
                end
              
              
              Severity: Minor
              Found in spec-opal/matchers_spec.rb and 1 other location - About 55 mins to fix
              spec-opal/matchers_spec.rb on lines 99..115

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

              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

              describe "eql" do
                it "matches when expected.eql?(actual)" do
                  expect(1).to eql(1)
                end
              
              
              Severity: Minor
              Found in spec-opal/matchers_spec.rb and 1 other location - About 55 mins to fix
              spec-opal/matchers_spec.rb on lines 79..95

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

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

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

                      removes.each do |block|
                        block.remove.each do |item|
                          outlist[item.position - lo] = encode(block.op) + outlist[item.position - lo][1..-1] # - or !
                        end
                
                
                Severity: Minor
                Found in lib-opal/opal/rspec/fixes/diff-lcs/hunk.rb and 1 other location - About 45 mins to fix
                lib-opal/opal/rspec/fixes/diff-lcs/hunk.rb on lines 106..113

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

                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

                      inserts.each do |block|
                        block.insert.each do |item|
                          outlist[item.position - lo] = encode(block.op) + outlist[item.position - lo][1..-1] # + or !
                        end
                
                
                Severity: Minor
                Found in lib-opal/opal/rspec/fixes/diff-lcs/hunk.rb and 1 other location - About 45 mins to fix
                lib-opal/opal/rspec/fixes/diff-lcs/hunk.rb on lines 82..89

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

                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

                    context "when an error happens in `after(:suite)`" do
                      it 'allows the error to propagate to the user' do
                        RSpec.configuration.after(:suite) { 1 / 0 }
                
                        # expect {
                Severity: Minor
                Found in spec-opal-rspec/core/hooks_spec.rb and 1 other location - About 35 mins to fix
                spec-opal-rspec/core/hooks_spec.rb on lines 21..32

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

                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

                Severity
                Category
                Status
                Source
                Language