File source.rb
has 547 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'mimemagic_ext'
require 'net/ftp'
class Source < ApplicationModel
extend Enumerize
Class Source
has 39 methods (exceeds 20 allowed). Consider refactoring. Open
class Source < ApplicationModel
extend Enumerize
belongs_to :workbench, optional: false
has_many :retrievals, class_name: "Source::Retrieval", foreign_key: "source_id", dependent: :destroy
Class Retrieval
has 23 methods (exceeds 20 allowed). Consider refactoring. Open
class Retrieval < Operation
include Measurable
belongs_to :source, optional: false
belongs_to :import, class_name: "Import::Workbench"
Method process
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def process(source_file, target_file)
route_ids = self.route_ids
ignore_parents = self.ignore_parents?
gtfs_target_for = Proc.new do |resource, associations|
- 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 checksum!
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def checksum!
::Zip::File.open(file) do |zip_file|
# Sort the entries by name to always digest in the same order
zip_file.glob('*').sort_by(&:name).each do |entry|
# We could read only the beginning of larger files
- 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 fetch
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def fetch(path)
http.start do |http|
http.request request do |response|
return redirect.fetch(path) if response.is_a?(Net::HTTPRedirection)
raise error_for(response) unless response.is_a?(Net::HTTPSuccess)
- 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 perform
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def perform
unless source
logger.info "Source #{source_id} no longer available"
return
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"