prefeiturasp/SME-PratoAberto-Editor

View on GitHub
helpers/download_special_unit_menu.py

Summary

Maintainability
D
2 days
Test Coverage

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 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 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 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

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

      def set_cardapio(cardapios, doc_cardapio, doc_idade):
          l_refeicoes = list(doc_cardapio.keys())
          for refeicao in l_refeicoes:
              alimentos = ', '.join(doc_cardapio[refeicao])
              if doc_idade in cardapios:
      Severity: Minor
      Found in helpers/download_special_unit_menu.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 save_dia has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      def save_dia(wb, ws, lin, data_ant, cardapios, xls_file):
          numero_dia = datetime.weekday(datetime(int(data_ant[:4]), int(data_ant[4:][:2]), int(data_ant[6:])))
          nome_dia = dias_semana[numero_dia]
          dia = nome_dia + ' ' + data_ant[6:] + '/' + meses[int(data_ant[4:][:2]) - 1][:3]
          ws.cell(row=lin, column=1).value = dia
      Severity: Minor
      Found in helpers/download_special_unit_menu.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

      Identical blocks of code found in 2 locations. Consider refactoring.
      Open

      def get_num_semana(s_data):
          dta = s_data[:4] + '-' + s_data[4:][:2] + '-' + s_data[6:]
          tz_dta = datetime.strptime(dta, '%Y-%m-%d')
          return (tz_dta.isocalendar()[1])
      Severity: Major
      Found in helpers/download_special_unit_menu.py and 1 other location - About 4 hrs to fix
      helpers/download_spreadsheet.py on lines 128..131

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 84.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

          dia = nome_dia + ' ' + data_ant[6:] + '/' + meses[int(data_ant[4:][:2]) - 1][:3]
      Severity: Major
      Found in helpers/download_special_unit_menu.py and 1 other location - About 3 hrs to fix
      helpers/download_spreadsheet.py on lines 188..188

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 69.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

          numero_dia = datetime.weekday(datetime(int(data_ant[:4]), int(data_ant[4:][:2]), int(data_ant[6:])))
      Severity: Major
      Found in helpers/download_special_unit_menu.py and 1 other location - About 2 hrs to fix
      helpers/download_spreadsheet.py on lines 186..186

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 53.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

              for idade in l_idades:
                  l_refeicoes = list(cardapios[idade].keys())
                  for refeicao in l_refeicoes:
                      cardapios[idade][refeicao] = []
      Severity: Major
      Found in helpers/download_special_unit_menu.py and 1 other location - About 1 hr to fix
      helpers/download_spreadsheet.py on lines 375..378

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 48.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Identical blocks of code found in 2 locations. Consider refactoring.
      Open

          lista_semanas = [i for i in range(int(semana_de), int(semana_ate) + 1)]
      Severity: Minor
      Found in helpers/download_special_unit_menu.py and 1 other location - About 30 mins to fix
      helpers/download_special_unit_menu.py on lines 135..135

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 32.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Identical blocks of code found in 2 locations. Consider refactoring.
      Open

          lista_semanas = [i for i in range(int(semana_de), int(semana_ate) + 1)]
      Severity: Minor
      Found in helpers/download_special_unit_menu.py and 1 other location - About 30 mins to fix
      helpers/download_special_unit_menu.py on lines 223..223

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 32.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      There are no issues that match your filters.

      Category
      Status