openaustralia/morph

View on GitHub

Showing 52 of 52 total issues

Class Scraper has 41 methods (exceeds 20 allowed). Consider refactoring.
Open

class Scraper < ApplicationRecord
  extend T::Sig

  include RenderSync::Actions
  # Using smaller batch_size than the default for the time being because
Severity: Minor
Found in app/models/scraper.rb - About 5 hrs to fix

    Class User has 27 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class User < Owner
      extend T::Sig
    
      devise :trackable, :rememberable, :omniauthable, omniauth_providers: [:github]
      has_many :organizations_users, dependent: :destroy
    Severity: Minor
    Found in app/models/user.rb - About 3 hrs to fix

      Class Database has 26 methods (exceeds 20 allowed). Consider refactoring.
      Open

        class Database
          extend T::Sig
          CORRUPT_DATABASE_EXCEPTIONS = T.let([
            SQLite3::NotADatabaseException,
            SQLite3::CorruptException,
      Severity: Minor
      Found in app/lib/morph/database.rb - About 3 hrs to fix

        Class DockerUtils has 25 methods (exceeds 20 allowed). Consider refactoring.
        Open

          class DockerUtils
            extend T::Sig
        
            sig { params(name: String).returns(Docker::Image) }
            def self.pull_docker_image(name)
        Severity: Minor
        Found in app/lib/morph/docker_utils.rb - About 2 hrs to fix

          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 api_controller.rb has 271 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            class ApiController < ApplicationController
              extend T::Sig
            
              include ActionController::Live
            
            
            Severity: Minor
            Found in app/controllers/api_controller.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

                File scraper.rb has 265 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                class Scraper < ApplicationRecord
                  extend T::Sig
                
                  include RenderSync::Actions
                  # Using smaller batch_size than the default for the time being because
                Severity: Minor
                Found in app/models/scraper.rb - About 2 hrs to fix

                  Class ScrapersController has 22 methods (exceeds 20 allowed). Consider refactoring.
                  Open

                  class ScrapersController < ApplicationController
                    extend T::Sig
                  
                    # Follow what GitHub does here. When you are not authorised to see
                    # a scraper it just gives a 404
                  Severity: Minor
                  Found in app/controllers/scrapers_controller.rb - About 2 hrs to fix

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

                      def bootstrap_flash(options = {})
                        flash_messages = []
                        flash.each do |type, message|
                          # Skip empty messages, e.g. for devise messages set to nothing in a locale file.
                          next if message.blank?
                    Severity: Minor
                    Found in app/helpers/bootstrap_flash_helper.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 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 41 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            def self.compile_and_start_run(
                              repo_path:, env_variables: {}, container_labels: {}, max_lines: 0, platform: nil,
                              disable_proxy: false, memory: nil, &block
                            )
                              memory = default_memory_limit if memory.nil?
                        Severity: Minor
                        Found in app/lib/morph/docker_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 initialize has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                            Open

                              def initialize(owner)
                                super
                                # Everyone can list all (non private) scrapers
                                can :read, Scraper, private: false
                            
                            
                            Severity: Minor
                            Found in app/abilities/scraper_ability.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 attach_to_run has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                            Open

                                def self.attach_to_run(container, since = nil, &block)
                                  params = { stdout: true, stderr: true, follow: true, timestamps: true }
                                  params[:since] = since.to_f if since
                                  container.streaming_logs(params) do |s, line|
                                    timestamp = Time.zone.parse(line[0..29])
                            Severity: Minor
                            Found in app/lib/morph/docker_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 parse_line has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                def self.parse_line(line)
                                  field, value = line.split(": ")
                            
                                  case field
                                  when /Maximum resident set size \(kbytes\)/
                            Severity: Minor
                            Found in app/lib/morph/time_command.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 12 (exceeds 5 allowed). Consider refactoring.
                              Open

                                  def self.compile_and_start_run(
                                    repo_path:, env_variables: {}, container_labels: {}, max_lines: 0, platform: nil,
                                    disable_proxy: false, memory: nil, &block
                                  )
                                    memory = default_memory_limit if memory.nil?
                              Severity: Minor
                              Found in app/lib/morph/docker_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 data_atom has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                def data_atom(scraper, owner)
                                  params_query = T.cast(params[:query], String)
                              
                                  # Only measuring the size of the entry blocks. We're ignoring the header.
                                  size = 0
                              Severity: Minor
                              Found in app/controllers/api_controller.rb - About 1 hr to fix
                                Severity
                                Category
                                Status
                                Source
                                Language