Fullscreen/yt

View on GitHub

Showing 46 of 46 total issues

Class Video has 54 methods (exceeds 20 allowed). Consider refactoring.
Open

    class Video < Resource

    ### SNIPPET ###

      # @!attribute [r] title
Severity: Major
Found in lib/yt/models/video.rb - About 7 hrs to fix

    Method reports_params has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
    Open

          def reports_params
            @parent.reports_params.tap do |params|
              params['startDate'] = @days_range.begin
              params['endDate'] = @days_range.end
              params['metrics'] = @metrics.keys.join(',').to_s.camelize(:lower)
    Severity: Minor
    Found in lib/yt/collections/reports.rb - About 5 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 define_reports_method has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
    Open

          def define_reports_method(metric, type)
            (@metrics ||= {})[metric] = type
            define_method :reports do |options = {}|
              from = options[:since] || options[:from] || (options[:by].in?([:day, :month]) ? 5.days.ago : '2005-02-01')
              to = options[:until] || options[:to] || Date.today
    Severity: Minor
    Found in lib/yt/associations/has_reports.rb - About 3 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

    File geography.rb has 320 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require 'active_support'
    require 'active_support/core_ext/hash/indifferent_access'
    
    module Yt
      # The list of country codes and names used by the YouTube Analytics API.
    Severity: Minor
    Found in lib/yt/constants/geography.rb - About 3 hrs to fix

      Method define_metric_method has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
      Open

            def define_metric_method(metric)
              define_method metric do |options = {}|
                from = options[:since] || options[:from] || (options[:by].in?([:day, :month]) ? 5.days.ago : '2005-02-01')
                to = options[:until] || options[:to] || Date.today
                location = options[:in]
      Severity: Minor
      Found in lib/yt/associations/has_reports.rb - About 3 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

      File video.rb has 285 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      require 'yt/models/resource'
      
      module Yt
        module Models
          # Provides methods to interact with YouTube videos.
      Severity: Minor
      Found in lib/yt/models/video.rb - About 2 hrs to fix

        Method within has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
        Open

              def within(days_range, country, state, dimension, videos, historical, max_retries = 3)
                @days_range = days_range
                @country = country
                @state = state
                @dimension = dimension
        Severity: Minor
        Found in lib/yt/collections/reports.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

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

          class Request
            # Initializes a Request object.
            # @param [Hash] options the options for the request.
            # @option options [String, Symbol] :method (:get) The HTTP method to use.
            # @option options [Class] :expected_response (Net::HTTPSuccess) The class
        Severity: Minor
        Found in lib/yt/request.rb - About 2 hrs to fix

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

                def eager_load_items_from(items)
                  if included_relationships.any?
                    associations = [:claim, :category]
                    if (included_relationships & associations).any?
                      included_relationships.append(:snippet).uniq!
          Severity: Minor
          Found in lib/yt/collections/videos.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 eager_load_items_from has 45 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def eager_load_items_from(items)
                  if included_relationships.any?
                    associations = [:claim, :category]
                    if (included_relationships & associations).any?
                      included_relationships.append(:snippet).uniq!
          Severity: Minor
          Found in lib/yt/collections/videos.rb - About 1 hr to fix

            Method define_metric_method has 36 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  def define_metric_method(metric)
                    define_method metric do |options = {}|
                      from = options[:since] || options[:from] || (options[:by].in?([:day, :month]) ? 5.days.ago : '2005-02-01')
                      to = options[:until] || options[:to] || Date.today
                      location = options[:in]
            Severity: Minor
            Found in lib/yt/associations/has_reports.rb - About 1 hr to fix

              Method within has 30 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                    def within(days_range, country, state, dimension, videos, historical, max_retries = 3)
                      @days_range = days_range
                      @country = country
                      @state = state
                      @dimension = dimension
              Severity: Minor
              Found in lib/yt/collections/reports.rb - About 1 hr to fix

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

                module Yt
                  module Collections
                    # Provides methods to interact with a the advertising options of a YouTube video.
                    #
                    # Resources with advertising options are: {Yt::Models::Video videos}.
                Severity: Major
                Found in lib/yt/collections/advertising_options_sets.rb and 1 other location - About 1 hr to fix
                lib/yt/collections/claim_histories.rb on lines 4..30

                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 51.

                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 Yt
                  module Collections
                    # Provides methods to interact with a the claim history options of a YouTube claim.
                    #
                    # Resources with claim history are: {Yt::Models::Claim claims}.
                Severity: Major
                Found in lib/yt/collections/claim_histories.rb and 1 other location - About 1 hr to fix
                lib/yt/collections/advertising_options_sets.rb on lines 4..30

                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 51.

                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 type_cast has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                Open

                      def type_cast(value, type)
                        case [type]
                          when [Time] then Yt::Timestamp.parse(value) if value
                          when [Integer] then value.to_i if value
                          when [Float] then value.to_f if value
                Severity: Minor
                Found in lib/yt/associations/has_attribute.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 eager_load_items_from has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                      def eager_load_items_from(items)
                        if included_relationships.any?
                          ids = items.map{|item| item['id']}
                          parts = included_relationships.map{|r| r.to_s.camelize(:lower)}
                          conditions = {id: ids.join(','), part: parts.join(',')}
                Severity: Minor
                Found in lib/yt/collections/playlists.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 upload_body has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                      def upload_body(params = {})
                        {}.tap do |body|
                          snippet = params.slice :title, :description, :tags, :category_id
                          snippet[:categoryId] = snippet.delete(:category_id) if snippet[:category_id]
                          body[:snippet] = snippet if snippet.any?
                Severity: Minor
                Found in lib/yt/models/account.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 within has 7 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                      def within(days_range, country, state, dimension, videos, historical, max_retries = 3)
                Severity: Major
                Found in lib/yt/collections/reports.rb - About 50 mins to fix

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

                  module Yt
                    module Collections
                      # @private
                      class Players < Base
                  
                  
                  Severity: Minor
                  Found in lib/yt/collections/players.rb and 1 other location - About 45 mins to fix
                  lib/yt/collections/statistics_sets.rb on lines 4..26

                  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 41.

                  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 Yt
                    module Collections
                      # @private
                      class StatisticsSets < Base
                  
                  
                  Severity: Minor
                  Found in lib/yt/collections/statistics_sets.rb and 1 other location - About 45 mins to fix
                  lib/yt/collections/players.rb on lines 4..26

                  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 41.

                  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