mikevallano/tmdb-moviequeue

View on GitHub

Showing 27 of 41 total issues

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

  def list_sort_handler(sort_by, member = nil)
    @sort_by = sort_by
    @member = member
    if @member.present?
      @user = User.find(@member)
Severity: Minor
Found in app/lib/sorting_handler.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 list_sort_handler has 54 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def list_sort_handler(sort_by, member = nil)
    @sort_by = sort_by
    @member = member
    if @member.present?
      @user = User.find(@member)
Severity: Major
Found in app/lib/sorting_handler.rb - About 2 hrs to fix

    Method get_providers has 53 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def get_providers(tmdb_id:, title:, media_type:, media_format:, release_date: nil)
          params = { tmdb_id: tmdb_id, media_type: media_type }
          results = Tmdb::Client.request(:streaming_service_providers, params)&.dig(:results, :US)
    
          parameterized_title = title.parameterize(separator: '+')
    Severity: Major
    Found in app/services/streaming_service_provider_data_service.rb - About 2 hrs to fix

      Method build_url_for_movie_discover_search has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

            def build_url_for_movie_discover_search(params)
              page = params[:page].presence || 1
              sort_by = params[:sort_by].presence || 'popularity'
              api_path = "/discover/movie?api_key=#{ENV['tmdb_api_key']}&certification_country=US"
              api_path += "&with_people=#{params[:people]}" if params[:people].present?
      Severity: Minor
      Found in app/lib/tmdb/client.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 has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

        def create
          build_resource(sign_up_params)
      
          if params[:token].present?
            @token = params[:token]
      Severity: Minor
      Found in app/controllers/registrations_controller.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 update_movie has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          def update_movie(movie)
            # I'm not sure why this method uses HTTParty instead
            tmdb_id = movie.tmdb_id.to_s
            movie_url = "#{Tmdb::Client::BASE_URL}/movie/#{tmdb_id}?api_key=#{Tmdb::Client::API_KEY}&append_to_response=trailers,credits,releases"
            api_result = begin
      Severity: Minor
      Found in app/services/movie_data_service.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 get_common_movies_between_multiple_actors has 39 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def get_common_movies_between_multiple_actors(actor_names: nil, paginate_actor_names: nil, page: nil, sort_by: nil)
            names = actor_names.uniq.reject { |name| name == '' }.compact.presence || paginate_actor_names.presence.split(';')
            return if names.blank?
      
            not_found_messages = []
      Severity: Minor
      Found in app/services/movie_data_service.rb - About 1 hr to fix

        Method update_movie has 38 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def update_movie(movie)
              # I'm not sure why this method uses HTTParty instead
              tmdb_id = movie.tmdb_id.to_s
              movie_url = "#{Tmdb::Client::BASE_URL}/movie/#{tmdb_id}?api_key=#{Tmdb::Client::API_KEY}&append_to_response=trailers,credits,releases"
              api_result = begin
        Severity: Minor
        Found in app/services/movie_data_service.rb - About 1 hr to fix

          Method get_advanced_movie_search_results has 33 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def get_advanced_movie_search_results(params)
                searched_terms = SearchParamParser.parse_movie_params_for_display(params)
                data = if params[:actor_name].present?
                 person_id = Tmdb::Client.request(:person_search, query: params[:actor_name])&.dig(:results)&.first&.dig(:id)
                 return OpenStruct.new(not_found_message: "No results for actor '#{params[:actor_name]}'.") if person_id.blank?
          Severity: Minor
          Found in app/services/movie_data_service.rb - About 1 hr to fix

            Method initialize_from_parsed_data has 33 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def self.initialize_from_parsed_data(result)
                release_date = Date.parse(result[:release_date]) if result[:release_date].present?
                vote_average = result[:vote_average].present? ? result[:vote_average].round(1) : 0
                runtime = result[:runtime].presence || 0
            
            
            Severity: Minor
            Found in app/entities/movie_more.rb - About 1 hr to fix

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

                def create
                  @invite = Invite.new(invite_params)
                  @invite.email = @invite.email.strip if @invite.email.present?
                  @invite[:token] = @invite.generate_token
                  @invitee = @invite.find_invitee
              Severity: Minor
              Found in app/controllers/invites_controller.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 has 29 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def create
                  @invite = Invite.new(invite_params)
                  @invite.email = @invite.email.strip if @invite.email.present?
                  @invite[:token] = @invite.generate_token
                  @invitee = @invite.find_invitee
              Severity: Minor
              Found in app/controllers/invites_controller.rb - About 1 hr to fix

                Method movies_index_sort_handler has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def movies_index_sort_handler(sort_by)
                    @sort_by = sort_by
                
                    case @sort_by
                    when "title"
                Severity: Minor
                Found in app/lib/sorting_handler.rb - About 1 hr to fix

                  Method update has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def update
                      self.resource = resource_class.to_adapter.get!(send(:"current_#{resource_name}").to_key)
                      prev_unconfirmed_email = resource.unconfirmed_email if resource.respond_to?(:unconfirmed_email)
                  
                      resource_updated = update_resource(resource, account_update_params)
                  Severity: Minor
                  Found in app/controllers/registrations_controller.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 get_common_movies_between_multiple_actors has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def get_common_movies_between_multiple_actors(actor_names: nil, paginate_actor_names: nil, page: nil, sort_by: nil)
                        names = actor_names.uniq.reject { |name| name == '' }.compact.presence || paginate_actor_names.presence.split(';')
                        return if names.blank?
                  
                        not_found_messages = []
                  Severity: Minor
                  Found in app/services/movie_data_service.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 get_movies_for_actor has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      def get_movies_for_actor(actor_name:, page:, sort_by:)
                        person_data = Tmdb::Client.request(:person_search, query: actor_name)[:results]&.first
                  
                        if person_data.blank?
                          return OpenStruct.new(
                  Severity: Minor
                  Found in app/services/movie_data_service.rb - About 1 hr to fix

                    Method create has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      def create
                        build_resource(sign_up_params)
                    
                        if params[:token].present?
                          @token = params[:token]
                    Severity: Minor
                    Found in app/controllers/registrations_controller.rb - About 1 hr to fix

                      Method parse_movie_params_for_display has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        def self.parse_movie_params_for_display(params)
                          output = {}
                          output[:actor_name_display] = "#{params[:actor_name].titlecase} movies" if params[:actor_name].present?
                          output[:mpaa_rating_display] = "Rated #{params[:mpaa_rating]}" if params[:mpaa_rating].present?
                      
                      
                      Severity: Minor
                      Found in app/lib/search_param_parser.rb - About 1 hr to fix

                        Method initialize_from_parsed_data has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                        Open

                          def self.initialize_from_parsed_data(result)
                            release_date = Date.parse(result[:release_date]) if result[:release_date].present?
                            vote_average = result[:vote_average].present? ? result[:vote_average].round(1) : 0
                            runtime = result[:runtime].presence || 0
                        
                        
                        Severity: Minor
                        Found in app/entities/movie_more.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 get_providers has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                        Open

                            def get_providers(tmdb_id:, title:, media_type:, media_format:, release_date: nil)
                              params = { tmdb_id: tmdb_id, media_type: media_type }
                              results = Tmdb::Client.request(:streaming_service_providers, params)&.dig(:results, :US)
                        
                              parameterized_title = title.parameterize(separator: '+')
                        Severity: Minor
                        Found in app/services/streaming_service_provider_data_service.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

                        Severity
                        Category
                        Status
                        Source
                        Language