trocafone    /
                    correios-lib
                
                            | Total Complexity | 1 | 
| Total Lines | 10 | 
| Duplicated Lines | 80 % | 
| Coverage | 100% | 
| Changes | 0 | ||
| Metric | Value | 
|---|---|
| wmc | 1 | 
| dl | 8 | 
| loc | 10 | 
| ccs | 3 | 
| cts | 3 | 
| cp | 1 | 
| rs | 10 | 
| c | 0 | 
| b | 0 | 
| f | 0 | 
| Rating | Name | Duplication | Size | Complexity | 
|---|---|---|---|---|
| A | get_schema() | 8 | 8 | 1 | 
Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
| 1 | # -*- coding: utf-8 -*-  | 
            ||
| 
                                                                                                    
                         0 ignored issues 
                            –
                            show
                         | 
                |||
| 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 correios_lib.base import EntityBase  | 
            |
| 29 | 1 | from correios_lib.validators import CEP, Email, Date, Price  | 
            |
| 30 | 1 | from voluptuous import *  | 
            |
| 
                                                                                                    
                         0 ignored issues 
                            –
                            show
                         | 
                |||
| 31 | |||
| 32 | |||
| 33 | 1 | class Destinatario(EntityBase):  | 
            |
| 34 | ''' Reference to wsdl: '''  | 
            ||
| 35 | |||
| 36 | 1 | def get_schema(self):  | 
            |
| 37 | 1 |         return Schema({ | 
            |
| 
                                                                                                    
                         0 ignored issues 
                            –
                            show
                         | 
                |||
| 38 |             Required('nome'): All(Coerce(str), Length(max=60)), | 
            ||
| 
                                                                                                                                                                                                                                                                
                         0 ignored issues 
                            –
                            show
                         | 
                |||
| 39 |             Required('logradouro'): All(Coerce(str), Length(max=72)), | 
            ||
| 
                                                                                                                                                                                                                                                                
                         0 ignored issues 
                            –
                            show
                         | 
                |||
| 40 |             Required('numero'): All(Coerce(str), Length(max=8)), | 
            ||
| 
                                                                                                                                                                                                                                                                
                         0 ignored issues 
                            –
                            show
                         | 
                |||
| 41 |             Optional('complemento'): All(Coerce(str), Length(max=30)), | 
            ||
| 
                                                                                                                                                                                                                                                                
                         0 ignored issues 
                            –
                            show
                         | 
                |||
| 42 |             Required('bairro'): All(Coerce(str), Length(max=50)), | 
            ||
| 
                                                                                                                                                                                                                                                                
                         0 ignored issues 
                            –
                            show
                         | 
                |||
| 43 |             Optional('referencia'): All(Coerce(str), Length(max=60)), | 
            ||
| 
                                                                                                                                                                                                                                                                
                         0 ignored issues 
                            –
                            show
                         | 
                |||
| 44 |             Required('cidade'): All(Coerce(str), Length(max=36)), | 
            ||
| 
                                                                                                                                                                                                                                                                
                         0 ignored issues 
                            –
                            show
                         | 
                |||
| 45 |             Required('uf'): All(Coerce(str), Length(min=2, max=2)), | 
            ||
| 
                                                                                                                                                                                                                                                                
                         0 ignored issues 
                            –
                            show
                         | 
                |||
| 46 |             Required('cep'): All(CEP, Length(min=8, max=9)), | 
            ||
| 
                                                                                                                                                                                                            
                         0 ignored issues 
                            –
                            show
                         | 
                |||
| 47 |             Optional('ddd'): All(Coerce(str), Length(min=2, max=2)), | 
            ||
| 
                                                                                                                                                                                                                                                                
                         0 ignored issues 
                            –
                            show
                         | 
                |||
| 48 |             Optional('telefone'): All(Coerce(str), Length(min=8, max=12)), | 
            ||
| 
                                                                                                                                                                                                                                                                
                         0 ignored issues 
                            –
                            show
                         | 
                |||
| 49 |             Optional('email'): All(Email, Length(max=72)) | 
            ||
| 
                                                                                                                                                                                                            
                         0 ignored issues 
                            –
                            show
                         | 
                |||
| 50 | }, extra=REMOVE_EXTRA)  | 
            ||
| 
                                                                                                    
                         0 ignored issues 
                            –
                            show
                         | 
                |||
| 51 | |||
| 52 | |||
| 53 | 1 | class Coleta(EntityBase):  | 
            |
| 
                                                                                                    
                         0 ignored issues 
                            –
                            show
                        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...
                 | 
                |||
| 54 | |||
| 55 | 1 | def get_schema(self):  | 
            |
| 56 | 1 |         return Schema({ | 
            |
| 
                                                                                                    
                         0 ignored issues 
                            –
                            show
                         | 
                |||
| 57 |             Required('tipo'): Any('CA', 'C', 'A'), | 
            ||
| 
                                                                                                                                                        
                         0 ignored issues 
                            –
                            show
                         | 
                |||
| 58 |             Optional('numero'): Coerce(int), | 
            ||
| 
                                                                                                                                                        
                         0 ignored issues 
                            –
                            show
                         | 
                |||
| 59 |             Optional('id_cliente'): All(Length(max=30)), | 
            ||
| 
                                                                                                                                                                                                            
                         0 ignored issues 
                            –
                            show
                         | 
                |||
| 60 |             Optional('ag'): Date, | 
            ||
| 
                                                                                                    
                         0 ignored issues 
                            –
                            show
                         | 
                |||
| 61 |             Optional('cartao'): Coerce(str), | 
            ||
| 
                                                                                                                                                        
                         0 ignored issues 
                            –
                            show
                         | 
                |||
| 62 |             Optional('valor_declarado'): Price, | 
            ||
| 
                                                                                                    
                         0 ignored issues 
                            –
                            show
                         | 
                |||
| 63 |             Optional('servico_adicional'): All(Coerce(str), Length(max=20)), | 
            ||
| 
                                                                                                                                                                                                                                                                
                         0 ignored issues 
                            –
                            show
                         | 
                |||
| 64 |             Optional('descricao'): All(Coerce(str), Length(max=255)), | 
            ||
| 
                                                                                                                                                                                                                                                                
                         0 ignored issues 
                            –
                            show
                         | 
                |||
| 65 |             Optional('ar'): Any(1, 0), | 
            ||
| 
                                                                                                                                                        
                         0 ignored issues 
                            –
                            show
                         | 
                |||
| 66 |             Optional('cklist'): Any(2, 4, 5, 7), | 
            ||
| 
                                                                                                                                                        
                         0 ignored issues 
                            –
                            show
                         | 
                |||
| 67 |             Optional('documento'): [str], | 
            ||
| 
                                                                                                    
                         0 ignored issues 
                            –
                            show
                         | 
                |||
| 68 |             Required('remetente'): Remetente, | 
            ||
| 
                                                                                                    
                         0 ignored issues 
                            –
                            show
                         | 
                |||
| 69 |             Optional('obj_col'): [Objeto], | 
            ||
| 
                                                                                                    
                         0 ignored issues 
                            –
                            show
                         | 
                |||
| 70 |             Optional('produto'): Produto | 
            ||
| 
                                                                                                    
                         0 ignored issues 
                            –
                            show
                         | 
                |||
| 71 | }, extra=REMOVE_EXTRA)  | 
            ||
| 
                                                                                                    
                         0 ignored issues 
                            –
                            show
                         | 
                |||
| 72 | |||
| 73 | |||
| 74 | 1 | class ColetaSimultanea(EntityBase):  | 
            |
| 
                                                                                                    
                         0 ignored issues 
                            –
                            show
                        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...
                 | 
                |||
| 75 | |||
| 76 | 1 | View Code Duplication | def get_schema(self):  | 
            
| 
                                                                                                    
                         0 ignored issues 
                            –
                            show
                         | 
                |||
| 77 | 1 |         return Schema({ | 
            |
| 
                                                                                                    
                         0 ignored issues 
                            –
                            show
                         | 
                |||
| 78 |             Required('tipo'): Any('C', 'A'), | 
            ||
| 
                                                                                                                                                        
                         0 ignored issues 
                            –
                            show
                         | 
                |||
| 79 |             Optional('id_cliente'): All(Length(max=30)), | 
            ||
| 
                                                                                                                                                                                                            
                         0 ignored issues 
                            –
                            show
                         | 
                |||
| 80 |             Optional('valor_declarado'): Price, | 
            ||
| 
                                                                                                    
                         0 ignored issues 
                            –
                            show
                         | 
                |||
| 81 |             Optional('descricao'): All(Coerce(str), Length(max=255)), | 
            ||
| 
                                                                                                                                                                                                                                                                
                         0 ignored issues 
                            –
                            show
                         | 
                |||
| 82 |             Optional('cklist'): Any(2, 4, 5, 7), | 
            ||
| 
                                                                                                                                                        
                         0 ignored issues 
                            –
                            show
                         | 
                |||
| 83 |             Optional('documento'): [str], | 
            ||
| 
                                                                                                    
                         0 ignored issues 
                            –
                            show
                         | 
                |||
| 84 |             Required('remetente'): Remetente, | 
            ||
| 
                                                                                                    
                         0 ignored issues 
                            –
                            show
                         | 
                |||
| 85 |             Optional('produto'): Produto, | 
            ||
| 
                                                                                                    
                         0 ignored issues 
                            –
                            show
                         | 
                |||
| 86 |             Optional('obs'): All(Coerce(str)) | 
            ||
| 
                                                                                                                                                                                                            
                         0 ignored issues 
                            –
                            show
                         | 
                |||
| 87 | }, extra=REMOVE_EXTRA)  | 
            ||
| 
                                                                                                    
                         0 ignored issues 
                            –
                            show
                         | 
                |||
| 88 | |||
| 89 | |||
| 90 | 1 | class Objeto(EntityBase):  | 
            |
| 
                                                                                                    
                         0 ignored issues 
                            –
                            show
                        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...
                 | 
                |||
| 91 | |||
| 92 | 1 | View Code Duplication | def get_schema(self):  | 
            
| 
                                                                                                    
                         0 ignored issues 
                            –
                            show
                         | 
                |||
| 93 | 1 |         return Schema({ | 
            |
| 
                                                                                                    
                         0 ignored issues 
                            –
                            show
                         | 
                |||
| 94 |             Required('item'): 1, | 
            ||
| 
                                                                                                    
                         0 ignored issues 
                            –
                            show
                         | 
                |||
| 95 |             Optional('id'): All(Coerce(str), Length(max=30)), | 
            ||
| 
                                                                                                                                                                                                                                                                
                         0 ignored issues 
                            –
                            show
                         | 
                |||
| 96 |             Optional('desc'): All(Coerce(str), Length(max=255)), | 
            ||
| 
                                                                                                                                                                                                                                                                
                         0 ignored issues 
                            –
                            show
                         | 
                |||
| 97 |             Optional('entrega'): All(Coerce(str), Length(max=13)), | 
            ||
| 
                                                                                                                                                                                                                                                                
                         0 ignored issues 
                            –
                            show
                         | 
                |||
| 98 |             Optional('num'): All(Coerce(str), Length(max=13)), | 
            ||
| 
                                                                                                                                                                                                                                                                
                         0 ignored issues 
                            –
                            show
                         | 
                |||
| 99 | }, extra=REMOVE_EXTRA)  | 
            ||
| 
                                                                                                    
                         0 ignored issues 
                            –
                            show
                         | 
                |||
| 100 | |||
| 101 | |||
| 102 | 1 | class Produto(EntityBase):  | 
            |
| 
                                                                                                    
                         0 ignored issues 
                            –
                            show
                        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...
                 | 
                |||
| 103 | |||
| 104 | 1 | def get_schema(self):  | 
            |
| 105 | 1 |         return Schema({ | 
            |
| 
                                                                                                    
                         0 ignored issues 
                            –
                            show
                         | 
                |||
| 106 |             Optional('codigo'): Coerce(int), | 
            ||
| 
                                                                                                                                                        
                         0 ignored issues 
                            –
                            show
                         | 
                |||
| 107 |             Optional('tipo'): Coerce(int), | 
            ||
| 
                                                                                                                                                        
                         0 ignored issues 
                            –
                            show
                         | 
                |||
| 108 |             Optional('qtd'): Coerce(int) | 
            ||
| 
                                                                                                                                                        
                         0 ignored issues 
                            –
                            show
                         | 
                |||
| 109 | }, extra=REMOVE_EXTRA)  | 
            ||
| 
                                                                                                    
                         0 ignored issues 
                            –
                            show
                         | 
                |||
| 110 | |||
| 111 | |||
| 112 | 1 | class Remetente(EntityBase):  | 
            |
| 
                                                                                                    
                         0 ignored issues 
                            –
                            show
                        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...
                 | 
                |||
| 113 | |||
| 114 | 1 | def get_schema(self):  | 
            |
| 115 | 1 |         return Schema({ | 
            |
| 
                                                                                                    
                         0 ignored issues 
                            –
                            show
                         | 
                |||
| 116 |             Required('nome'): All(Coerce(str), Length(max=60)), | 
            ||
| 
                                                                                                                                                                                                                                                                
                         0 ignored issues 
                            –
                            show
                         | 
                |||
| 117 |             Required('logradouro'): All(Coerce(str), Length(max=72)), | 
            ||
| 
                                                                                                                                                                                                                                                                
                         0 ignored issues 
                            –
                            show
                         | 
                |||
| 118 |             Required('numero'): All(Coerce(str), Length(max=8)), | 
            ||
| 
                                                                                                                                                                                                                                                                
                         0 ignored issues 
                            –
                            show
                         | 
                |||
| 119 |             Optional('complemento'): All(Coerce(str), Length(max=30)), | 
            ||
| 
                                                                                                                                                                                                                                                                
                         0 ignored issues 
                            –
                            show
                         | 
                |||
| 120 |             Required('bairro'): All(Coerce(str), Length(max=50)), | 
            ||
| 
                                                                                                                                                                                                                                                                
                         0 ignored issues 
                            –
                            show
                         | 
                |||
| 121 |             Optional('referencia'): All(Coerce(str), Length(max=60)), | 
            ||
| 
                                                                                                                                                                                                                                                                
                         0 ignored issues 
                            –
                            show
                         | 
                |||
| 122 |             Required('cidade'): All(Coerce(str), Length(max=36)), | 
            ||
| 
                                                                                                                                                                                                                                                                
                         0 ignored issues 
                            –
                            show
                         | 
                |||
| 123 |             Required('uf'): All(Coerce(str), Length(min=2, max=2)), | 
            ||
| 
                                                                                                                                                                                                                                                                
                         0 ignored issues 
                            –
                            show
                         | 
                |||
| 124 |             Required('cep'): All(CEP, Length(min=8, max=9)), | 
            ||
| 
                                                                                                                                                                                                            
                         0 ignored issues 
                            –
                            show
                         | 
                |||
| 125 |             Required('ddd'): All(Coerce(str), Length(min=2, max=2)), | 
            ||
| 
                                                                                                                                                                                                                                                                
                         0 ignored issues 
                            –
                            show
                         | 
                |||
| 126 |             Required('telefone'): All(Coerce(str), Length(min=8, max=12)), | 
            ||
| 
                                                                                                                                                                                                                                                                
                         0 ignored issues 
                            –
                            show
                         | 
                |||
| 127 |             Required('email'): All(Email, Length(max=72)), | 
            ||
| 
                                                                                                                                                                                                            
                         0 ignored issues 
                            –
                            show
                         | 
                |||
| 128 |             Optional('celular'): All(Coerce(str), Length(max=9)), | 
            ||
| 
                                                                                                                                                                                                                                                                
                         0 ignored issues 
                            –
                            show
                         | 
                |||
| 129 |             Optional('ddd_celular'): All(Coerce(str), Length(max=3)), | 
            ||
| 
                                                                                                                                                                                                                                                                
                         0 ignored issues 
                            –
                            show
                         | 
                |||
| 130 |             Optional('sms'): Any('S', 'N'), | 
            ||
| 
                                                                                                                                                        
                         0 ignored issues 
                            –
                            show
                         | 
                |||
| 131 |             Optional('identificacao'): All(Coerce(str), Length(max=14)) | 
            ||
| 
                                                                                                                                                                                                                                                                
                         0 ignored issues 
                            –
                            show
                         | 
                |||
| 132 | }, extra=REMOVE_EXTRA)  | 
            ||
| 
                                                                                                    
                         0 ignored issues 
                            –
                            show
                         | 
                |||
| 133 | 
The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:
If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.