Showing 16 of 29 total issues
Method oauth_request
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
def oauth_request
request = http_request
consumer = OAuth::Consumer.new(@client.consumer_key, @client.consumer_secret, site: domain)
token = OAuth::AccessToken.new(consumer, @client.access_token, @client.access_token_secret)
request.oauth!(consumer.http, consumer, token)
- 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 metric_filtering.rb
has 278 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'twitter-ads'
require 'yaml'
module TwitterAds
Class Account
has 22 methods (exceeds 20 allowed). Consider refactoring. Open
class Account
include TwitterAds::DSL
attr_reader :client
Method to_params
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def to_params
params = {}
self.class.properties.each do |name, type|
value = instance_variable_get("@#{name}") || send(name)
next if value.nil?
- 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 oauth_request
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def oauth_request
request = http_request
consumer = OAuth::Consumer.new(@client.consumer_key, @client.consumer_secret, site: domain)
token = OAuth::AccessToken.new(consumer, @client.access_token, @client.access_token_secret)
request.oauth!(consumer.http, consumer, token)
Method filter_placements
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def filter_placements(metrics, placements)
# return, nothing to exclude
return if placements.include?(:all_on_twitter) && placements.include?(:publisher_network)
# remove all TAP-related metrics unless publisher_network
- 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 batch_save
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def batch_save(account, objs)
resource = self::RESOURCE_BATCH % { account_id: account.id }
json_body = []
Method load
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def load(account, card_uris = nil, card_id = nil, with_deleted = nil, opts = {})
if (card_uris && card_id) || (card_uris.nil? && card_id.nil?)
raise ArgumentError.new('card_uris and card_id are exclusive parameters. ' \
'Please supply one or the other, but not both.')
end
- 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 load
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def load(account, card_uris = nil, card_id = nil, with_deleted = nil, opts = {})
Method initialize
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def initialize(consumer_key, consumer_secret, access_token, access_token_secret, opts = {})
Method from_response
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def from_response(object, headers = nil)
if !headers.nil?
TwitterAds::Utils.extract_response_headers(headers).each { |key, value|
singleton_class.class_eval { attr_accessor key }
instance_variable_set("@#{key}", 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 write_log
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def write_log(object)
if object.respond_to?(:code)
@client.logger.info("Status: #{object.code} #{object.message}")
else
@client.logger.info("Send: #{object.method} #{domain}#{@resource} #{@options[:params]}")
- 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 initialize
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def initialize(*args)
if args.size == 1 && args[0].respond_to?(:body) && args[0].respond_to?(:code)
@response = args[0]
@code = args[0].code
@details = args[0].body[:errors] if args[0].body.is_a?(Hash) && args[0].body[:errors]
- 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 validate
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def validate
details = []
unless @line_item_id
details << { code: 'MISSING_PARAMETER',
- 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 extract_response_headers
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def extract_response_headers(headers)
values = {}
# only get "X-${name}" custom response headers
headers.each { |key, value|
if key =~ /^x-/
- 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 flatten_params
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def flatten_params(args)
params = args
params.each { |key, value|
if value.is_a?(Array)
next if value.empty?
- 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"