twitterdev/twitter-python-ads-sdk

View on GitHub
twitter_ads/creative.py

Summary

Maintainability
F
3 days
Test Coverage

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
Severity: Minor
Found in twitter_ads/creative.py - About 4 hrs to fix

    Similar blocks of code found in 3 locations. Consider refactoring.
    Open

        @classmethod
        @FlattenParams
        def attach(klass, account, **kwargs):
            """
            Associate one or more Tweets with the specified line item.
    Severity: Major
    Found in twitter_ads/creative.py and 2 other locations - About 2 hrs to fix
    twitter_ads/analytics.py on lines 96..105
    twitter_ads/campaign.py on lines 24..30

    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 61.

    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

    Further Reading

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

            if self.id:
                method = 'put'
                resource = self.RESOURCE.format(account_id=self.account.id, id=self.id)
            else:
                method = 'post'
    Severity: Major
    Found in twitter_ads/creative.py and 1 other location - About 2 hrs to fix
    twitter_ads/resource.py on lines 201..206

    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 60.

    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

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        @classmethod
        @FlattenParams
        def load(klass, account, **kwargs):
            resource = klass.RESOURCE_COLLECTION.format(account_id=account.id)
            request = Request(account.client, 'get', resource, params=kwargs)
    Severity: Major
    Found in twitter_ads/creative.py and 1 other location - About 1 hr to fix
    twitter_ads/creative.py on lines 366..369

    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 49.

    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

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

            if kwargs.get('card_uris'):
                resource = klass.FETCH_URI.format(account_id=account.id)
                request = Request(account.client, 'get', resource, params=kwargs)
                return Cursor(klass, request, init_with=[account])
    Severity: Major
    Found in twitter_ads/creative.py and 1 other location - About 1 hr to fix
    twitter_ads/creative.py on lines 445..450

    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 49.

    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

    Further Reading

    Similar blocks of code found in 3 locations. Consider refactoring.
    Open

    class MediaCreative(Analytics, Resource, Persistence):
    
        PROPERTIES = {}
    
        RESOURCE_COLLECTION = '/' + API_VERSION + '/accounts/{account_id}/media_creatives'
    Severity: Major
    Found in twitter_ads/creative.py and 2 other locations - About 1 hr to fix
    twitter_ads/campaign.py on lines 148..153
    twitter_ads/creative.py on lines 16..21

    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 45.

    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

    Further Reading

    Similar blocks of code found in 3 locations. Consider refactoring.
    Open

    class PromotedAccount(Analytics, Resource, Persistence):
    
        PROPERTIES = {}
    
        RESOURCE_COLLECTION = '/' + API_VERSION + '/accounts/{account_id}/promoted_accounts'
    Severity: Major
    Found in twitter_ads/creative.py and 2 other locations - About 1 hr to fix
    twitter_ads/campaign.py on lines 148..153
    twitter_ads/creative.py on lines 106..111

    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 45.

    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

    Further Reading

    Similar blocks of code found in 9 locations. Consider refactoring.
    Open

    class AccountMedia(Resource, Persistence):
    
        PROPERTIES = {}
    
        RESOURCE_COLLECTION = '/' + API_VERSION + '/accounts/{account_id}/account_media'
    Severity: Major
    Found in twitter_ads/creative.py and 8 other locations - About 1 hr to fix
    twitter_ads/campaign.py on lines 308..313
    twitter_ads/campaign.py on lines 335..340
    twitter_ads/campaign.py on lines 355..360
    twitter_ads/creative.py on lines 129..134
    twitter_ads/creative.py on lines 163..168
    twitter_ads/creative.py on lines 201..206
    twitter_ads/creative.py on lines 227..232
    twitter_ads/creative.py on lines 308..313

    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 44.

    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

    Further Reading

    Similar blocks of code found in 9 locations. Consider refactoring.
    Open

    class ScheduledTweet(Resource, Persistence):
    
        PROPERTIES = {}
    
        RESOURCE_COLLECTION = '/' + API_VERSION + '/accounts/{account_id}/scheduled_tweets'
    Severity: Major
    Found in twitter_ads/creative.py and 8 other locations - About 1 hr to fix
    twitter_ads/campaign.py on lines 308..313
    twitter_ads/campaign.py on lines 335..340
    twitter_ads/campaign.py on lines 355..360
    twitter_ads/creative.py on lines 87..92
    twitter_ads/creative.py on lines 129..134
    twitter_ads/creative.py on lines 163..168
    twitter_ads/creative.py on lines 227..232
    twitter_ads/creative.py on lines 308..313

    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 44.

    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

    Further Reading

    Similar blocks of code found in 9 locations. Consider refactoring.
    Open

    class DraftTweet(Resource, Persistence):
    
        PROPERTIES = {}
    
        RESOURCE_COLLECTION = '/' + API_VERSION + '/accounts/{account_id}/draft_tweets'
    Severity: Major
    Found in twitter_ads/creative.py and 8 other locations - About 1 hr to fix
    twitter_ads/campaign.py on lines 308..313
    twitter_ads/campaign.py on lines 335..340
    twitter_ads/campaign.py on lines 355..360
    twitter_ads/creative.py on lines 87..92
    twitter_ads/creative.py on lines 129..134
    twitter_ads/creative.py on lines 163..168
    twitter_ads/creative.py on lines 201..206
    twitter_ads/creative.py on lines 308..313

    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 44.

    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

    Further Reading

    Similar blocks of code found in 9 locations. Consider refactoring.
    Open

    class VideoConversationCard(Resource, Persistence):
    
        PROPERTIES = {}
    
        RESOURCE_COLLECTION = '/' + API_VERSION + '/accounts/{account_id}/cards/video_conversation'
    Severity: Major
    Found in twitter_ads/creative.py and 8 other locations - About 1 hr to fix
    twitter_ads/campaign.py on lines 308..313
    twitter_ads/campaign.py on lines 335..340
    twitter_ads/campaign.py on lines 355..360
    twitter_ads/creative.py on lines 87..92
    twitter_ads/creative.py on lines 129..134
    twitter_ads/creative.py on lines 201..206
    twitter_ads/creative.py on lines 227..232
    twitter_ads/creative.py on lines 308..313

    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 44.

    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

    Further Reading

    Similar blocks of code found in 9 locations. Consider refactoring.
    Open

    class PollCard(Resource, Persistence):
    
        PROPERTIES = {}
    
        RESOURCE_COLLECTION = '/' + API_VERSION + '/accounts/{account_id}/cards/poll'
    Severity: Major
    Found in twitter_ads/creative.py and 8 other locations - About 1 hr to fix
    twitter_ads/campaign.py on lines 308..313
    twitter_ads/campaign.py on lines 335..340
    twitter_ads/campaign.py on lines 355..360
    twitter_ads/creative.py on lines 87..92
    twitter_ads/creative.py on lines 129..134
    twitter_ads/creative.py on lines 163..168
    twitter_ads/creative.py on lines 201..206
    twitter_ads/creative.py on lines 227..232

    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 44.

    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

    Further Reading

    Similar blocks of code found in 9 locations. Consider refactoring.
    Open

    class ImageConversationCard(Resource, Persistence):
    
        PROPERTIES = {}
    
        RESOURCE_COLLECTION = '/' + API_VERSION + '/accounts/{account_id}/cards/image_conversation'
    Severity: Major
    Found in twitter_ads/creative.py and 8 other locations - About 1 hr to fix
    twitter_ads/campaign.py on lines 308..313
    twitter_ads/campaign.py on lines 335..340
    twitter_ads/campaign.py on lines 355..360
    twitter_ads/creative.py on lines 87..92
    twitter_ads/creative.py on lines 163..168
    twitter_ads/creative.py on lines 201..206
    twitter_ads/creative.py on lines 227..232
    twitter_ads/creative.py on lines 308..313

    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 44.

    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

    Further Reading

    There are no issues that match your filters.

    Category
    Status