Showing 22 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

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

          client.get("/r/television/top.json").body["data"]["children"].each do |item|
            listing = item["data"]
            next if listing["is_self"]
            NewsItem.find_or_create_by(title: listing["title"]) do |news_item|
              news_item.attributes = {url: listing["url"], score: listing["ups"], category: "tv_shows" }
    Severity: Minor
    Found in app/jobs/fetch_tv_shows_news_job.rb and 1 other location - About 50 mins to fix
    app/jobs/fetch_movie_news_job.rb on lines 12..16

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 43.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

          client.get("/r/movies/top.json").body["data"]["children"].each do |item|
            listing = item["data"]
            next if listing["is_self"]
            NewsItem.find_or_create_by(title: listing["title"]) do |news_item|
              news_item.attributes = {url: listing["url"], score: listing["ups"], category: "movies" }
    Severity: Minor
    Found in app/jobs/fetch_movie_news_job.rb and 1 other location - About 50 mins to fix
    app/jobs/fetch_tv_shows_news_job.rb on lines 12..16

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 43.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

      module Trakt
        module Data
          class ProgressSeason < Dry::Struct
            transform_keys(&:to_sym)
    
    
    Severity: Minor
    Found in app/business_logic/services/trakt/data/progress_season.rb and 1 other location - About 50 mins to fix
    app/business_logic/services/trakt/data/watched_season.rb on lines 2..15

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 43.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

      module Trakt
        module Data
          class WatchedSeason < Dry::Struct
            transform_keys(&:to_sym)
    
    
    Severity: Minor
    Found in app/business_logic/services/trakt/data/watched_season.rb and 1 other location - About 50 mins to fix
    app/business_logic/services/trakt/data/progress_season.rb on lines 2..15

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 43.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    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

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

      module Trakt
        module Data
          class WatchedShow < Dry::Struct
            transform_keys(&:to_sym)
    
    
    Severity: Minor
    Found in app/business_logic/services/trakt/data/watched_show.rb and 1 other location - About 45 mins to fix
    app/business_logic/services/trakt/data/progress_show.rb on lines 2..13

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 39.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

      module Trakt
        module Data
          class ProgressShow < Dry::Struct
            transform_keys(&:to_sym)
    
    
    Severity: Minor
    Found in app/business_logic/services/trakt/data/progress_show.rb and 1 other location - About 45 mins to fix
    app/business_logic/services/trakt/data/watched_show.rb on lines 2..13

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 39.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    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

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

      class WatchTvShow < BaseMutation
        argument :id, ID, required: true
    
        type Types::TvShowType
    
    
    Severity: Minor
    Found in app/graphql/mutations/watch_tv_show.rb and 1 other location - About 25 mins to fix
    app/graphql/mutations/sample_tv_show.rb on lines 2..15

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 30.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    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

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

      class SampleTvShow < BaseMutation
        argument :id, ID, required: true
    
        type Types::TvShowType
    
    
    Severity: Minor
    Found in app/graphql/mutations/sample_tv_show.rb and 1 other location - About 25 mins to fix
    app/graphql/mutations/watch_tv_show.rb on lines 2..15

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 30.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

      module Trakt
        module Data
          class ProgressEpisode < Dry::Struct
            transform_keys(&:to_sym)
    
    
    Severity: Minor
    Found in app/business_logic/services/trakt/data/progress_episode.rb and 1 other location - About 25 mins to fix
    app/business_logic/services/trakt/data/watched_episode.rb on lines 2..12

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 29.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

      module Trakt
        module Data
          class WatchedEpisode < Dry::Struct
            transform_keys(&:to_sym)
    
    
    Severity: Minor
    Found in app/business_logic/services/trakt/data/watched_episode.rb and 1 other location - About 25 mins to fix
    app/business_logic/services/trakt/data/progress_episode.rb on lines 2..12

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 29.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Severity
    Category
    Status
    Source
    Language