Showing 35 of 90 total issues
Function clean_duplicates
has a Cognitive Complexity of 60 (exceeds 5 allowed). Consider refactoring. Open
def clean_duplicates(self):
data = dict()
for element in self.data:
id = self.generate_id(element)
if data.get(id) is 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 run
has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring. Open
def run(stress_model_path, g2p_model_path, grapheme_set, g2p_dict_path, aligner_dump_path, raw_stress_dict_path,
stress_trie_path, zalyzniak_dict, ru_wiki_dict, cmu_dict):
raw_writer = Writer(FileType.RAW, MARKUPS_DUMP_RAW_PATH)
raw_writer.open()
i = 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 handle
has a Cognitive Complexity of 32 (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")
Markup.objects.filter(markup=MarkupVersion.objects.get(pk=3)).delete()
for i, poem in enumerate(poems):
- 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 handle
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
def handle(self, *args, **options):
engine = Engine(language="ru")
poems = Poem.objects.all()
begin = int(options.get('from'))
end = int(options.get('to')) if options.get('to') is not None else len(poems)
- 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 check_field
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
function check_field(event) {
var error = '';
if (event.data == 'first_name'){
if (!(/^^[А-ЯЁA-Z][а-яёa-z]+$/.test($('#id_first_name').val()))) error += 'Должно начинается с большой буквы';
}
- 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 handle
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
def handle(self, *args, **options):
dir = options.get('dir')
output = options.get('out')
print(dir, output)
with open(output, "w", encoding='utf-8') as f:
- 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 post
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
def post(self, request, *args, **kwargs):
if request.user.is_authenticated():
diffs = request.POST.getlist('diffs[]')
m = self.get_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 to_django
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def to_django(self, filename, themes_filename, fields):
themes_to_pk = dict()
with open(themes_filename, 'w', encoding='utf-8') as f:
themes = list(set(list(itertools.chain.from_iterable([element['themes'] for element in self.data]))))
pk = 1
- 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_paths
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def get_paths(path: str, ext: str):
"""
Получение всех файлов заданного типа по заданному пути.
:param path: путь к файлу/папке.
- 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 main
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def main():
corpus = Corpus()
text_files = [os.path.join(BASE_DIR, "datasets", "web", "rupoem.xml"), os.path.join(BASE_DIR, "datasets", "web", "strofa.xml"),
os.path.join(BASE_DIR, "datasets", "web", "klassika.xml"),]
themes_files = [os.path.join(BASE_DIR, "datasets", "web", "themes.xml")]
- 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 process_file
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def process_file(self, file_name, item_node_name, fields):
tree = etree.parse(file_name)
root = tree.getroot()
for item in root.findall(item_node_name):
element = dict()
- 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
has 10 arguments (exceeds 4 allowed). Consider refactoring. Open
def run(stress_model_path, g2p_model_path, grapheme_set, g2p_dict_path, aligner_dump_path, raw_stress_dict_path,
Function process_markup
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def process_markup(markup):
text = markup.text
output = []
prev = 0
for l in range(len(markup.lines)):
- 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 check_field
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
function check_field(event) {
var error = '';
if (event.data == 'first_name'){
if (!(/^^[А-ЯЁA-Z][а-яёa-z]+$/.test($('#id_first_name').val()))) error += 'Должно начинается с большой буквы';
}
Function post_poem
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
function post_poem(dict){
var reload = false;
for (var key in dict) {
if (($.inArray(key, ajax_fields)) === -1) {
reload = true;
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
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['themes']) == 0:
theme_list = "[]"
else:
theme_list = "["
for theme in element['themes']:
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 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