Passed
Push — master ( aeb165...d9ae97 )
by Dean
03:04
created

PersonalLists   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 31
Duplicated Lines 100 %

Test Coverage

Coverage 29.4%
Metric Value
wmc 5
dl 31
loc 31
ccs 5
cts 17
cp 0.294
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A run() 18 18 3
A create_playlist() 8 8 2

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1 1
from plugin.sync.core.enums import SyncData, SyncMode, SyncMedia
2 1
from plugin.sync.modes.pull.lists.base import Lists
3
4 1
import elapsed
5 1
import logging
6
7 1
log = logging.getLogger(__name__)
8
9
10 1 View Code Duplication
class PersonalLists(Lists):
0 ignored issues
show
Coding Style introduced by
This class has no __init__ method.
Loading history...
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
11 1
    data = [SyncData.Personal]
12 1
    mode = SyncMode.Pull
13
14 1
    @elapsed.clock
15
    def run(self):
16
        # Retrieve plex sections
17
        p_sections, p_sections_map = self.sections()
0 ignored issues
show
Bug introduced by
The Instance of PersonalLists does not seem to have a member named sections.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
Unused Code introduced by
The variable p_sections seems to be unused.
Loading history...
18
19
        # Retrieve plex playlists
20
        p_playlists = dict(self.get_playlists())
21
22
        # Retrieve trakt lists
23
        t_lists = self.trakt[(SyncMedia.Lists, SyncData.Personal)]
0 ignored issues
show
Bug introduced by
The Instance of PersonalLists does not seem to have a member named trakt.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
24
25
        if t_lists is None:
26
            log.warn('Unable to retrieve liked lists')
27
            return
28
29
        # Process trakt lists
30
        for _, t_list in t_lists.items():
31
            self.process(SyncData.Personal, p_playlists, p_sections_map, t_list)
32
33 1
    def create_playlist(self, uri, name):
34
        # Check if playlist creation is enabled
35
        if self.configuration['sync.lists.personal.playlists'] is False:
0 ignored issues
show
Bug introduced by
The Instance of PersonalLists does not seem to have a member named configuration.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
36
            log.info('No playlist found named %r ("Create playlists in plex" not enabled)', name)
37
            return None
38
39
        # Create playlist
40
        return super(PersonalLists, self).create_playlist(uri, name)
41