okfn-brasil/serenata-de-amor

View on GitHub

Showing 286 of 286 total issues

File fetch_sex_places.py has 411 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import asyncio
import json
import logging
import math
import os
Severity: Minor
Found in research/src/fetch_sex_places.py - About 5 hrs to fix

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

    class SuspiciousListFilter(JarbasListFilter):
    
        title = 'reembolso suspeito'
        parameter_name = 'is_suspicions'
        options = (
    Severity: Major
    Found in jarbas/dashboard/admin/list_filters.py and 1 other location - About 3 hrs to fix
    jarbas/dashboard/admin/list_filters.py on lines 83..97

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

    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

    class HasReceiptFilter(JarbasListFilter):
    
        title = 'nota fiscal digitalizada'
        parameter_name = 'has_receipt'
        options = (
    Severity: Major
    Found in jarbas/dashboard/admin/list_filters.py and 1 other location - About 3 hrs to fix
    jarbas/dashboard/admin/list_filters.py on lines 49..63

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

    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

    File fetch_tse_data.py has 279 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    """
    This script downloads and format some data from TSE website.
    The first objective with this data is to obtain a list of all politicians in Brazil.
    In march 2017, the data available in TSE website contained information about elected people from the year 1994 to 2016.
    Data before 1994 does not contains name of the politicians.
    Severity: Minor
    Found in research/src/fetch_tse_data.py - About 2 hrs to fix

      File fetch_cnpj_info.py has 267 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      from concurrent import futures
      import json
      import argparse
      import time
      import random
      Severity: Minor
      Found in research/src/fetch_cnpj_info.py - About 2 hrs to fix

        File translation_table.py has 261 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        from bs4 import BeautifulSoup
        
        
        EN = (
            {
        Severity: Minor
        Found in research/src/translation_table.py - About 2 hrs to fix

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

          class ApplicantListView(ListAPIView):
          
              serializer_class = ApplicantSerializer
          
              def get_queryset(self):
          Severity: Major
          Found in jarbas/chamber_of_deputies/views.py and 1 other location - About 2 hrs to fix
          jarbas/chamber_of_deputies/views.py on lines 116..123

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

          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

          class SubquotaListView(ListAPIView):
          
              serializer_class = SubquotaSerializer
          
              def get_queryset(self):
          Severity: Major
          Found in jarbas/chamber_of_deputies/views.py and 1 other location - About 2 hrs to fix
          jarbas/chamber_of_deputies/views.py on lines 106..113

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

          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

                  if (index % 100) == 0 and index > 0:
                      print('###########################################')
                      print("%s requests made. Stopping to save." % index)
                      write_fetched_companies(fetched_companies)
                      print('###########################################')
          Severity: Major
          Found in research/src/fetch_yelp_info.py and 1 other location - About 1 hr to fix
          research/src/fetch_foursquare_info.py on lines 172..176

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

          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

                  if (index % 100) == 0 and index > 0:
                      print('###########################################')
                      print("%s companies fetched. Stopping to save." % index)
                      write_fetched_companies(fetched_companies)
                      print('###########################################')
          Severity: Major
          Found in research/src/fetch_foursquare_info.py and 1 other location - About 1 hr to fix
          research/src/fetch_yelp_info.py on lines 145..149

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

          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

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

          def transform_and_translate_data(json_data):
              """
              Transform main activity, secondary activity and partners list in
              multi columns and translate column names.
              """
          Severity: Minor
          Found in research/src/fetch_cnpj_info.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

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

          Severity: Major
          Found in rosie/rosie/federal_senate/__init__.py and 1 other location - About 1 hr to fix
          rosie/rosie/chamber_of_deputies/__init__.py on lines 0..9

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

          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

          Severity: Major
          Found in rosie/rosie/chamber_of_deputies/__init__.py and 1 other location - About 1 hr to fix
          rosie/rosie/federal_senate/__init__.py on lines 0..9

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

          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

              data['amendment_beneficiary'] = data['amendment_beneficiary'].map(lambda x: str(x).zfill(14))
          Severity: Major
          Found in research/src/fetch_federal_budget_datasets.py and 1 other location - About 1 hr to fix
          research/src/fetch_federal_sanctions.py on lines 115..115

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

          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

              data['company_cnpj'] = data['company_cnpj'].map(lambda x: str(x).zfill(14))
          Severity: Major
          Found in research/src/fetch_federal_sanctions.py and 1 other location - About 1 hr to fix
          research/src/fetch_federal_budget_datasets.py on lines 45..45

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

          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

          Function run has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

          def run(target, limit=None):
              """
              :param target: (string) path to the directory to save the receipts images
              :param limit: (int) limit the amount of receipts to fecth (default: None)
              """
          Severity: Minor
          Found in research/src/fetch_receipts.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

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

          result_translation = {
              'SUPLENTE': 'alternate',
              'NÃO ELEITO': 'not_elected',
              '#NULO#': 'null',
              'ELEITO': 'elected',
          Severity: Minor
          Found in research/src/fetch_tse_data.py and 1 other location - About 55 mins to fix
          research/src/fetch_federal_sanctions.py on lines 73..90

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

          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

              data.rename(columns={
                  'Tipo de Pessoa': 'entity_type',
                  'CPF ou CNPJ do Sancionado': 'sanctioned_cnpj_cpf',
                  'Nome Informado pelo Órgão Sancionador': 'name_given_by_sanctioning_body',
                  'Razão Social - Cadastro Receita': 'company_name_receita_database',
          Severity: Minor
          Found in research/src/fetch_federal_sanctions.py and 1 other location - About 55 mins to fix
          research/src/fetch_tse_data.py on lines 279..296

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

          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

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

              def handle(self, *args, **options):
                  if not all(self.credentials):
                      self.log.warning('Twitter API credentials not set.')
                      return
          
          
          Severity: Minor
          Found in jarbas/chamber_of_deputies/management/commands/tweets.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 organize_deputy_data has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

          def organize_deputy_data(deputy, advisors):
              """
              Organizes all the deputies information in a list. Use this function to
              prepare data to be written to CSV format.
              :deputy: (dict) A dict with keys `deputy_name` and `deputy_number`
          Severity: Minor
          Found in research/src/fetch_deputies_advisors.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

          Severity
          Category
          Status
          Source
          Language