openaustralia/morph

View on GitHub
app/lib/morph/runner.rb

Summary

Maintainability
D
1 day
Test Coverage

Class Runner has 24 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Runner
    extend T::Sig

    include RenderSync::Actions
    sig { returns(Run) }
Severity: Minor
Found in app/lib/morph/runner.rb - About 2 hrs to fix

    File runner.rb has 270 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    module Morph
      # High level API for running morph scraper. Handles the setting up of default
      # configuration if things like Gemfiles are not included (for Ruby)
      class Runner
        extend T::Sig
    Severity: Minor
    Found in app/lib/morph/runner.rb - About 2 hrs to fix

      Method attach_to_run_and_finish has 45 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def attach_to_run_and_finish(container, since, &block)
            if container.nil?
              # TODO: Return the status for a compile error
              result = Morph::RunResult.new(255, {}, {})
            else
      Severity: Minor
      Found in app/lib/morph/runner.rb - About 1 hr to fix

        Method synch_and_go! has 41 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def synch_and_go!(&block)
              scraper = run.scraper
              # If this run belongs to a scraper that has just been deleted
              # or if the run has already been marked as finished then
              # don't do anything
        Severity: Minor
        Found in app/lib/morph/runner.rb - About 1 hr to fix

          Method compile_and_start_run has 40 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def compile_and_start_run(max_lines = Runner.default_max_lines, &block)
                # puts "Starting...\n"
                run.database.backup
                # If the run is not part of a scraper (e.g. through the api) then there won't be a git repository
                git_revision = Rugged::Repository.new(run.repo_path).head.target_id unless run.scraper.nil?
          Severity: Minor
          Found in app/lib/morph/runner.rb - About 1 hr to fix

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

                def attach_to_run_and_finish(container, since, &block)
                  if container.nil?
                    # TODO: Return the status for a compile error
                    result = Morph::RunResult.new(255, {}, {})
                  else
            Severity: Minor
            Found in app/lib/morph/runner.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 compile_and_start_run has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                def compile_and_start_run(max_lines = Runner.default_max_lines, &block)
                  # puts "Starting...\n"
                  run.database.backup
                  # If the run is not part of a scraper (e.g. through the api) then there won't be a git repository
                  git_revision = Rugged::Repository.new(run.repo_path).head.target_id unless run.scraper.nil?
            Severity: Minor
            Found in app/lib/morph/runner.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

            Avoid too many return statements within this method.
            Open

                    return
            Severity: Major
            Found in app/lib/morph/runner.rb - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                      return
              Severity: Major
              Found in app/lib/morph/runner.rb - About 30 mins to fix

                There are no issues that match your filters.

                Category
                Status