okfn-brasil/serenata-de-amor

View on GitHub

Showing 286 of 286 total issues

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

    def handle(self, *args, **options):
        self.batch, self.pause = options['batch_size'], options['pause']
        self.count = 0
        self.queue = []

Severity: Minor
Found in jarbas/chamber_of_deputies/management/commands/receipts.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

                if future.exception() is None and future.result() is not None and future.result()['status'] == 'OK':
                    result_translated = transform_and_translate_data(
                        future.result())
                    temp_dataset = pd.concat([temp_dataset, result_translated])
                    if last_saving_point < divmod(len(temp_dataset.index), 100)[0]:
Severity: Major
Found in research/src/fetch_cnpj_info.py - About 45 mins to fix

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

        def get(self, request):
    
            # get filtering parameters from query string
            params = (
                'applicant_id',
    Severity: Minor
    Found in jarbas/chamber_of_deputies/views.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

    Function translate_impeded_non_profit_entities_dataset has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def translate_impeded_non_profit_entities_dataset(filepath, dataset_name, year, month, day):
    Severity: Minor
    Found in research/src/fetch_federal_sanctions.py - About 35 mins to fix

      Function dummy_translation_dataset has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def dummy_translation_dataset(filepath, dataset_name, year, month, day):
      Severity: Minor
      Found in research/src/fetch_federal_sanctions.py - About 35 mins to fix

        Function translate_national_register_punished_companies_dataset has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        def translate_national_register_punished_companies_dataset(filepath, dataset_name, year, month, day):
        Severity: Minor
        Found in research/src/fetch_federal_sanctions.py - About 35 mins to fix

          Function translate_inident_and_suspended_companies_dataset has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          def translate_inident_and_suspended_companies_dataset(filepath, dataset_name, year, month, day):
          Severity: Minor
          Found in research/src/fetch_federal_sanctions.py - About 35 mins to fix

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

                data.to_csv(path_or_buf='{0}{1}-{2}-{3}-{4}.xz'.format(BASE_DATA_DIR, year, month, day, dataset_name), sep=',',
            Severity: Major
            Found in research/src/fetch_federal_sanctions.py and 3 other locations - About 35 mins to fix
            research/src/fetch_federal_sanctions.py on lines 66..66
            research/src/fetch_federal_sanctions.py on lines 117..117
            research/src/fetch_federal_sanctions.py on lines 124..124

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

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

            def read_geocoding_info(company):
                cnpj = re.sub(CNPJ_REGEX, '', company['cnpj'])
                filename = '%s/%s.pkl' % (TEMP_PATH, cnpj)
                if os.path.isfile(filename):
                    with open(filename, 'rb') as f:
            Severity: Minor
            Found in research/src/geocode_addresses.py - About 35 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

                if isinstance(string, str):
                    nfkd_form = unicodedata.normalize('NFKD', string.lower())
                    return nfkd_form.encode('ASCII', 'ignore').decode('utf-8')
            Severity: Minor
            Found in research/src/fetch_inbox.py and 1 other location - About 35 mins to fix
            rosie/rosie/chamber_of_deputies/classifiers/meal_price_outlier_classifier.py on lines 104..106

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

            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

                    dates = sorted(set([l[0] for l in matches if l]), reverse=True)
            Severity: Minor
            Found in research/src/group_receipts.py and 2 other locations - About 35 mins to fix
            research/src/fetch_foursquare_info.py on lines 25..25
            research/src/fetch_yelp_info.py on lines 51..51

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

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

                data.to_csv(path_or_buf='{0}{1}-{2}-{3}-{4}.xz'.format(BASE_DATA_DIR, year, month, day, dataset_name), sep=',',
            Severity: Major
            Found in research/src/fetch_federal_sanctions.py and 3 other locations - About 35 mins to fix
            research/src/fetch_federal_sanctions.py on lines 66..66
            research/src/fetch_federal_sanctions.py on lines 99..99
            research/src/fetch_federal_sanctions.py on lines 124..124

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

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

                data.to_csv(path_or_buf='{0}{1}-{2}-{3}-{4}.xz'.format(BASE_DATA_DIR, year, month, day, dataset_name), sep=',',
            Severity: Major
            Found in research/src/fetch_federal_sanctions.py and 3 other locations - About 35 mins to fix
            research/src/fetch_federal_sanctions.py on lines 99..99
            research/src/fetch_federal_sanctions.py on lines 117..117
            research/src/fetch_federal_sanctions.py on lines 124..124

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

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

            def send_requests(reqs):
                """
                Send all the requests in :reqs: and reads the response data to extract the
                deputies data.  It will check if a deputy has more than one page of
                advisors and send new requests if True
            Severity: Minor
            Found in research/src/fetch_deputies_advisors.py - About 35 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 4 locations. Consider refactoring.
            Open

                data.to_csv(path_or_buf='{0}{1}-{2}-{3}-{4}.xz'.format(BASE_DATA_DIR, year, month, day, dataset_name), sep=',',
            Severity: Major
            Found in research/src/fetch_federal_sanctions.py and 3 other locations - About 35 mins to fix
            research/src/fetch_federal_sanctions.py on lines 66..66
            research/src/fetch_federal_sanctions.py on lines 99..99
            research/src/fetch_federal_sanctions.py on lines 117..117

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

            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

                dates = sorted(set([l[0] for l in matches if l]), reverse=True)
            Severity: Minor
            Found in research/src/fetch_foursquare_info.py and 2 other locations - About 35 mins to fix
            research/src/fetch_yelp_info.py on lines 51..51
            research/src/group_receipts.py on lines 26..26

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

            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

                dates = sorted(set([l[0] for l in matches if l]), reverse=True)
            Severity: Minor
            Found in research/src/fetch_yelp_info.py and 2 other locations - About 35 mins to fix
            research/src/fetch_foursquare_info.py on lines 25..25
            research/src/group_receipts.py on lines 26..26

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

            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

                def __normalize_string(self, string):
                    nfkd_form = unicodedata.normalize('NFKD', string.lower())
                    return nfkd_form.encode('ASCII', 'ignore').decode('utf-8')
            research/src/fetch_inbox.py on lines 15..17

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

            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

                def print_saving(self, **kwargs):
                    saving_msg = '{} (Saving the URLs to the database…)'
                    return self.print_msg(saving_msg.format(self.count_msg()), **kwargs)
            Severity: Minor
            Found in jarbas/chamber_of_deputies/management/commands/receipts.py and 1 other location - About 30 mins to fix
            jarbas/chamber_of_deputies/management/commands/receipts.py on lines 83..85

            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

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

                def print_pause(self, **kwargs):
                    pause_msg = '{} (Taking a break to avoid being blocked…)'
                    return self.print_msg(pause_msg.format(self.count_msg()), **kwargs)
            Severity: Minor
            Found in jarbas/chamber_of_deputies/management/commands/receipts.py and 1 other location - About 30 mins to fix
            jarbas/chamber_of_deputies/management/commands/receipts.py on lines 87..89

            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

            Severity
            Category
            Status
            Source
            Language