fuzeman/trakt.py

View on GitHub

Showing 249 of 249 total issues

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

    @application
    @authenticated
    def pause(self, movie=None, show=None, episode=None, progress=0.0, **kwargs):
        """Send the scrobble "pause' action.

Severity: Major
Found in trakt/interfaces/scrobble.py and 2 other locations - About 50 mins to fix
trakt/interfaces/scrobble.py on lines 136..235
trakt/interfaces/scrobble.py on lines 342..446

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

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

    @application
    @authenticated
    def stop(self, movie=None, show=None, episode=None, progress=0.0, **kwargs):
        """Send the scrobble "stop" action.

Severity: Major
Found in trakt/interfaces/scrobble.py and 2 other locations - About 50 mins to fix
trakt/interfaces/scrobble.py on lines 136..235
trakt/interfaces/scrobble.py on lines 240..337

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

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

    @application
    @authenticated
    def start(self, movie=None, show=None, episode=None, progress=0.0, **kwargs):
        """Send the scrobble "start" action.

Severity: Major
Found in trakt/interfaces/scrobble.py and 2 other locations - About 50 mins to fix
trakt/interfaces/scrobble.py on lines 240..337
trakt/interfaces/scrobble.py on lines 342..446

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

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

def import_subclass(module_name, base):
    # TODO display a warning if multiple classes have been found?

    module = __import__(module_name, fromlist='*')
    result = None
Severity: Minor
Found in docs/conf.py - About 45 mins 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 item has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def item(cls, client, store, item, media=None, **kwargs):
        i_type = item.get('type') or media

        if not i_type:
            raise ValueError('Unknown item type')
Severity: Minor
Found in trakt/mapper/sync.py - About 45 mins 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 _update has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def _update(self, info=None, is_watched=None, is_collected=None, **kwargs):
        if not info:
            return

        super(Video, self)._update(info, **kwargs)
Severity: Minor
Found in trakt/objects/video.py - About 45 mins 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 __iter__ has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def __iter__(self):
        if self.total_pages is None:
            if self.exceptions:
                raise ValueError("Pagination state hasn't been resolved")

Severity: Minor
Found in trakt/core/pagination.py - About 45 mins 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 iterate_items has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def iterate_items(cls, client, store, items, func, media=None, **kwargs):
Severity: Minor
Found in trakt/mapper/sync.py - About 45 mins to fix

    Function seasons has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def seasons(self, username, id=None, start_at=None, end_at=None, store=None, **kwargs):
    Severity: Minor
    Found in trakt/interfaces/users/history.py - About 45 mins to fix

      Function process has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def process(cls, client, store, items, media=None, flat=False, **kwargs):
      Severity: Minor
      Found in trakt/mapper/sync.py - About 45 mins to fix

        Function lookup has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def lookup(self, id, service=None, media=None, extended=None, page=None, per_page=None, **kwargs):
                """Lookup items by their Trakt, IMDB, TMDB, TVDB, or TVRage ID.
        
                **Note:** If you lookup an identifier without a :code:`media` type specified it
                might return multiple items if the :code:`service` is not globally unique.
        Severity: Minor
        Found in trakt/interfaces/search.py - About 45 mins 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 shows has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def shows(self, username, id=None, start_at=None, end_at=None, store=None, **kwargs):
        Severity: Minor
        Found in trakt/interfaces/users/history.py - About 45 mins to fix

          Function get has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def get(self, source, media, collection=None, start_date=None, days=None, query=None, years=None, genres=None,
                      languages=None, countries=None, runtimes=None, ratings=None, certifications=None, networks=None,
                      status=None, **kwargs):
                  """Retrieve calendar items.
          
          
          Severity: Minor
          Found in trakt/interfaces/calendars.py - About 45 mins 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 _update has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def _update(self, info=None, in_watchlist=None, **kwargs):
                  if not info:
                      return
          
                  update_attributes(self, info, [
          Severity: Minor
          Found in trakt/objects/media.py - About 45 mins 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 action has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def action(self, action, movie=None, show=None, episode=None, progress=0.0, **kwargs):
          Severity: Minor
          Found in trakt/interfaces/scrobble.py - About 45 mins to fix

            Function _validate_oauth has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                def _validate_oauth(self):
                    config = self.client.configuration
            
                    # Ensure token expiry is available
                    if config['oauth.created_at'] is None or config['oauth.expires_in'] is None:
            Severity: Minor
            Found in trakt/core/http.py - About 45 mins 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 __call__ has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def __call__(self, token=None, refresh_token=None, created_at=None, expires_in=None, refresh=None, username=None):
            Severity: Minor
            Found in trakt/core/configuration.py - About 45 mins to fix

              Function movies has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  def movies(self, username, id=None, start_at=None, end_at=None, store=None, **kwargs):
              Severity: Minor
              Found in trakt/interfaces/users/history.py - About 45 mins to fix

                Function get has 6 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    def get(self, media=None, store=None, params=None, query=None, flat=False, **kwargs):
                Severity: Minor
                Found in trakt/interfaces/sync/core/mixins.py - About 45 mins to fix

                  Function progress has 6 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      def progress(self, progress_type, id, hidden=False, specials=False, count_specials=True, **kwargs):
                  Severity: Minor
                  Found in trakt/interfaces/shows/__init__.py - About 45 mins to fix
                    Severity
                    Category
                    Status
                    Source
                    Language