Showing 57 of 274 total issues
Function __init__
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
def __init__(self, *args, **kwargs):
"""
Constructor method that will complete the tests and display the
results.
"""
Function complete_tests
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
def complete_tests(self):
"""
This function will perform the above tests, and set the appropriate
variables with test information.
"""
Function compare_strings
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def compare_strings(self, **kwargs):
"""
This method is called by the main regex4dummies class, and calls all
further methods find patterns within strings.
"""
- 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 gather_important_information
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def gather_important_information(self, text):
"""
Returns the most important information within a text
based on its topics.
"""
- 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 extract_verb_phrases
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def extract_verb_phrases(self, **kwargs):
"""
Returns the verb phrases found within
a text.
"""
- 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_previous_instance
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def find_previous_instance(self, instance_to_find, string_containing_instance, current_index, objects_to_fail, updated_object):
is_word_found = "False"
for index in xrange(current_index - 1, 0, -1):
for fail in objects_to_fail:
- 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 run_tests
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def run_tests(self, tool_tester):
"""
Runs tests, then returns
"""
Function average_tokenize
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def average_tokenize(self, string_to_tokenize):
"""
Returns the averaged tokenization of the string
"""
- 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 add_to_updated_object == "True":
updated_object = new_object + tagged_sentence[index][0]
else:
updated_object = new_object
Avoid deeply nested control flow statements. Open
if index != 0:
temporary_phrase = ""
for phrase_index in range(index, prep_index + 1):
temporary_phrase += " " + tagged_sentence[phrase_index][0]
Avoid deeply nested control flow statements. Open
if ' '.join(pattern) in str(test_string) and pattern != '' and pattern != []:
if ' '.join(pattern) not in patterns and ' '.join(pattern) not in test_sentence_info:
test_sentence_info += [str(' '.join(pattern))]
sentence_information[str(' '.join(pattern))] = ['', '', '', [], 2, 0]
Avoid deeply nested control flow statements. Open
if len(base_sentence[len(base_sentence) - 1].split()) > len(test_sentence[len(test_sentence) - 1].split()):
# If other patterns have been detected
if patterns != []:
sentence_information[base_sentence[len(base_sentence) - 1]] = base_sentence[: len(base_sentence) - 1]
sentence_information[base_sentence[len(base_sentence) - 1]].append(2)
Avoid deeply nested control flow statements. Open
if len(base_sentence[len(base_sentence) - 1].split()) > len(test_sentence[len(test_sentence) - 1].split()):
# If other patterns have been detected
if patterns != []:
sentence_information[base_sentence[len(base_sentence) - 1]] = base_sentence[: len(base_sentence) - 1]
sentence_information[base_sentence[len(base_sentence) - 1]].append(2)
Avoid deeply nested control flow statements. Open
if len(base_sentence[len(base_sentence) - 1].split()) > len(test_sentence[len(test_sentence) - 1].split()):
# If other patterns have been detected
if patterns != []:
sentence_information[base_sentence[len(base_sentence) - 1]] = base_sentence[: len(base_sentence) - 1]
sentence_information[base_sentence[len(base_sentence) - 1]].append(2)
Avoid deeply nested control flow statements. Open
if base_pattern_subject == test_pattern_subject and base_pattern_verb == test_pattern_verb and base_pattern_object == test_pattern_object:
# If the patterns are the same, add the patterns to the identified patterns
# If the base_pattern is more descriptive, add that to the pattern information
if len(base_pattern.split(' ')) > len(test_pattern.split(' ')):
pattern_information[base_pattern.lower()] = [base_pattern_subject, base_pattern_verb, base_pattern_object, base_pattern_prepositional_phrases, 2, 0]
Avoid deeply nested control flow statements. Open
for compound_index in range(index + 1, len(tagged_sentence)):
if "NN" in tagged_sentence[compound_index][1] or "PRP" in tagged_sentence[compound_index][1]:
compound_object += " " + tagged_sentence[index + 1][0] + " " + tagged_sentence[compound_index][0]
break
Avoid deeply nested control flow statements. Open
if index != 0:
updated_subject = ' '.join(sentence_raw.split()[0 : index]) + ' '.join(sentence_raw.split()[prep_index + 1 : len(sentence_raw.split())])
updated_tag = sentence_tagged[0 : index] + sentence_tagged[prep_index + 1 : len(sentence_tagged)]
else:
updated_subject = ' '.join(sentence_raw.split()[prep_index + 1 : len(sentence_raw.split())])
Avoid deeply nested control flow statements. Open
if index != 0:
updated_object = ' '.join(raw_sentence.split()[0 : index]) + ' '.join(raw_sentence.split()[prep_index + 1 : len(raw_sentence.split())])
updated_tag = tagged_sentence[0 : index] + tagged_sentence[prep_index + 1 : len(tagged_sentence)]
else:
updated_object = ' '.join(raw_sentence.split()[prep_index + 1 : len(raw_sentence.split())])
Avoid deeply nested control flow statements. Open
if ' '.join(pattern) not in patterns and ' '.join(pattern) not in base_sentence_info:
test_sentence_info += [str(' '.join(pattern))]
sentence_information[str(' '.join(pattern))] = ['', '', '', [], 2, 0]
else:
Avoid deeply nested control flow statements. Open
if updated_object == "":
updated_object = compound_object + ", "
else:
add_to_updated_object, new_object = self.find_previous_instance(["NN", "PRP"], full_tagged_sentence, len(full_tagged_sentence) - (len(tagged_sentence) - index), ["VB"], updated_object + compound_object)