IlyaGusev/PoetryCorpus

View on GitHub

Showing 35 of 90 total issues

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

                    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

                    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

                    Function to_sketch has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def to_sketch(self, filename, fields):
                            with open(filename, 'w', encoding='utf-8') as f:
                                content = '<?xml version="1.0" encoding="UTF-8"?><items>'
                                for element in self.data:
                                    xml = '<doc '
                    Severity: Minor
                    Found in poetry/apps/corpus/scripts/unite.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 get_accents has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                    def get_accents(markup: Markup):
                        accents = []
                        for line in markup.lines:
                            for word in line.words:
                                for syllable in word.syllables:
                    Severity: Minor
                    Found in poetry/apps/corpus/views/comparison_view.py - About 25 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