UnB-KnEDLe/DODFMiner

View on GitHub

Showing 59 of 67 total issues

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

    def _extract_single_file(self):
        if self.args.type_of_extr is not None:
            if self.args.type_of_extr == 'pure-text':
                ContentExtractor.extract_text(self.args.single_file,
                                              single=True)
Severity: Minor
Found in dodfminer/run.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 segment has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

  def segment(self, file):
    atos_convenio = {
      'numero_dodf':[],
      'titulo':[],
      'texto':[]
Severity: Minor
Found in dodfminer/extract/polished/acts/convenio.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 _mount_json has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def _mount_json(self):
        """Mounts json containing titles with its associated subtitles
        and store it at self._json.

        Returns:
Severity: Minor
Found in dodfminer/extract/pure/utils/title_extractor.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 _mount_hierarchy has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def _mount_hierarchy(self):
        """Mounts list containing titles with its associated subtitles
        and store it at self._hierarchy.

        Returns:
Severity: Minor
Found in dodfminer/extract/pure/utils/title_extractor.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 extract_to_json has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def extract_to_json(cls, folder='./',
                        titles_with_boxes=False, norm='NFKD'):
        """Extract information from DODF to JSON.

        Args:
Severity: Minor
Found in dodfminer/extract/pure/core.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 segment has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

  def segment(self, file):
    atos_contrato = {
      'numero_dodf':[],
      'titulo':[],
      'texto':[]
Severity: Minor
Found in dodfminer/extract/polished/acts/contrato2.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 _extract_bold_upper_page has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

def _extract_bold_upper_page(page):
    """Extracts page content which have bold font and are uppercase.

    Args:
        page: fitz.fitz.Page object to have its bold content extracted.
Severity: Minor
Found in dodfminer/extract/pure/utils/title_extractor.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 segment has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

  def segment(self, file):
    atos_licitacao = {
      'numero_dodf':[],
      'titulo':[],
      'texto':[]
Severity: Minor
Found in dodfminer/extract/polished/acts/licitacao.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 _get_special_acts has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def _get_special_acts(self, lis_matches):
        for i, match in enumerate(self._raw_matches):
            act = match.group()
            matricula = re.search(MATRICULA, act) or \
                re.search(MATRICULA_GENERICO, act) or \
Severity: Minor
Found in dodfminer/extract/polished/acts/cessoes.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 segment has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

  def segment(self, file):
    atos_anulacao_revogacao = {
      'numero_dodf':[],
      'titulo':[],
      'texto':[]
Severity: Minor
Found in dodfminer/extract/polished/acts/anulacao_revogacao.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 segment has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

  def segment(self, file):
    atos_suspensao = {
      'numero_dodf':[],
      'titulo':[],
      'texto':[]
Severity: Minor
Found in dodfminer/extract/polished/acts/suspensao.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 _find_instances has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def _find_instances(self) -> List[Match]:
        """Returns list of re.Match objects found on `self._text_no_crosswords`.

        Return:
            a list with all re.Match objects resulted from searching for
Severity: Minor
Found in dodfminer/extract/polished/acts/sem_efeito_aposentadoria.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 extract_multiple_acts has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def extract_multiple_acts(path, types, backend):
    """Extract multple Acts from Multiple DODFs to act named CSVs.

    Args:
        path (str): Folder where the Dodfs are.
Severity: Minor
Found in dodfminer/extract/polished/helper.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 __init__ has 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def __init__(self, file, backend, debug=False, extra_search=True,
Severity: Major
Found in dodfminer/extract/polished/acts/sem_efeito_aposentadoria.py - About 50 mins to fix

    Function extract_text has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def extract_text(cls, file, single=False, block=False, is_json=True, sep=' ', norm='NFKD'):
    Severity: Minor
    Found in dodfminer/extract/pure/core.py - About 45 mins to fix

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

          def _limits(cls, sentence):
              """Find the limits of words in the sentence.
      
              Args:
                  sentence (str): target sentence.
      Severity: Minor
      Found in dodfminer/extract/polished/backend/ner.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 re.search(r'(?:ADITIVO)', titulo) is None:
                      if re.search(regex_titulo_convenio, titulo) is not None:
                        if 'termo aditivo ao con' not in section_3[orgao][documento][ato]['texto'].lower():
                          atos_contrato_convenio['numero_dodf'].append(file['json']['nu_numero'])
                          atos_contrato_convenio['titulo'].append(titulo)
      Severity: Major
      Found in dodfminer/extract/polished/acts/contrato_convenio.py - About 45 mins to fix

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

            def read_json(self, file_name):
                """Reads a .json file of a DODF.
        
                A single string with all the relevant text from the act section is extracted.
                """
        Severity: Minor
        Found in dodfminer/extract/polished/acts/base.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 re.search(regex_titulo_aditivo, titulo) is not None:
                        atos_aditamento['numero_dodf'].append(file['json']['nu_numero'])
                        atos_aditamento['titulo'].append(titulo)
                        atos_aditamento['texto'].append(re.sub(r'<[^>]*>', '', titulo + " " + section_3[orgao][documento][ato]['texto']))
                      elif titulo in titulos_termo_aditivo:
        Severity: Major
        Found in dodfminer/extract/polished/acts/aditamento.py - About 45 mins to fix

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

              def _limits(self, sentence):
                  """Find the limits of words in the sentence.
          
                  Args:
                      sentence (str): target sentence.
          Severity: Minor
          Found in dodfminer/extract/polished/backend/seg.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