| Total Complexity | 5 |
| Total Lines | 31 |
| Duplicated Lines | 100 % |
| Coverage | 29.4% |
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 |
|
| 10 | 1 | View Code Duplication | class LikedLists(Lists): |
| 11 | 1 | data = [SyncData.Liked] |
|
| 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() |
||
| 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.Liked)] |
||
| 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.Liked, 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.liked.playlists'] is False: |
||
| 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(LikedLists, self).create_playlist(uri, name) |
||
| 41 |