UnB-KnEDLe/DODFMiner

View on GitHub

Showing 59 of 67 total issues

Avoid deeply nested control flow statements.
Open

              if re.search(r'(?:ADITIVO)', titulo) is None:
                if re.search(regex_titulo_contrato, titulo) is not None:
                  if 'termo aditivo ao contrato' 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

    Avoid deeply nested control flow statements.
    Open

                            if cand.label_ == 'PER':
                                break
    
    
    Severity: Major
    Found in dodfminer/extract/polished/acts/sem_efeito_aposentadoria.py - About 45 mins to fix

      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 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 section and (title not in content_dict[section].keys()):
                                    content_dict[section].update(
                                        {normalized_title: []})
                            else:
        Severity: Major
        Found in dodfminer/extract/pure/core.py - About 45 mins to fix

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

              def _extract_acts(self, text, prediction):
                  """Extract and join words predicted to be part of an act.
          
                  Args:
                      text (list): List of words in the text of a DODF.
          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

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

          def extract_multiple(files, act_type, backend, txt_out=False, txt_path="./results"):
              """Extract Act from Multiple DODF to a single DataFrame.
          
              Note:
                  This function might save data to disc in text format,
          Severity: Minor
          Found in dodfminer/extract/polished/helper.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 extract_multiple has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          def extract_multiple(files, act_type, backend, txt_out=False, txt_path="./results"):
          Severity: Minor
          Found in dodfminer/extract/polished/helper.py - About 35 mins to fix

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

                def __init__(self, file, backend, debug=False, extra_search=True, pipeline = None):
            Severity: Minor
            Found in dodfminer/extract/polished/acts/cessoes.py - About 35 mins to fix

              Function _standard_props has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  def _standard_props(self):
                      act = {}
              
                      file = self._file_name.split('/')[-1] if self._file_name else None
                      match = re.search(r'(\d+\-\d+\-\d+)',file) if file else None
              Severity: Minor
              Found in dodfminer/extract/polished/acts/base.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

              Function _find_prop_value has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  def _find_prop_value(self, rule, act):
                      """Returns named group, or the whole match if no named groups
                              are present on the match.
                      Args:
                          match: a re.Match object
              Severity: Minor
              Found in dodfminer/extract/polished/acts/cessoes.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

              Function get_downloads has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

              def get_downloads(year, month):
                  if "_" in month:
                      url2, dodfs = req2(req1(year), month)
                      _links = {}
              
              
              Severity: Minor
              Found in dodfminer/downloader/helper.py - About 25 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 _extract_page_lines_content has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

              def _extract_page_lines_content(page):
                  """Extracts page lines.
              
                  Args:
                      page: fitz.fitz.Page object to have its bold content extracted.
              Severity: Minor
              Found in dodfminer/extract/pure/utils/box_extractor.py - About 25 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 load has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                def load(self):
                  # Load model
                  if self.pipeline is None:
                    f_path = os.path.dirname(__file__)
                    f_path += self.model_path
              Severity: Minor
              Found in dodfminer/extract/polished/acts/base_contratos.py - About 25 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 get_files_path has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

              def get_files_path(path, file_type):
                  """Get all files path inside a folder.
              
                  Works with nested folders.
              
              
              Severity: Minor
              Found in dodfminer/extract/polished/helper.py - About 25 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 committee_classification has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

              def committee_classification(all_acts, path, types, backend):
                  """Uses committee classification to find act types.
              
                  Args:
                      all_acts (DataFrame): Dataframe with acts text and regex type.
              Severity: Minor
              Found in dodfminer/extract/polished/helper.py - About 25 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 _get_pdfs_list has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  def _get_pdfs_list(cls, folder):
                      """Get DODFs list from the path.
              
                      Args:
                          folder: The folder containing the PDFs to be extracted.
              Severity: Minor
              Found in dodfminer/extract/pure/core.py - About 25 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 xml_multiple has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

              def xml_multiple(path, backend):
                  files = []
                  if os.path.isfile(path):
                      files = [path]
                      path_ = './'
              Severity: Minor
              Found in dodfminer/extract/polished/helper.py - About 25 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 extract_to_txt has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  def extract_to_txt(cls, folder='./', norm='NFKD'):
                      """Extract information from DODF to a .txt file.
              
                      For each PDF file in data/DODFs, the method extracts information from the
                      PDF and writes it to the .txt file.
              Severity: Minor
              Found in dodfminer/extract/pure/core.py - About 25 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