IlyaGusev/PoetryCorpus

View on GitHub

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 == "Ј":
Severity: Major
Found in poetry/apps/corpus/scripts/stihi.py - About 45 mins to fix

    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):
    Severity: Major
    Found in poetry/apps/corpus/management/commands/from_treeton.py - About 45 mins to fix

      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']):
      Severity: Major
      Found in poetry/apps/corpus/scripts/unite.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                                if len(element['text']) > len(data[id]['text']):
                                    data[id]['text'] = element['text']
                                self.duplicates_count += 1
        Severity: Major
        Found in poetry/apps/corpus/scripts/unite.py - About 45 mins to fix

          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:
          Severity: Major
          Found in poetry/apps/corpus/scripts/stihi.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                    for theme in element['themes']:
                                        data[id]['themes'].add(theme)
                            elif data[id]['text'] is None:
            Severity: Major
            Found in poetry/apps/corpus/scripts/unite.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                      if syllable.text[i] in VOWELS:
                                          syllable.stress = syllable.begin + i
              
              
              Severity: Major
              Found in poetry/apps/corpus/views/markup_view.py - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                        if name == "":
                                            continue
                                        print(name, author)
                Severity: Major
                Found in poetry/apps/corpus/management/commands/generate_from_raw.py - About 45 mins to fix

                  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:
                  Severity: Major
                  Found in poetry/apps/corpus/scripts/unite.py - About 45 mins to fix

                    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
                    Severity: Major
                    Found in poetry/apps/corpus/management/commands/from_treeton.py - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                              for l in t.split("\\n"):
                                                  if l != '':
                                                      l = l.replace("/", "").replace(":", "")
                                                      name = l[:50]
                                                      break
                      Severity: Major
                      Found in poetry/apps/corpus/management/commands/generate_from_raw.py - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                                if len(element['themes']) == 0:
                                                    theme_list = "[]"
                                                else:
                                                    theme_list = "["
                                                    for theme in element['themes']:
                        Severity: Major
                        Found in poetry/apps/corpus/scripts/unite.py - About 45 mins to fix

                          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):
                          Severity: Minor
                          Found in poetry/apps/accounts/models.py - About 35 mins to fix

                            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):
                            Severity: Minor
                            Found in poetry/apps/corpus/management/commands/generate_raw.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

                            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
                            Severity: Minor
                            Found in poetry/apps/corpus/scripts/unite.py and 2 other locations - About 35 mins to fix
                            poetry/apps/corpus/scripts/unite.py on lines 198..201
                            poetry/apps/corpus/scripts/unite.py on lines 203..206

                            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

                            Further Reading

                            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
                            Severity: Minor
                            Found in poetry/apps/corpus/scripts/unite.py and 2 other locations - About 35 mins to fix
                            poetry/apps/corpus/scripts/unite.py on lines 203..206
                            poetry/apps/corpus/scripts/unite.py on lines 208..211

                            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

                            Further Reading

                            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]
                            Severity: Minor
                            Found in poetry/apps/corpus/management/commands/get_manual.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 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++) {
                            Severity: Minor
                            Found in poetry/static/js/ajax.csrf.js - 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

                            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
                            Severity: Minor
                            Found in poetry/apps/corpus/management/commands/generate_markups.py and 1 other location - About 35 mins to fix
                            poetry/apps/corpus/management/commands/generate_markups.py on lines 65..65

                            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

                            Further Reading

                            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
                            
                            Severity: Minor
                            Found in poetry/apps/corpus/views/poem_view.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

                            Severity
                            Category
                            Status
                            Source
                            Language