radar-parlamentar/radar

View on GitHub
radar_parlamentar/importadores/camara_genero/genero_historia_partidos.py

Summary

Maintainability
D
2 days
Test Coverage

Avoid deeply nested control flow statements.
Open

                if not len(partido):
                    partido = "SEM PARTIDO"
                if partido == "S":
Severity: Major
Found in radar_parlamentar/importadores/camara_genero/genero_historia_partidos.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                    if partido not in lista_partidos:
                        lista_partidos.append(partido)
    
    
    Severity: Major
    Found in radar_parlamentar/importadores/camara_genero/genero_historia_partidos.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                      if not nums:
                          nums = {"M": 0, "F": 0}
                          legis_partidos[legislatura] = nums
                      nums[genero] = nums.get(genero, 0) + 1
      Severity: Major
      Found in radar_parlamentar/importadores/camara_genero/genero_historia_partidos.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                        if ano.find("e") == -1:
                            anos2.append(ano)
                        else:
                            ano1, e, ano2 = ano.partition("e")
                            anos2.append(ano1.strip())
        Severity: Major
        Found in radar_parlamentar/importadores/camara_genero/genero_historia_partidos.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                          if not legis_partidos:
                              legis_partidos = {}
                              historia[partido] = legis_partidos
                          nums = legis_partidos.get(legislatura, {})
          Severity: Major
          Found in radar_parlamentar/importadores/camara_genero/genero_historia_partidos.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                            if partido == "S":
                                partido = "SEM PARTIDO"
            
            
            Severity: Major
            Found in radar_parlamentar/importadores/camara_genero/genero_historia_partidos.py - About 45 mins to fix

              Remove this commented out code.
              Open

                          #    nums["duracao"] = duracao

              Programmers should not comment out code as it bloats programs and reduces readability.

              Unused code should be deleted and can be retrieved from source control history if required.

              See

              • MISRA C:2004, 2.4 - Sections of code should not be "commented out".
              • MISRA C++:2008, 2-7-2 - Sections of code shall not be "commented out" using C-style comments.
              • MISRA C++:2008, 2-7-3 - Sections of code should not be "commented out" using C++ comments.
              • MISRA C:2012, Dir. 4.4 - Sections of code should not be "commented out"

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

                          for leg in legis:
                              termos = leg.split(",")
                              data = termos[1].strip()
                              try:
                                  partido = termos[-1].strip().partition(".")[0]
              radar_parlamentar/importadores/camara_genero/genero_comparativo_partidos.py on lines 47..62

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

              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 3 locations. Consider refactoring.
              Open

                          for ano in anos:
                              if ano.find("e") == -1:
                                  anos2.append(ano)
                              else:
                                  ano1, e, ano2 = ano.partition("e")
              radar_parlamentar/importadores/camara_genero/genero_comparativo_partidos.py on lines 37..43
              radar_parlamentar/importadores/camara_genero/num_genero_legis.py on lines 37..43

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

              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 4 locations. Consider refactoring.
              Open

                          if legis.find("Deputada") != -1:
                              genero = "F"
                              cont += 1
                          else:
                              genero = "M"
              radar_parlamentar/importadores/camara_genero/genero_comparativo_partidos.py on lines 25..29
              radar_parlamentar/importadores/camara_genero/nomes_deputadas_csv.py on lines 19..23
              radar_parlamentar/importadores/camara_genero/num_genero_legis.py on lines 25..29

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

              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

              Do not use bare 'except'
              Open

                              except:

              When catching exceptions, mention specific exceptions when possible.

              Okay: except Exception:
              Okay: except BaseException:
              E722: except:

              There are no issues that match your filters.

              Category
              Status