prefeiturasp/SME-PratoAberto-Editor

View on GitHub
helpers/gerador_excel_cardapio_ue.py

Summary

Maintainability
B
6 hrs
Test Coverage

GeradorExcelCardapioUE has 24 functions (exceeds 20 allowed). Consider refactoring.
Open

class GeradorExcelCardapioUE(object):

    def __init__(self, id_unidade_especial):
        self.api = os.environ.get('PRATOABERTO_API')
        # self.api = 'http://localhost:8000'
Severity: Minor
Found in helpers/gerador_excel_cardapio_ue.py - About 2 hrs to fix

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

        def get_refeicao_by_categoria(self, faixa, data, categoria, semana):
            for cardapio in self.cardapios:
                if cardapio.get('data') == data and cardapio.get('faixa') == faixa and cardapio.get('semana') == semana:
                    for categ, refeicao in cardapio.get('cardapio').items():
                        if categ == categoria:
    Severity: Minor
    Found in helpers/gerador_excel_cardapio_ue.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 _criar_refeicoes_cardapios has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def _criar_refeicoes_cardapios(self, semana, categorias_faixas_dict, datas_cardapio, aba_planilha):
            posicao_linha_inicial = 4
            posicisao_coluna_inicial = 2
            contador_colunas_faixa = 0
            for faixa, categorias in categorias_faixas_dict.items():
    Severity: Minor
    Found in helpers/gerador_excel_cardapio_ue.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 _criar_faixa_etaria_categoria_planilha has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def _criar_faixa_etaria_categoria_planilha(self, aba_planilha, coluna_final, coluna_inicial_categoria,
    Severity: Minor
    Found in helpers/gerador_excel_cardapio_ue.py - About 45 mins to fix

      Function _escrever_titulos_planilha has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def _escrever_titulos_planilha(self, aba_planilha, data_fim_formatada, data_inicio_formatada, titulo_polo,
      Severity: Minor
      Found in helpers/gerador_excel_cardapio_ue.py - About 35 mins to fix

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

            def _get_categorias_by_faixa_etaria_dict(self, semana, faixa_etarias):
                categoria_dict = {}
                faixas_etarias_ordenada = sorted(faixa_etarias, key=lambda k: k)
                for faixa in faixas_etarias_ordenada:
                    categoria_dict[faixa] = []
        Severity: Minor
        Found in helpers/gerador_excel_cardapio_ue.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

        There are no issues that match your filters.

        Category
        Status