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
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
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,
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)
Class Runner
has 24 methods (exceeds 20 allowed). Consider refactoring. Open
class Runner
extend T::Sig
include RenderSync::Actions
sig { returns(Run) }
File api_controller.rb
has 271 lines of code (exceeds 250 allowed). Consider refactoring. Open
class ApiController < ApplicationController
extend T::Sig
include ActionController::Live
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
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
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
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?
- Read upRead up
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
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
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?
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?
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
- Read upRead up
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])
- Read upRead up
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\)/
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
- Read upRead up
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?
- Read upRead up
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