mattheworiordan/capybara-screenshot

View on GitHub

Showing 6 of 8 total issues

Method save has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

      def save
        current_path do |path|
          within_offending_window do
            if path.empty?
              warn 'WARN: Screenshot could not be saved. `page.current_path` is empty.'
Severity: Minor
Found in lib/capybara-screenshot/saver.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 after_failed_example has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

        def after_failed_example(example)
          if example.example_group.include?(Capybara::DSL) # Capybara DSL method has been included for a feature we can snapshot
            Capybara.using_session(Capybara::Screenshot.final_session_name) do
              if Capybara::Screenshot.autosave_on_failure && failed?(example) && Capybara.page.current_url != ''
                filename_prefix = Capybara::Screenshot.filename_prefix_for(:rspec, example)
Severity: Minor
Found in lib/capybara-screenshot/rspec.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 10 (exceeds 5 allowed). Consider refactoring.
Open

      def initialize(strategy)
        @strategy = strategy

        @strategy_proc = case strategy
        when :keep_all
Severity: Minor
Found in lib/capybara-screenshot/pruner.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 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

      def initialize(saver, s3_client, bucket_name, object_configuration, options={})
Severity: Minor
Found in lib/capybara-screenshot/s3_saver.rb - About 35 mins to fix

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

            def failed?(example)
              return true if example.exception
              return false unless defined?(::RSpec::Expectations::FailureAggregator)
    
              failure_notifier = ::RSpec::Support.failure_notifier
    Severity: Minor
    Found in lib/capybara-screenshot/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 which has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def which(cmd)
            exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
    
            ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
              exts.each { |ext|
    Severity: Minor
    Found in lib/capybara-screenshot/saver.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