GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

saruman.helpers.error_handling()   B
last analyzed

Complexity

Conditions 7

Size

Total Lines 17

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 9.584
Metric Value
cc 7
dl 0
loc 17
ccs 10
cts 16
cp 0.625
crap 9.584
rs 7.3333
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 1
import contextlib
4 1
import logging
5
6 1
from plumbum.commands.processes import ProcessExecutionError, CommandNotFound, ProcessTimedOut
0 ignored issues
show
Configuration introduced by
The import plumbum.commands.processes could not be resolved.

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...
7 1
from celery.exceptions import (SecurityError, Ignore, QueueNotFound, WorkerShutdown, WorkerTerminate,
0 ignored issues
show
Configuration introduced by
The import celery.exceptions could not be resolved.

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...
8
                               ImproperlyConfigured, NotRegistered, AlreadyRegistered,
9
                               MaxRetriesExceededError, Retry,
10
                               TaskRevokedError, NotConfigured, AlwaysEagerIgnored,
11
                               InvalidTaskError, ChordError, CPendingDeprecationWarning,
12
                               CDeprecationWarning, FixupWarning, DuplicateNodenameWarning,
13
                               SoftTimeLimitExceeded, TimeLimitExceeded, WorkerLostError,
14
                               Terminated)
15 1
from saruman.helpers.exceptions import FirewallGenericError
16
17 1
__all__ = ['error_handling']
18
19 1
WARNING = (Ignore, AlreadyRegistered, CPendingDeprecationWarning,
20
           CDeprecationWarning, FixupWarning, DuplicateNodenameWarning,
21
           SoftTimeLimitExceeded, Retry)
22 1
HANDLED_ERROR = ()
23 1
UNHANDLED_ERROR = (ProcessTimedOut, WorkerShutdown, WorkerTerminate, ImproperlyConfigured, NotRegistered,
24
                   MaxRetriesExceededError, TaskRevokedError, NotConfigured, AlwaysEagerIgnored, InvalidTaskError,
25
                   ChordError, FirewallGenericError, TimeLimitExceeded, WorkerLostError, Terminated)
26 1
CRITICAL = (ProcessExecutionError, CommandNotFound, SecurityError, QueueNotFound)
27
28
29 1
@contextlib.contextmanager
30
def error_handling(logger):
0 ignored issues
show
Coding Style introduced by
This function 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...
31 1
    try:
32 1
        assert isinstance(logger, logging.Logger)
33 1
        try:
34 1
            yield
35 1
        except WARNING as e:
0 ignored issues
show
Coding Style Naming introduced by
The name e does not conform to the variable naming conventions ([a-z_][a-z0-9_]{2,30}$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
36
            logger.warning(e)
37 1
        except UNHANDLED_ERROR as e:
0 ignored issues
show
Coding Style Naming introduced by
The name e does not conform to the variable naming conventions ([a-z_][a-z0-9_]{2,30}$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
38
            logger.error(e)
39
            raise
40 1
        except HANDLED_ERROR as e:
0 ignored issues
show
Coding Style Naming introduced by
The name e does not conform to the variable naming conventions ([a-z_][a-z0-9_]{2,30}$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
41
            logger.error(e)
42 1
        except CRITICAL as e:
0 ignored issues
show
Coding Style Naming introduced by
The name e does not conform to the variable naming conventions ([a-z_][a-z0-9_]{2,30}$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
43 1
            logger.critical(e)
44
    except Exception as e:
0 ignored issues
show
Coding Style Naming introduced by
The name e does not conform to the variable naming conventions ([a-z_][a-z0-9_]{2,30}$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
45
        print(e)
46