Passed
Push — master ( ed1cae...acd77f )
by
unknown
02:26
created

DummyNotifier.__init__()   A

Complexity

Conditions 1

Size

Total Lines 3
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nop 3
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
# -*- coding: utf-8 -*-
0 ignored issues
show
Coding Style introduced by
This module should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
2
3
from tracim.lib.utils.logger import logger
4
from tracim.models.auth import User
5
from tracim.models.data import Content
6
7
8
class INotifier(object):
9
    """
10
    Interface for Notifier instances
11
    """
12
    def __init__(self, config, current_user: User=None):
0 ignored issues
show
Coding Style introduced by
Exactly one space required around keyword argument assignment
Loading history...
13
        pass
14
15
    def notify_content_update(self, content: Content):
0 ignored issues
show
Coding Style introduced by
This method should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
16
        raise NotImplementedError
17
18
19
class NotifierFactory(object):
0 ignored issues
show
Coding Style introduced by
This class should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
Unused Code introduced by
The variable __class__ seems to be unused.
Loading history...
20
21
    @classmethod
22
    def create(cls, config, current_user: User=None) -> INotifier:
0 ignored issues
show
Coding Style introduced by
Exactly one space required around keyword argument assignment
Loading history...
Coding Style introduced by
This method should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
23
        if not config.EMAIL_NOTIFICATION_ACTIVATED:
24
            return DummyNotifier(config, current_user)
25
        return EmailNotifier(config, current_user)
26
27
28
class DummyNotifier(INotifier):
0 ignored issues
show
Coding Style introduced by
This class should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
Unused Code introduced by
The variable __class__ seems to be unused.
Loading history...
29
    send_count = 0
30
31
    def __init__(self, config, current_user: User=None):
0 ignored issues
show
Coding Style introduced by
Exactly one space required around keyword argument assignment
Loading history...
32
        INotifier.__init__(config, current_user)
33
        logger.info(self, 'Instantiating Dummy Notifier')
34
35
    def notify_content_update(self, content: Content):
36
        type(self).send_count += 1
37
        logger.info(
38
            self,
39
            'Fake notifier, do not send notification for update of content {}'.format(content.content_id)  # nopep8
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (115/100).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
40
        )
41
42
43
class EmailNotifier(INotifier):
0 ignored issues
show
Coding Style introduced by
This class should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
Bug introduced by
The method notify_content_update which was declared abstract in the super-class INotifier
was not overridden.

Methods which raise NotImplementedError should be overridden in concrete child classes.

Loading history...
44
    # TODO - G.M [emailNotif] move and restore Email Notifier in another file.
0 ignored issues
show
Coding Style introduced by
TODO and FIXME comments should generally be avoided.
Loading history...
45
    pass
46