radar-parlamentar/radar

View on GitHub
radar_parlamentar/importadores/camara_genero.py

Summary

Maintainability
A
3 hrs
Test Coverage

Function contabiliza_termos_geral has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

def contabiliza_termos_geral(lista_indexadas):
    for proposicao in lista_indexadas:
        for termo in proposicao['txtIndexacao']:
            if termo not in DESCARTADAS:
                if termo in DIC_TERMOS:
Severity: Minor
Found in radar_parlamentar/importadores/camara_genero.py - About 1 hr 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 jsonMatrix_gera_links_partidos_termos has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def jsonMatrix_gera_links_partidos_termos():
    global matrix
    matrix['links'] = []
    for p in range(len(matrix['partidos'])):
        partidoNome = matrix['partidos'][p]['name']
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 partidos_das_proposicoes has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def partidos_das_proposicoes(lista_proposicoes):
    for proposicao in lista_proposicoes:
        if proposicao['txtSiglaPartido']:
            partido = proposicao['txtSiglaPartido'].strip()
            if partido not in PARTIDOS:
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 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

Merge this if statement with the enclosing one.
Open

            if proposicao['txtSiglaPartido'].strip() in LISTA_BASE_PARTIDOS:

Merging collapsible if statements increases the code's readability.

Noncompliant Code Example

if condition1:
    if condition2:
        # ...

Compliant Solution

if condition1 and condition2:
    # ...

Rename function "jsonMatrix_gera_partidos" to match the regular expression ^[a-z_][a-z0-9_]{2,}$.
Open

def jsonMatrix_gera_partidos():

Shared coding conventions allow teams to collaborate efficiently. This rule checks that all function names match a provided regular expression.

Noncompliant Code Example

With the default provided regular expression: ^[a-z_][a-z0-9_]{2,30}$

def MyFunction(a,b):
    ...

Compliant Solution

def my_function(a,b):
    ...

Rename function "jsonMatrix_gera_termos_mais_mais" to match the regular expression ^[a-z_][a-z0-9_]{2,}$.
Open

def jsonMatrix_gera_termos_mais_mais():

Shared coding conventions allow teams to collaborate efficiently. This rule checks that all function names match a provided regular expression.

Noncompliant Code Example

With the default provided regular expression: ^[a-z_][a-z0-9_]{2,30}$

def MyFunction(a,b):
    ...

Compliant Solution

def my_function(a,b):
    ...

Rename function "jsonMatrix_gera_links_partidos_termos" to match the regular expression ^[a-z_][a-z0-9_]{2,}$.
Open

def jsonMatrix_gera_links_partidos_termos():

Shared coding conventions allow teams to collaborate efficiently. This rule checks that all function names match a provided regular expression.

Noncompliant Code Example

With the default provided regular expression: ^[a-z_][a-z0-9_]{2,30}$

def MyFunction(a,b):
    ...

Compliant Solution

def my_function(a,b):
    ...

There are no issues that match your filters.

Category
Status