Showing 12 of 77 total issues
File creative.py
has 371 lines of code (exceeds 250 allowed). Consider refactoring. Open
# Copyright (C) 2015 Twitter, Inc.
"""Container for all creative management logic used by the Ads API SDK."""
import json
File campaign.py
has 354 lines of code (exceeds 250 allowed). Consider refactoring. Open
# Copyright (C) 2015 Twitter, Inc.
"""Container for all campaign management logic used by the Ads API SDK."""
from twitter_ads.enum import TRANSFORM
Function __oauth_request
has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring. Open
def __oauth_request(self):
headers = {'user-agent': self.__user_agent()}
if 'headers' in self.options:
headers.update(self.options['headers'].copy())
- 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 test_rate_limit.py
has 277 lines of code (exceeds 250 allowed). Consider refactoring. Open
import responses
import unittest
import time
from tests.support import with_resource, with_fixture, characters
Function test_analytics_async
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def test_analytics_async():
responses.add(responses.GET,
with_resource('/' + API_VERSION + '/accounts/2iqph'),
body=with_fixture('accounts_load'),
content_type='application/json')
Function from_response
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def from_response(self, response, headers=None):
"""
Populates a given objects attributes from a parsed JSON API response.
This helper handles all necessary type coercions as it assigns
attribute values.
- 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
Function __from_response
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def __from_response(self, response):
self._next_cursor = response.body.get('next_cursor', None)
if 'total_count' in response.body:
self._total_count = int(response.body['total_count'])
- 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
Function to_params
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def to_params(self):
"""
Generates a Hash of property values for the current object. This helper
handles all necessary type coercions as it generates its output.
"""
- 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
Function __init__
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self,
Function to_time
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def to_time(time, granularity):
"""Returns a truncated and rounded time string based on the specified granularity."""
if not granularity:
if type(time) is datetime.date:
return format_date(time)
- 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
Avoid too many return
statements within this function. Open
return format_time(time)
Function batch_save
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def batch_save(klass, account, objs):
"""
Makes batch request(s) for a passed in list of objects
"""
- 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"