Showing 26 of 46 total issues
Class Video
has 54 methods (exceeds 20 allowed). Consider refactoring. Open
class Video < Resource
### SNIPPET ###
# @!attribute [r] title
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)
- Read upRead up
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
- Read upRead up
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.
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]
- Read upRead up
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 286 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'yt/models/resource'
module Yt
module Models
# Provides methods to interact with YouTube videos.
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
- Read upRead up
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
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!
- Read upRead up
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!
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]
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
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
- Read upRead up
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(',')}
- Read upRead up
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?
- Read upRead up
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)
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
- Read upRead up
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 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
- Read upRead up
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
Method authentication
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def authentication
@authentication = current_authentication
@authentication ||= use_refresh_token! if @refresh_token
@authentication ||= use_authorization_code! if @authorization_code
@authentication ||= use_device_code! if @device_code
- Read upRead up
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"