mattheworiordan/capybara-screenshot

View on GitHub

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

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

        if Capybara::Screenshot.autosave_on_failure
          Capybara.using_session(Capybara::Screenshot.final_session_name) do
            filename_prefix = Capybara::Screenshot.filename_prefix_for(:spinach, step_data)
            saver = Capybara::Screenshot.new_saver(Capybara, Capybara.page, true, filename_prefix)
            saver.save
    Severity: Minor
    Found in lib/capybara-screenshot/spinach.rb and 1 other location - About 25 mins to fix
    lib/capybara-screenshot/testunit.rb on lines 26..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 30.

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

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

          if Capybara::Screenshot.autosave_on_failure
            Capybara.using_session(Capybara::Screenshot.final_session_name) do
              filename_prefix = Capybara::Screenshot.filename_prefix_for(:testunit, fault)
    
              saver = Capybara::Screenshot.new_saver(Capybara, Capybara.page, true, filename_prefix)
    Severity: Minor
    Found in lib/capybara-screenshot/testunit.rb and 1 other location - About 25 mins to fix
    lib/capybara-screenshot/spinach.rb on lines 9..14

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

    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