Showing 46 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
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}.
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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}.
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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)
Similar blocks of code found in 2 locations. Consider refactoring. Open
module Yt
module Collections
# @private
class StatisticsSets < Base
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
module Yt
module Collections
# @private
class Players < Base
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76