Passed
Push — master ( 694e2f...150a8e )
by Dean
09:10 queued 06:18
created

OpenSSL   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Test Coverage

Coverage 60%

Importance

Changes 4
Bugs 0 Features 0
Metric Value
wmc 3
c 4
b 0
f 0
dl 0
loc 32
ccs 9
cts 15
cp 0.6
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A test_import() 0 16 2
A on_success() 0 9 1
1 1
from plugin.core.libraries.tests.core.base import BaseTest
0 ignored issues
show
Bug introduced by
The name base does not seem to exist in module plugin.core.libraries.tests.core.
Loading history...
Configuration introduced by
Unable to import 'plugin.core.libraries.tests.core.base' (invalid syntax (<string>, line 52))

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
4 1
class OpenSSL(BaseTest):
0 ignored issues
show
Coding Style introduced by
This class has no __init__ method.
Loading history...
5 1
    name = 'openssl'
6 1
    optional = True
7
8 1
    @staticmethod
9
    def test_import():
10
        import OpenSSL.SSL
0 ignored issues
show
Comprehensibility Bug introduced by
OpenSSL is re-defining a name which is already available in the outer-scope (previously defined on line 4).

It is generally a bad practice to shadow variables from the outer-scope. In most cases, this is done unintentionally and might lead to unexpected behavior:

param = 5

class Foo:
    def __init__(self, param):   # "param" would be flagged here
        self.param = param
Loading history...
11
12
        # Try construct SSL context
13
        ctx = OpenSSL.SSL.Context(OpenSSL.SSL.SSLv23_METHOD)
14
15
        # Ensure library has SNI support
16
        cnx = OpenSSL.SSL.Connection(ctx)
17
18
        if not hasattr(cnx, 'set_tlsext_host_name'):
19
            raise Exception('Missing SNI extension')
20
21
        return {
22
            'versions': {
23
                'pyopenssl': getattr(OpenSSL, '__version__', None)
24
            }
25
        }
26
27 1
    @classmethod
28
    def on_success(cls, metadata):
0 ignored issues
show
Unused Code introduced by
The argument metadata seems to be unused.
Loading history...
29
        # Inject pyopenssl into requests
30 1
        from requests.packages.urllib3.contrib.pyopenssl import inject_into_urllib3
31 1
        inject_into_urllib3()
32
33
        # Enable secure error reporting
34 1
        from plugin.core.logger.handlers.error_reporter import RAVEN
0 ignored issues
show
Bug introduced by
The name error_reporter does not seem to exist in module plugin.core.logger.handlers.
Loading history...
Configuration introduced by
Unable to import 'plugin.core.logger.handlers.error_reporter' (invalid syntax (<string>, line 134))

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...
35
        RAVEN.set_protocol('threaded+requests+https')
36