Passed
Push — develop ( e15ceb...5f9839 )
by Dean
02:51
created

SessionPrefix.increment()   A

Complexity

Conditions 2

Size

Total Lines 14

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 14
ccs 0
cts 8
cp 0
rs 9.4285
c 0
b 0
f 0
cc 2
crap 6
1
from plugin.core.environment import Environment
0 ignored issues
show
Bug introduced by
The name environment does not seem to exist in module plugin.core.
Loading history...
Configuration introduced by
Unable to import 'plugin.core.environment' (invalid syntax (<string>, line 101))

This can be caused by one of the following:

1. Missing Dependencies

This error could indicate a configuration issue of Pylint. Make sure that your libraries are available by adding the necessary commands.

# .scrutinizer.yml
before_commands:
    - sudo pip install abc # Python2
    - sudo pip3 install abc # Python3
Tip: We are currently not using virtualenv to run pylint, when installing your modules make sure to use the command for the correct version.

2. Missing __init__.py files

This error could also result from missing __init__.py files in your module folders. Make sure that you place one file in each sub-folder.

Loading history...
2
3
import logging
4
5
log = logging.getLogger(__name__)
6
7
8
class SessionPrefix(object):
9
    @classmethod
10
    def get(cls):
11
        prefix = cls._get()
12
13
        # Initial
14
        if prefix is None:
15
            return cls.increment()
16
17
        return prefix
18
19
    @classmethod
20
    def increment(cls):
21
        prefix = Environment.dict['session.prefix']
22
23
        if prefix is None:
24
            prefix = 1
25
        else:
26
            prefix += 1
27
28
        # Update session prefix
29
        cls._set(prefix)
30
31
        log.debug('Incremented session prefix to %r', prefix)
32
        return prefix
33
34
    @classmethod
35
    def _get(cls):
36
        return Environment.dict['session.prefix']
37
38
    @classmethod
39
    def _set(cls, prefix):
40
        Environment.dict['session.prefix'] = prefix
41