Showing 52 of 52 total issues
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?
- 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 initialize
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def initialize(user)
super
# Everyone can show and watch anyone
can :show, Owner
- 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
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def data
begin
scraper = T.let(Scraper.friendly.find(params[:id]), Scraper)
rescue ActiveRecord::RecordNotFound
render_error "can't find scraper #{params[:id]}", 404
Method data_json
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def data_json(scraper, owner)
params_query = T.cast(params[:query], String)
params_callback = T.cast(params[:callback], T.nilable(String))
# When calculating the size here we're ignoring a few bytes at the front and end
Method lookup_metadata_remote
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def self.lookup_metadata_remote(domain_name)
doc = RestClient::Resource.new(
"http://#{domain_name}", verify_ssl: OpenSSL::SSL::VERIFY_NONE
).get
header = Nokogiri::HTML(doc).at("html head")
- 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 bootstrap_flash
has 26 lines of code (exceeds 25 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?
Method create
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create
authenticated_user = T.must(current_user)
scraper = Scraper.new(create_scraper_params)
scraper.full_name = "#{scraper.owner.to_param}/#{scraper.name}"
Method data_json
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def data_json(scraper, owner)
params_query = T.cast(params[:query], String)
params_callback = T.cast(params[:callback], T.nilable(String))
# When calculating the size here we're ignoring a few bytes at the front and end
- 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 process_json_stream_chunk
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def self.process_json_stream_chunk(chunk)
return [], chunk if chunk[-1..-1] != "\n"
buffer = +""
result = []
- 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 clean_utf8_string
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def self.clean_utf8_string(string)
if string.respond_to?(:encode)
if string.valid_encoding?
# Actually try converting to utf-8 and check if that works
begin
- 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 add_database_type_translations
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def add_database_type_translations(db)
# Don't error on dates that are FixNum and that don't parse
%w[date datetime].each do |type|
db.translator.add_translator(type) do |t, v|
case t.downcase
- 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 curl_command_linked
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def curl_command_linked(scraper, format, key, sql, callback)
Method api_url_in_html
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def api_url_in_html(scraper, format, key, sql, callback)
Method rows_changed_in_range
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def self.rows_changed_in_range(table, min, max, db1, db2)
Method curl_command
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def curl_command(scraper, format, key, sql, callback)
Method diffstat_table_rowid_range
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def self.diffstat_table_rowid_range(table, min, max, db1, db2)
Method data
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def data
begin
scraper = T.let(Scraper.friendly.find(params[:id]), Scraper)
rescue ActiveRecord::RecordNotFound
render_error "can't find scraper #{params[:id]}", 404
- 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 create
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def create
if ConnectionLogsController.key == params[:key]
domain = Domain.find_by(name: params[:host])
if domain.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 a Cognitive Complexity of 7 (exceeds 5 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
- 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
Avoid too many return
statements within this method. Open
return