thedrummeraki/tanoshimu

View on GitHub
app/operations/shows/sync.rb

Summary

Maintainability
C
7 hrs
Test Coverage

Method create_or_update_show_for has 46 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def create_or_update_show_for(data, airing_status, show_obj: nil)
      fetched_attrs = data[:attributes]
      synched_show = show_obj.present? ? show_obj : find_show_from_attributes(fetched_attrs)

      if synched_show.persisted?
Severity: Minor
Found in app/operations/shows/sync.rb - About 1 hr to fix

    Method crawl_shows has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def crawl_shows
          raise 'Crawling is not allowed.' unless Rails.configuration.allows_crawling
    
          @current_url = "https://kitsu.io/api/edge/anime?page%5Blimit%5D=20&page%5Boffset%5D=0"
          @has_next = true
    Severity: Minor
    Found in app/operations/shows/sync.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 airing_status_for has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def airing_status_for(show, default: 'unknown')
          return default if show.starts_on.blank?
    
          today_s_date = DateTime.now.utc
          if show.starts_on < today_s_date
    Severity: Minor
    Found in app/operations/shows/sync.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 create_or_update_show_for has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def create_or_update_show_for(data, airing_status, show_obj: nil)
          fetched_attrs = data[:attributes]
          synched_show = show_obj.present? ? show_obj : find_show_from_attributes(fetched_attrs)
    
          if synched_show.persisted?
    Severity: Minor
    Found in app/operations/shows/sync.rb - About 55 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 sync_show has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def sync_show
          raise '`show` params is mandatory with sync_type: :show' unless show.present?
          return unless show.synchable?
    
          response = RestClient.get(request_show_url(show))
    Severity: Minor
    Found in app/operations/shows/sync.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 override_episodes_for has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def override_episodes_for(show)
          #::Sync::Shows::ReactionCountJob.perform_later(show)
          return if show.reference_id.blank?
    
          response = RestClient.get(request_episodes_url(show))
    Severity: Minor
    Found in app/operations/shows/sync.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 create_shows_then_next_page has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def create_shows_then_next_page(season)
          Rails.logger.info("[Shows::Sync] #{request_airing_url(season)}")
          there_is_data = true
          created_shows = []
    
    
    Severity: Minor
    Found in app/operations/shows/sync.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

    Avoid too many return statements within this method.
    Open

          return sync_shows if sync_type == :shows
    Severity: Major
    Found in app/operations/shows/sync.rb - About 30 mins to fix

      There are no issues that match your filters.

      Category
      Status