Passed
Push — develop ( 08e1cf...7492d1 )
by Dean
02:39
created

PausedHandler   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 21
Duplicated Lines 100 %

Test Coverage

Coverage 93.33%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 7
c 1
b 0
f 0
dl 21
loc 21
ccs 14
cts 15
cp 0.9333
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B process() 14 14 7

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.scrobbler.core import SessionEngine, SessionHandler
2
3
4 1 View Code Duplication
@SessionEngine.register
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
5 1
class PausedHandler(SessionHandler):
6 1
    __event__ = 'paused'
7
8 1
    __src__ = ['pause', 'start', 'stop']
9 1
    __dst__ = ['pause', 'stop']
10
11 1
    @classmethod
12
    def process(cls, session, payload):
13
        # Handle media change
14 1
        if cls.has_media_changed(session, payload) and session.state in ['start', 'pause']:
15
            yield 'stop', session.payload
16
17
        # Handle current media
18 1
        if cls.should_scrobble(session, payload):
19 1
            if session.state in ['start', 'pause']:
20 1
                yield 'stop', payload
21 1
        elif session.state == 'start':
22 1
            yield 'pause', payload
23 1
        elif session.state == 'pause':
24
            yield None, payload
25