fuzeman/trakt.py

View on GitHub

Showing 249 of 249 total issues

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

    def new(self, media, **kwargs):
        if media != 'shows':
            raise ValueError("Media '%s' does not support the `new()` method" % (media,))

        return self.get(media, 'new', **kwargs)
Severity: Major
Found in trakt/interfaces/calendars.py and 1 other location - About 1 hr to fix
trakt/interfaces/calendars.py on lines 18..22

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

Function __init__ has 37 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def __init__(self, client, keys, index=None):
        super(Show, self).__init__(client, keys, index)

        self.title = None
        """
Severity: Minor
Found in trakt/objects/show.py - About 1 hr to fix

    Function construct has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        def construct(cls, client, media, item, keys=None, **kwargs):
            if keys is None:
                _, keys = cls.get_ids(media, item)
    
            if media == 'movie':
    Severity: Minor
    Found in trakt/mapper/core/base.py - About 1 hr to fix

    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 dictfilter has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    def dictfilter(d, **kwargs):
        result = {}
    
        if 'get' in kwargs:
            for key in kwargs['get']:
    Severity: Minor
    Found in trakt/core/helpers.py - About 1 hr to fix

    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

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

        @authenticated
        def movies(self, username, id=None, start_at=None, end_at=None, store=None, **kwargs):
            return self.get(
                username, 'movies',
    Severity: Major
    Found in trakt/interfaces/users/history.py and 3 other locations - About 1 hr to fix
    trakt/interfaces/users/history.py on lines 96..99
    trakt/interfaces/users/history.py on lines 107..110
    trakt/interfaces/users/history.py on lines 118..121

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

    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 4 locations. Consider refactoring.
    Open

        @authenticated
        def shows(self, username, id=None, start_at=None, end_at=None, store=None, **kwargs):
            return self.get(
                username, 'shows',
    Severity: Major
    Found in trakt/interfaces/users/history.py and 3 other locations - About 1 hr to fix
    trakt/interfaces/users/history.py on lines 85..88
    trakt/interfaces/users/history.py on lines 107..110
    trakt/interfaces/users/history.py on lines 118..121

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

    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 4 locations. Consider refactoring.
    Open

        @authenticated
        def episodes(self, username, id=None, start_at=None, end_at=None, store=None, **kwargs):
            return self.get(
                username, 'episodes',
    Severity: Major
    Found in trakt/interfaces/users/history.py and 3 other locations - About 1 hr to fix
    trakt/interfaces/users/history.py on lines 85..88
    trakt/interfaces/users/history.py on lines 96..99
    trakt/interfaces/users/history.py on lines 107..110

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

    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 4 locations. Consider refactoring.
    Open

        @classmethod
        def _construct(cls, client, keys, info=None, index=None, **kwargs):
            person = cls(client, keys, index=index)
            person._update(info, **kwargs)
    
    
    Severity: Major
    Found in trakt/objects/person.py and 3 other locations - About 1 hr to fix
    trakt/objects/episode.py on lines 167..172
    trakt/objects/season.py on lines 122..127
    trakt/objects/show.py on lines 283..288

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

    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 4 locations. Consider refactoring.
    Open

        @classmethod
        def _construct(cls, client, keys, info=None, index=None, **kwargs):
            episode = cls(client, keys, index=index)
            episode._update(info, **kwargs)
    
    
    Severity: Major
    Found in trakt/objects/episode.py and 3 other locations - About 1 hr to fix
    trakt/objects/person.py on lines 79..84
    trakt/objects/season.py on lines 122..127
    trakt/objects/show.py on lines 283..288

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

    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 4 locations. Consider refactoring.
    Open

        @classmethod
        def _construct(cls, client, keys, info=None, index=None, **kwargs):
            season = cls(client, keys, index=index)
            season._update(info, **kwargs)
    
    
    Severity: Major
    Found in trakt/objects/season.py and 3 other locations - About 1 hr to fix
    trakt/objects/episode.py on lines 167..172
    trakt/objects/person.py on lines 79..84
    trakt/objects/show.py on lines 283..288

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

    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 4 locations. Consider refactoring.
    Open

        @authenticated
        def seasons(self, username, id=None, start_at=None, end_at=None, store=None, **kwargs):
            return self.get(
                username, 'seasons',
    Severity: Major
    Found in trakt/interfaces/users/history.py and 3 other locations - About 1 hr to fix
    trakt/interfaces/users/history.py on lines 85..88
    trakt/interfaces/users/history.py on lines 96..99
    trakt/interfaces/users/history.py on lines 118..121

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

    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 4 locations. Consider refactoring.
    Open

        @classmethod
        def _construct(cls, client, keys, info=None, index=None, **kwargs):
            show = cls(client, keys, index=index)
            show._update(info, **kwargs)
    
    
    Severity: Major
    Found in trakt/objects/show.py and 3 other locations - About 1 hr to fix
    trakt/objects/episode.py on lines 167..172
    trakt/objects/person.py on lines 79..84
    trakt/objects/season.py on lines 122..127

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

    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

    Function _send has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def _send(self, request):
            response = self.client.http.send(request)
    
            if response is None:
                if self.exceptions:
    Severity: Minor
    Found in trakt/core/pagination.py - About 1 hr to fix

    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 get has 10 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def get(self, username, media=None, id=None, start_at=None, end_at=None, store=None,
    Severity: Major
    Found in trakt/interfaces/users/history.py - About 1 hr to fix

      Function request has 10 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def request(self, method, path=None, params=None, data=None, query=None, authenticated=False,
      Severity: Major
      Found in trakt/core/http.py - About 1 hr to fix

        Function get_ids has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            def get_ids(media, item, parent=None):
                if not item:
                    return None, []
        
                ids = item.get('ids', {})
        Severity: Minor
        Found in trakt/mapper/core/base.py - About 1 hr to fix

        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

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

            @classmethod
            def _construct(cls, info=None, **kwargs):
                if not info:
                    return
        
        
        Severity: Major
        Found in trakt/objects/progress.py and 1 other location - About 1 hr to fix
        trakt/objects/progress.py on lines 316..324

        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

        Further Reading

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

            @authenticated
            def shows(self, id=None, start_at=None, end_at=None, store=None, **kwargs):
                return self.get(
        Severity: Major
        Found in trakt/interfaces/sync/history.py and 3 other locations - About 1 hr to fix
        trakt/interfaces/sync/history.py on lines 49..51
        trakt/interfaces/sync/history.py on lines 71..73
        trakt/interfaces/sync/history.py on lines 82..84

        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

        Further Reading

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

                if 'last_episode' in info:
                    episode = self._client.construct('episode', info['last_episode'])
        
                    if episode:
                        self.last_episode = episode
        Severity: Major
        Found in trakt/objects/progress.py and 1 other location - About 1 hr to fix
        trakt/objects/progress.py on lines 174..178

        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

        Further Reading

        Function to_dict has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            def to_dict(self):
                """Dump episode to a dictionary.
        
                :return: Episode dictionary
                :rtype: :class:`~python:dict`
        Severity: Minor
        Found in trakt/objects/episode.py - About 1 hr to fix

        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

        Severity
        Category
        Status
        Source
        Language