af83/chouette-core

View on GitHub
app/models/source.rb

Summary

Maintainability
D
2 days
Test Coverage

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
Severity: Major
Found in app/models/source.rb - About 1 day to fix

    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
    Severity: Minor
    Found in app/models/source.rb - About 5 hrs to fix

      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"
      Severity: Minor
      Found in app/models/source.rb - About 2 hrs to fix

        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|
        Severity: Minor
        Found in app/models/source.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 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
        Severity: Minor
        Found in app/models/source.rb - About 45 mins 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 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)
        Severity: Minor
        Found in app/models/source.rb - About 35 mins 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 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
        Severity: Minor
        Found in app/models/source.rb - About 35 mins 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

        There are no issues that match your filters.

        Category
        Status