Showing 67 of 67 total issues
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'):
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.
- Read upRead up
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)
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.
"""
- Read upRead up
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:
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.
- Read upRead up
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 is_json:
list_of_boxes.append((text[0], text[1], text[2],
text[3], norm_text))
else:
drawboxes_text += (norm_text + sep)
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.
- Read upRead up
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 offset_sum != -1:
offset_prop = offset + offset_sum
child_annotation = self._annotate(prop_type,
value, offset_prop)
root_passage.append(child_annotation)
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)
Avoid deeply nested control flow statements. Open
if cand.label_ == 'PER':
break
Avoid deeply nested control flow statements. Open
if section and (title not in content_dict[section].keys()):
content_dict[section].update(
{normalized_title: []})
else:
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,
- Read upRead up
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
for IOB, text, _, titulo in zip(self.predicted, self.atos_encontrados['texto'], self.atos_encontrados['numero_dodf'], self.atos_encontrados['titulo']):
- Read upRead up
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 34.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Identical blocks of code found in 2 locations. Consider refactoring. Open
for IOB, text, numdodf, titulo in zip(self.predicted, self.atos_encontrados['texto'], self.atos_encontrados['numero_dodf'], self.atos_encontrados['titulo']):
- Read upRead up
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 34.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Function __init__
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self, file, backend, debug=False, extra_search=True, pipeline = None):
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"):
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
- Read upRead up
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
- Read upRead up
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.
- Read upRead up
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"