Fullscreen/yt

View on GitHub

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

                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

                  Method next_page has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                        def next_page
                          request = Yt::Request.new(list_params).tap do |request|
                            print "#{request.as_curl}\n" if Yt.configuration.developing?
                          end
                          response = request.run
                  Severity: Minor
                  Found in lib/yt/collections/annotations.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 insert has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                        def insert(options = {})
                          do_insert
                        rescue Yt::Error => error
                          ignorable_error = error.reasons.include? 'subscriptionDuplicate'
                          ignorable_error ||= (@parent.id == @auth.channel.id) if @auth
                  Severity: Minor
                  Found in lib/yt/collections/subscriptions.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

                  Consider simplifying this complex logical expression.
                  Open

                          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
                            location = options[:in]
                            country = location.is_a?(Hash) ? location[:country] : location
                  Severity: Major
                  Found in lib/yt/associations/has_reports.rb - About 40 mins to fix

                    Method build_insert_body has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                          def build_insert_body(attributes = {})
                            {}.tap do |body|
                              insert_parts.each do |name, part|
                                if should_include_part_in_insert? part, attributes
                                  body[name] = build_insert_body_part part, attributes
                    Severity: Minor
                    Found in lib/yt/collections/resources.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

                    Severity
                    Category
                    Status
                    Source
                    Language