radar-parlamentar/radar

View on GitHub

Showing 107 of 402 total issues

Function _voto_senado_to_model has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def _voto_senado_to_model(self, voto):
        """Interpreta voto como tá no XML e responde em adequação a modelagem
        em models.py"""

        DESCULPAS = ['MIS', 'MERC', 'P-NRV', 'REP',
Severity: Minor
Found in radar_parlamentar/importadores/sen.py - About 35 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Function main has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

def main(lista_casas_legislativas):

    for casa_legislativa in lista_casas_legislativas:

        if casa_legislativa == 'conv':
Severity: Minor
Found in radar_parlamentar/importadores/importador.py - About 35 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Function _montar_url_consulta_camara has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def _montar_url_consulta_camara(self, base_url, url_params, **kwargs):
        built_url = base_url

        for par in list(kwargs.keys()):
            if isinstance(kwargs[par], str):
Severity: Minor
Found in radar_parlamentar/importadores/cdep.py - About 35 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Function insere_genero_parlamentares_camara has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

def insere_genero_parlamentares_camara():
    URL_DADOS_CDEP = 'http://www.camara.leg.br/internet/deputado/'
    ARQ_DADOS_CDEP = 'DeputadosXML_52a55.zip'
    xml = abrir_xml_zipado(url=URL_DADOS_CDEP + ARQ_DADOS_CDEP)

Severity: Minor
Found in radar_parlamentar/importadores/cdep_genero.py - About 35 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Function proposicoes_indexadas has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

def proposicoes_indexadas(lista_proposicoes):
    indexados = []
    for proposicao in lista_proposicoes:
        if proposicao['txtIndexacao'] and proposicao['txtSiglaPartido']:
            if proposicao['txtSiglaPartido'].strip() in LISTA_BASE_PARTIDOS:
Severity: Minor
Found in radar_parlamentar/importadores/camara_genero.py - About 35 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Function _dict_partido has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def _dict_partido(self, partido):
        dict_partido = {"nome": partido.nome,
                        "numero": partido.numero,
                        "cor": partido.cor}
        dict_partido["t"] = []
Severity: Minor
Found in radar_parlamentar/analises/grafico.py - About 35 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Avoid too many return statements within this function.
Open

            return models.ABSTENCAO
Severity: Major
Found in radar_parlamentar/importadores/cmsp.py - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

                return 0
    Severity: Major
    Found in radar_parlamentar/exportadores/exportador_csv_r.py - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

                  return models.ABSTENCAO
      Severity: Major
      Found in radar_parlamentar/importadores/sen.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                    return models.ABSTENCAO
        Severity: Major
        Found in radar_parlamentar/importadores/sen.py - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                      return models.ABSTENCAO
          Severity: Major
          Found in radar_parlamentar/importadores/sen.py - About 30 mins to fix

            Function parseia_indexacoes has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            def parseia_indexacoes(indexacao):
                indexacao1 = [termo.strip()
                              for termo in indexacao.replace('\n', '').replace('.', '').
                              replace('_', '').split(',')]
                indexacao2 = []
            Severity: Minor
            Found in radar_parlamentar/importadores/camara_genero.py - About 25 mins to fix

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

            Function _votacao_from_xml has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def _votacao_from_xml(self, votacao_xml, prop):
                    """votacao_xml -- XML representando votação (objeto etree)
                       prop -- objeto do tipo Proposicao
                    """
                    descricao = 'Resumo: [%s]. ObjVotacao: [%s]' % (
            Severity: Minor
            Found in radar_parlamentar/importadores/cdep.py - About 25 mins to fix

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

            Function _scale has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def _scale(self, coords):
                    scaled = {}
                    for key, coord in list(coords.items()):
                        x = coord[0]
                        try:
            Severity: Minor
            Found in radar_parlamentar/analises/grafico.py - About 25 mins to fix

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

            Function importar_votacoes has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def importar_votacoes(self):
                    """# Realiza a consulta a API do senado através de uma request e
                    retorna os arquivos XMLS referentes as votações para serem importados
                    pelo radar
                     # facilita debug"""
            Severity: Minor
            Found in radar_parlamentar/importadores/sen.py - About 25 mins to fix

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

            Function plenaria has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            def plenaria(request, nome_curto_casa_legislativa=None,
                         identificador_proposicao=None):
                """identificador_proposicao: 'PL-123-2015'"""
            
                casas_legislativas = []
            Severity: Minor
            Found in radar_parlamentar/plenaria/views.py - About 25 mins to fix

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

            Function analisa_partidos has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def analisa_partidos(self):
                    """Gera as seguintes saídas:
                        self.coordenadas_partido # partido => [x,y]
                        self.tamanhos_partidos # partido => int
                        self.parlamentares_por_partido # partido => parlamentares
            Severity: Minor
            Found in radar_parlamentar/analises/analise.py - About 25 mins to fix

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

            Function _deputado has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def _deputado(self, voto_xml):
                    """Procura primeiro no cache e depois no banco; se não existir,
                    cria novo parlamentar"""
                    nome = voto_xml.get('Nome')
                    nome_partido = voto_xml.get('Partido')
            Severity: Minor
            Found in radar_parlamentar/importadores/cdep.py - About 25 mins to fix

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

            Function retrieve_votacoes has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def retrieve_votacoes(self):
                    try:
                        casa = models.CasaLegislativa.objects.get(nome_curto='cdep')
                    except:
                        casa = None
            Severity: Minor
            Found in radar_parlamentar/exportadores/exportador_csv_r.py - About 25 mins to fix

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

            Function enviar_para_elasticsearch has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            def enviar_para_elasticsearch(list_json, nome_indice):
                """Envia o json do modelo do radar para o Elasticsearch."""
                es = conectar_em_elastic_search()
                for item in list_json:
                    for key in list(item.keys()):
            Severity: Minor
            Found in radar_parlamentar/importadores/importador_elasticsearch.py - About 25 mins to fix

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

            Severity
            Category
            Status
            Source
            Language