prefeiturasp/SME-PratoAberto-Editor

View on GitHub

Showing 70 of 131 total issues

File app.py has 1671 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import collections
import datetime
import itertools
import json
import os
Severity: Major
Found in app.py - About 4 days to fix

    Function gera_excel has a Cognitive Complexity of 102 (exceeds 5 allowed). Consider refactoring.
    Open

    def gera_excel(parametros):
        try:
            # ..Acesso ao banco de dados
            client = pymongo.MongoClient(os.environ.get('MONGO_HOST'))
            db = client.pratoaberto
    Severity: Minor
    Found in helpers/download_spreadsheet.py - About 2 days 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 atualiza_historico_escolas has a Cognitive Complexity of 73 (exceeds 5 allowed). Consider refactoring.
    Open

    def atualiza_historico_escolas():
        data = request.form.get('json_dump', request.data)
        jdata = json.loads(data)
        jdata = [dict(t) for t in set([tuple(d.items()) for d in jdata])]
        flag_verificacoes = True
    Severity: Minor
    Found in app.py - About 1 day 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 create has a Cognitive Complexity of 48 (exceeds 5 allowed). Consider refactoring.
    Open

    def create(FILE):
        cardapio_dict = {}
        with open(FILE, 'r', encoding="ISO-8859-1") as f:
    
            soup = bs4.BeautifulSoup(f.read())
    Severity: Minor
    Found in cardapio_xml_para_dict.py - About 7 hrs 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 upload_file has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
    Open

    def upload_file():
        if 'file' not in request.files:
            flash('Nenhum arquivo foi selecionado!', 'danger')
            return redirect(url_for('backlog'))
    
    
    Severity: Minor
    Found in app.py - About 6 hrs 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 a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
    Open

    def set_planilha(unidade, menu, semana, data_de, data_ate, wb, ws, xls_file):
        semana_de, semana_ate = str(get_num_semana(data_de)), str(get_num_semana(data_ate))
        lista_semanas = [i for i in range(int(semana_de), int(semana_ate) + 1)]
        w_de, w_ate = str(get_num_semana(data_de)), str(get_num_semana(data_ate))
    
    
    Severity: Minor
    Found in helpers/download_special_unit_menu.py - About 5 hrs 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 post_idades_idades has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
    Open

    def post_idades_idades():
        escolas = get_escolas()
        headers = {'Content-type': 'application/json'}
        count = 0
        dic_refeicoes = {
    Severity: Minor
    Found in analises.py - About 4 hrs 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 upload_terceirizadas has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
    Open

    def upload_terceirizadas():
        headers = {'Content-type': 'application/json'}
        data = request.form.get('json_dump', request.data)
        jdata = json.loads(data)
        cardapios = []
    Severity: Minor
    Found in app.py - About 4 hrs 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 escolas has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
    Open

    def escolas(id_escola=None):
        form = SchoolRegistrationForm(request.form)
        if id_escola:
            school = get_escola(id_escola, raw=True)
            form.cod_eol.data = id_escola
    Severity: Minor
    Found in app.py - About 4 hrs 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 calendario_grupo_cardapio has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
    Open

    def calendario_grupo_cardapio():
        data = request.form.get('json_dump', request.data)
    
        charset = ['"', '[', ']']
        for char in charset:
    Severity: Minor
    Found in app.py - About 4 hrs 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 calendario has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
    Open

    def calendario():
        """
        do pendencias_publicacao vem pra ca quando se clica em href="/calendario?
    
        """
    Severity: Minor
    Found in app.py - About 3 hrs 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

    File analises.py has 304 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import collections
    import configparser
    import datetime
    import itertools
    
    
    Severity: Minor
    Found in analises.py - About 3 hrs to fix

      File download_spreadsheet.py has 290 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      #
      
      # download_spreadsheet.py
      #
      #   Gera arquivo excel com os cardápios publicados 
      Severity: Minor
      Found in helpers/download_spreadsheet.py - About 2 hrs to fix

        Function get_cardapios_unidades_especiais has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
        Open

        def get_cardapios_unidades_especiais(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 2 hrs 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

        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_escolas_dict has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
          Open

          def get_escolas_dict(params=None, by_type=None, limit=None):
              schools, _ = get_escolas(params=params, limit=limit)
              schools_dict = []
              if by_type and len(by_type):
                  if 'TODOS' in by_type:
          Severity: Minor
          Found in app.py - About 2 hrs 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 mapa_pendencias has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

          def mapa_pendencias():
              if request.method == "GET":
                  mapa = get_quebras_escolas()
          
                  delta_dias = datetime.timedelta(days=7)
          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 select_receitas_terceirizadas has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

          def select_receitas_terceirizadas(tipo_gestao, tipo_escola, edital, idade):
              engine = create_engine('sqlite:///sqlite/configuracoes_editor_merenda.db')
              Base.metadata.bind = engine
              dbsession = sessionmaker(bind=engine)
              session = dbsession()
          Severity: Minor
          Found in db_functions.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 save_dia has 12 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          def save_dia(sv_cardapios_dia, sv_lin, sv_data_ant, sv_num_faixas, sv_num_refeicoes, sv_tipo_escola, sv_tipo_gestao,
          Severity: Major
          Found in helpers/download_spreadsheet.py - About 1 hr to fix

            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

            Severity
            Category
            Status
            Source
            Language