Conditions | 6 |
Total Lines | 53 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 42 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | 1 | from plugin.sync.core.constants import GUID_AGENTS |
|
117 | def process_missing_movies(self): |
||
118 | """Trigger actions for movies that are in trakt, but was unable to be found in plex""" |
||
119 | |||
120 | # Increment progress steps |
||
121 | self.current.progress.group(Movies, 'missing:movies').add(len(self.p_pending)) |
||
122 | |||
123 | # Iterate over movies |
||
124 | for pk in list(self.p_pending): |
||
125 | # Increment one step |
||
126 | self.current.progress.group(Movies, 'missing:movies').step() |
||
127 | |||
128 | # Iterate over data handlers |
||
129 | triggered = False |
||
130 | |||
131 | for data in self.get_data(SyncMedia.Movies): |
||
132 | if data not in [SyncData.Collection]: |
||
133 | continue |
||
134 | |||
135 | # Retrieve movie |
||
136 | t_movie = self.trakt[(SyncMedia.Movies, data)].get(pk) |
||
137 | |||
138 | if not t_movie: |
||
139 | continue |
||
140 | |||
141 | log.debug('Found movie missing from plex: %r [data: %r]', pk, SyncData.title(data)) |
||
142 | |||
143 | # Trigger handler |
||
144 | self.execute_handlers( |
||
145 | SyncMedia.Movies, data, |
||
146 | |||
147 | key=None, |
||
148 | |||
149 | p_guid=Guid(*pk), |
||
150 | p_item=None, |
||
151 | |||
152 | t_item=t_movie |
||
153 | ) |
||
154 | |||
155 | # Mark triggered |
||
156 | triggered = True |
||
157 | |||
158 | # Check if action was triggered |
||
159 | if not triggered: |
||
160 | continue |
||
161 | |||
162 | # Remove movie from `pending` set |
||
163 | self.p_pending.remove(pk) |
||
164 | |||
165 | # Stop progress group |
||
166 | self.current.progress.group(Movies, 'missing:movies').stop() |
||
167 | |||
168 | # Report pending movies (no actions triggered) |
||
169 | self.log_pending('Unable to process %d movie(s)\n%s', self.p_pending) |
||
170 |
This check looks for calls to members that are non-existent. These calls will fail.
The member could have been renamed or removed.