okfn-brasil/serenata-de-amor

View on GitHub
research/src/fetch_cnpj_info.py

Summary

Maintainability
B
4 hrs
Test Coverage

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

    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

    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

      Invalid escape sequence '\d'
      Open

              date = re.compile('\d+-\d+-\d+-').findall(os.path.basename(filepath))
      Severity: Minor
      Found in research/src/fetch_cnpj_info.py by pep8

      Invalid escape sequences are deprecated in Python 3.6.

      Okay: regex = r'\.png$'
      W605: regex = '\.png$'

      Invalid escape sequence '\d'
      Open

              date = re.compile('\d+-\d+-\d+-').findall(os.path.basename(filepath))
      Severity: Minor
      Found in research/src/fetch_cnpj_info.py by pep8

      Invalid escape sequences are deprecated in Python 3.6.

      Okay: regex = r'\.png$'
      W605: regex = '\.png$'

      Invalid escape sequence '\d'
      Open

              date = re.compile('\d+-\d+-\d+-').findall(os.path.basename(filepath))
      Severity: Minor
      Found in research/src/fetch_cnpj_info.py by pep8

      Invalid escape sequences are deprecated in Python 3.6.

      Okay: regex = r'\.png$'
      W605: regex = '\.png$'

      There are no issues that match your filters.

      Category
      Status