prefeiturasp/SME-PratoAberto-Editor

View on GitHub

Showing 70 of 131 total issues

Function atualiza_config_cardapio has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

def atualiza_config_cardapio():
    form = OutSourcedMenuForm(request.form)
    new_menu = list()
    if 'is_unidade_especial' in request.form:
        new_menu.append('UE')
Severity: Minor
Found in app.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 set_unidade has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

def set_unidade(id_unidade, data_criacao=None, data_ini=None, data_fim=None, id_escolas=[]):
    db, client = connect()
    if db is not None:
        try:
            if data_criacao:
Severity: Minor
Found in ue_mongodb.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 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 publicacao has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

def publicacao():
    opt_status = ('STATUS', 'PUBLICADO', 'PENDENTE', 'SALVO', 'DELETADO')

    if 'refer' in session:
        if '/download_publicacao' not in request.referrer:
Severity: Minor
Found in app.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 adicionar_escola has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

def adicionar_escola():
    form = SchoolRegistrationForm(request.form)
    if not form.validate():
        flash('Ocorreu um erro ao salvar as informações')
        return redirect('editor/escolas?nome=&tipo_unidade=&limit=100&agrupamento=TODOS&tipo_atendimento=TODOS', code=302)
Severity: Minor
Found in app.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 get_pendencias has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def get_pendencias(request_obj, semana_default=None):
    params = request_obj.query_string.decode('utf-8')
    if 'filtro_semana' in params:
        week_filter = request_obj.args.get('filtro_semana')
        initial_date = datetime.datetime.strptime(week_filter.split(' - ')[0], '%d/%m/%Y').strftime('%Y%m%d')
Severity: Minor
Found in app.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 delete has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def delete(id_unidade=None):
    client = MongoClient(os.environ.get('MONGO_HOST'))
    db = client.pratoaberto
    if db is not None:
        if 'unidades_especiais' in db.list_collection_names():
Severity: Minor
Found in ue_mongodb.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 gera_excel has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def gera_excel(id_unidade):
    xls_file = None
    ue_dict = get_unidade_especial_by_id(id_unidade)
    unidade = ue_dict['nome']
    data_de = ue_dict['data_inicio']
Severity: Minor
Found in helpers/download_special_unit_menu.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 unidades_especiais has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def unidades_especiais(id_unidade_especial=None):
    form = SpecialUnitForm(request.form)
    form_filter = FilterTypeSchoolForm(request.form)
    by_type = form_filter.school_types.data
    if id_unidade_especial:
Severity: Minor
Found in app.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 get_quebras_escolas has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def get_quebras_escolas():
    escolas, paginacao = get_escolas()
    mapa_base = collections.defaultdict(list)
    for escola in escolas:
        try:
Severity: Minor
Found in app.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 set_planilha has 8 arguments (exceeds 4 allowed). Consider refactoring.
Open

def set_planilha(unidade, menu, semana, data_de, data_ate, wb, ws, xls_file):
Severity: Major
Found in helpers/download_special_unit_menu.py - About 1 hr to fix

    Function update_receitas_terceirizadas has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    def update_receitas_terceirizadas():
        r = db_functions.select_all_receitas_terceirizadas()
        modificacoes = []
        for row in r:
            row_aux = list(row[1:])
    Severity: Minor
    Found in analises.py - About 55 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 add_cardapio has 7 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def add_cardapio(tipo_gestao, tipo_escola, edital, diasemana, idade, refeicao, cardapio):
    Severity: Major
    Found in db_functions.py - About 50 mins to fix

      Function save_dia has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def save_dia(wb, ws, lin, data_ant, cardapios, xls_file):
      Severity: Minor
      Found in helpers/download_special_unit_menu.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                                    for row in default_sheet.rows:
                                        for cell in row:
                                            if isinstance(cell, Cell):
                                                new_cell = new_wb.cell(row=cell.row, column=cell.col_idx, value=cell.value)
                                                if cell.has_style:
        Severity: Major
        Found in helpers/download_spreadsheet.py - About 45 mins to fix

          Function get_publicados has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

          def get_publicados(request_obj, default_week):
              params = request_obj.query_string.decode('utf-8')
          
              if 'filtro_semana_mes' in params:
                  week_filter = request_obj.args.get('filtro_semana_mes')
          Severity: Minor
          Found in app.py - About 45 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 deeply nested control flow statements.
          Open

                                  for idade, v4 in v3.items():
                                      for data, v5 in v4.items():
                                          query = {
                                              'tipo_atendimento': tipo_atendimento,
                                              'tipo_unidade': tipo_unidade,
          Severity: Major
          Found in app.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                if _flag == True:
                                    # Encontramos o cardapio
                                    posicao = count
                                count += 1
            Severity: Major
            Found in app.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                  if subs is not None and subs.text is not None and len(subs.text):
                                      fullName = subs.text
                                  if item is not None and item.text is not None:
              Severity: Major
              Found in cardapio_xml_para_dict.py - About 45 mins to fix
                Severity
                Category
                Status
                Source
                Language