Showing 10 of 22 total issues

Class Movie has 23 methods (exceeds 20 allowed). Consider refactoring.
Open

class Movie < ApplicationRecord
  include Base64Images
  include PgSearch::Model

  multisearchable against: [:title]
Severity: Minor
Found in app/models/movie.rb - About 2 hrs to fix

    Method perform has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

      def perform(tv_show)
        ActiveRecord::Base.connection_pool.with_connection do
          tv_show.seasons.each do |season|
            season.update download_requested: false
          end
    Severity: Minor
    Found in app/jobs/fetch_tv_show_details_trakt_job.rb - About 2 hrs 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_release_dates has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

      def fetch_release_dates
        qualities = ["Unknown", "Digital HD", "Blu-ray", "4K UHD"]
        struct = Struct.new(:release_date, :release_type, :quality)
    
        release_dates.delete_all
    Severity: Minor
    Found in app/models/movie.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 base64_image has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def base64_image(*methods)
          methods.each do |method|
            define_method "#{method}_base64" do
              return nil unless Rails.application.config.action_controller.perform_caching
              base64 = Rails.cache.read("base64_#{send(method)}")
    Severity: Minor
    Found in app/models/concerns/base64_images.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 perform has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def perform
        ActiveRecord::Base.connection_pool.with_connection do
          client = Faraday.new(:url => "https://www.reddit.com") do |builder|
            builder.request :json
            builder.response :json
    Severity: Minor
    Found in app/jobs/fetch_tv_shows_news_job.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 perform has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def perform
          feed.published_since(@published_since).reject do |entry|
            entry.dolby_vision && !entry.hdr
          end.each do |entry|
            next if entry.name.blank?
    Severity: Minor
    Found in app/business_logic/services/fetch_and_persist_feed_entries.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 fetch_download_status has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def fetch_download_status(tv_show)
        ::Broad::ServiceRegistry.trakt_user.collected_show(tv_show.imdb_id).seasons.each do |season|
          show_season = tv_show.seasons.includes(:episodes).find_by(number: season.number)
          next if show_season.blank?
    
    
    Severity: Minor
    Found in app/jobs/fetch_tv_show_details_trakt_job.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 fetch_watched_status has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def fetch_watched_status(tv_show)
        ::Broad::ServiceRegistry.trakt_user.watched_show(tv_show.imdb_id).seasons.each do |season|
          show_season = tv_show.seasons.includes(:episodes).find_by(number: season.number)
          next if show_season.blank?
    
    
    Severity: Minor
    Found in app/jobs/fetch_tv_show_details_trakt_job.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 update_download_at has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def update_download_at
        return self if releases.empty?
        return self if watched?
        return self if download_at.present? && download_at < 1.week.ago
    
    
    Severity: Minor
    Found in app/models/episode.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 <=> has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      def <=>(other)
        resolution_comparison = resolution_points <=> other.resolution_points
        return resolution_comparison unless resolution_comparison == 0
        hdr_comparison = hdr_points <=> other.hdr_points
        return hdr_comparison unless hdr_comparison == 0
    Severity: Minor
    Found in app/models/episode_release.rb - About 25 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

    Severity
    Category
    Status
    Source
    Language