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.
Completed
Push — master ( cc6b42...7d41d1 )
by Flávio
01:26 queued 01:22
created

EntityBase   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Test Coverage

Coverage 95%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 6
c 2
b 0
f 0
dl 0
loc 38
ccs 19
cts 20
cp 0.95
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __init__() 0 10 3
A get_schema() 0 8 1
A validate() 0 16 2
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
#
4
# The MIT License (MIT)
5
#
6
# Copyright (c) 2016 Trocafone
7
#
8
# Permission is hereby granted, free of charge, to any person obtaining a copy
9
# of this software and associated documentation files (the "Software"), to deal
10
# in the Software without restriction, including without limitation the rights
11
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
# copies of the Software, and to permit persons to whom the Software is
13
# furnished to do so, subject to the following conditions:
14
#
15
# The above copyright notice and this permission notice shall be included in
16
# all copies or substantial portions of the Software.
17
#
18
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24
# SOFTWARE.
25
#
26
###############################################################################
27
28 1
from zeep import Client
1 ignored issue
show
Configuration introduced by
The import zeep 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...
29 1
from zeep.transports import Transport
1 ignored issue
show
Configuration introduced by
The import zeep.transports 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...
30 1
from voluptuous import Invalid, MultipleInvalid
1 ignored issue
show
Configuration introduced by
The import voluptuous 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...
31 1
import certifi
1 ignored issue
show
Configuration introduced by
The import certifi 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...
32
33
34 1
class WebserviceError(Exception):
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...
35 1
    pass
36
37
38 1
class WebserviceBase():
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...
introduced by
Old-style class defined.
Loading history...
Complexity introduced by
This abstract class seems to be used only once.

Abstract classes which are used only once can usually be inlined into the class which already uses this abstract class.

Loading history...
39
40 1
    def __init__(self, env, id_correios, password, cert=False):
41
        ''' Webservice initialization.
42
43
        Depending on the env get a different wsdl definition.
44
        New Correios SIGEP uses HTTPAuth to do requests.
45
46
        Args:
47
            env (str): Environment used to get the wsdl
48
            id_correios (str): IdCorreios given by correios website
49
            password (str): password vinculated to the IdCorreios
50
        '''
51
52
        ''' Untrusted ssl certificate for homolog envs see more at:
53
54
        https://www.ssllabs.com/ssltest/analyze.html?d=apphom.correios.com.br
55
        '''
0 ignored issues
show
Unused Code introduced by
This string statement has no effect and could be removed.
Loading history...
56 1
        if cert is False:
57 1
            verify = False
58
        else:
59
            verify = certifi.where()
60
61 1
        t = Transport(
0 ignored issues
show
Coding Style Naming introduced by
The name t 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...
62
            verify=verify,
63
            http_auth=(id_correios, password)
64
        )
65 1
        self.client = Client(wsdl=self.get_env(env), transport=t)
66
67 1
    def get_env(self, env):
68
        """ Get WSDL Url.
69
70
        Must be implemented in order to return the correct WSDL.
71
72
        Args:
73
            env (str): Environment used to get the wsdl
74
75
        Returns:
76
            str: WSDL Url of the corresponding environment
77
        """
78 1
        raise NotImplementedError()
79
80 1
    def call(self, method, request):
81
        ''' Call the webservice method with the validated request content
82
83
        Args:
84
            method (str): Name of the method available at the webservice
85
            request (RequestObject): Object containing all the info needed
86
87
        Returns:
88
            dict: Result of the service call
89
        '''
90 1
        service_method = getattr(self.client.service, method, None)
91
92 1
        try:
93 1
            return service_method(request)
94 1
        except ValueError:
95 1
            raise WebserviceError('The method you are trying to call does not '
96
                                  'exists.')
97
98
99 1
class EntityBase(dict):
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...
100
101 1
    def __init__(self, **kargs):
102 1
        super(EntityBase, self).__init__(kargs)
103 1
        self.validate()
104
105 1
        try:
106 1
            raise getattr(self, 'error')
107 1
        except AttributeError:
108 1
            pass
109 1
        except Invalid as e:
1 ignored issue
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...
110 1
            raise MultipleInvalid([e])
111
112 1
    def get_schema(self):
113
        """ Returns validation schema
114
115
        Returns:
116
            voluptous.Schema: Schema with validation rules
117
        """
118
        raise NotImplementedError("Every entitiy needs validation against a " +
119
                                  "Schema.")
120
121 1
    def validate(self):
122
        """ Validates content against schema
123
124
        In case of failure an error is kept inside the entity object,
125
        to be displayed by the client user if needed.
126
127
        Returns:
128
            bool: Validation result
129
        """
130 1
        schema = self.get_schema()
131 1
        try:
132 1
            super(EntityBase, self).__init__(schema(self))
133 1
            return True
134 1
        except Exception as e:
1 ignored issue
show
Best Practice introduced by
Catching very general exceptions such as Exception is usually not recommended.

Generally, you would want to handle very specific errors in the exception handler. This ensure that you do not hide other types of errors which should be fixed.

So, unless you specifically plan to handle any error, consider adding a more specific exception.

Loading history...
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...
135 1
            self.error = e
136
            return False
137