Showing 90 of 90 total issues
Avoid deeply nested control flow statements. Open
for line in lines:
if line == "":
continue
for ch in line:
if "a" < ch < "z" or "A" < ch < "Z" or ch == "Ј":
Avoid deeply nested control flow statements. Open
if len(stress_lines[line_number]) != syllable_count:
stress_lines[line_number] += "".join(["U" for _ in range(syllable_count-len(stress_lines[line_number]))])
for line_number, line in enumerate(markup.lines):
Avoid deeply nested control flow statements. Open
for field, value in data[id].items():
if value is None:
data[id][field] = element[field]
if len(element['text']) > len(data[id]['text']):
Avoid deeply nested control flow statements. Open
if len(element['text']) > len(data[id]['text']):
data[id]['text'] = element['text']
self.duplicates_count += 1
Avoid deeply nested control flow statements. Open
if not skip:
print(clean_text.split("\n")[:2])
markup, result = engine.get_improved_markup(clean_text)
raw_writer.write_markup(markup)
else:
Avoid deeply nested control flow statements. Open
for theme in element['themes']:
data[id]['themes'].add(theme)
elif data[id]['text'] is None:
Avoid deeply nested control flow statements. Open
if syllable.text[i] in VOWELS:
syllable.stress = syllable.begin + i
Avoid deeply nested control flow statements. Open
if name == "":
continue
print(name, author)
Avoid deeply nested control flow statements. Open
for j in range(3):
flag1 = get_actual_line(element['text'], i) in get_actual_line(data[id]['text'], j)
flag2 = get_actual_line(data[id]['text'], i) in get_actual_line(element['text'], j)
is_duplicate = is_duplicate or flag1 or flag2
if not is_duplicate:
Avoid deeply nested control flow statements. Open
for word in line.words:
for k in range(len(word.syllables)):
letter = stress_lines[line_number][current_pos]
word.syllables[k].stress = word.syllables[k].vowel() if letter.lower() == "s" else -1
current_pos += 1
Avoid deeply nested control flow statements. Open
for l in t.split("\\n"):
if l != '':
l = l.replace("/", "").replace(":", "")
name = l[:50]
break
Avoid deeply nested control flow statements. Open
if len(element['themes']) == 0:
theme_list = "[]"
else:
theme_list = "["
for theme in element['themes']:
Function create_user
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def create_user(self, email, organisation, password=None, first_name=None, last_name=None):
Function handle
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def handle(self, *args, **options):
poems = Poem.objects.all()
directory = os.path.join(BASE_DIR, "datasets", "corpus", "all_raw")
if os.path.exists(directory):
for path in os.listdir(directory):
- 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
Similar blocks of code found in 3 locations. Consider refactoring. Open
'date_to': {
'path': './/date_to',
'handler': lambda x: x if x is None else int(x.text),
'required': False
- 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 33.
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
Similar blocks of code found in 3 locations. Consider refactoring. Open
'text': {
'path': './/text',
'handler': lambda x: x if x is None else clean_text(x.text),
'required': True
- 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 33.
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 handle
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def handle(self, *args, **options):
output = options.get('out')
with open(output, "w", encoding='utf-8') as f:
content = '['
poems = [poem for poem in Poem.objects.all() if poem.count_manual_markups() != 0]
- 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 getCookie
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
function getCookie(name) {
var cookieValue = null;
if (document.cookie && document.cookie != '') {
var cookies = document.cookie.split(';');
for (var i = 0; i < cookies.length; i++) {
- 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
Similar blocks of code found in 2 locations. Consider refactoring. Open
xml_path = str(options.get('xml')) if options.get('xml') is not None else None
- 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 33.
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 get_context_data
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def get_context_data(self, **kwargs):
context = super(PoemView, self).get_context_data(**kwargs)
poem = self.get_object()
max_pk = Poem.objects.latest('pk').pk
- 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"