Mithil467/mitype

View on GitHub
mitype/app.py

Summary

Maintainability
B
6 hrs
Test Coverage

File app.py has 468 lines of code (exceeds 250 allowed). Consider refactoring.
Invalid

"""This is the Mitype main app script."""

import curses
import os
import sys
Severity: Minor
Found in mitype/app.py - About 7 hrs to fix

    Function main has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

        def main(self, win):
            """Respond to user inputs.
    
            This is where the infinite loop is executed to continuously serve events.
    
    
    Severity: Minor
    Found in mitype/app.py - About 3 hrs 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

    App has 23 functions (exceeds 20 allowed). Consider refactoring.
    Invalid

    class App:
        """Class for enclosing all methods required to run Mitype."""
    
        def __init__(self):
            """Initialize the application class."""
    Severity: Minor
    Found in mitype/app.py - About 2 hrs to fix

      Function __init__ has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def __init__(self):
              """Initialize the application class."""
              # Start the parser
              self.text, self.text_id = resolve_commandline_arguments()
              self.tokens = self.text.split()
      Severity: Minor
      Found in mitype/app.py - About 1 hr to fix

        Function key_printer has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def key_printer(self, win, key):
                """Print required key to terminal.
        
                Args:
                    win (any): Curses window object.
        Severity: Minor
        Found in mitype/app.py - About 55 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 keyinput has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def keyinput(win):
                """Retrieve next character of text input.
        
                Args:
                    win (any): Curses window.
        Severity: Minor
        Found in mitype/app.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

        Refactor this function to reduce its Cognitive Complexity from 25 to the 15 allowed.
        Open

            def main(self, win):
        Severity: Critical
        Found in mitype/app.py by sonar-python

        Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.

        See

        Line too long (80 > 79 characters)
        Open

                    win.addstr(self.number_of_lines_to_print_text, 0, self.current_word)
        Severity: Minor
        Found in mitype/app.py by pep8

        Limit all lines to a maximum of 79 characters.

        There are still many devices around that are limited to 80 character
        lines; plus, limiting windows to 80 characters makes it possible to
        have several windows side-by-side.  The default wrapping on such
        devices looks ugly.  Therefore, please limit all lines to a maximum
        of 79 characters. For flowing long blocks of text (docstrings or
        comments), limiting the length to 72 characters is recommended.
        
        Reports error E501.

        Whitespace before ':'
        Open

                    self.text[index : len(self.current_string)],
        Severity: Minor
        Found in mitype/app.py by pep8

        Avoid extraneous whitespace.

        Avoid extraneous whitespace in these situations:
        - Immediately inside parentheses, brackets or braces.
        - Immediately before a comma, semicolon, or colon.
        
        Okay: spam(ham[1], {eggs: 2})
        E201: spam( ham[1], {eggs: 2})
        E201: spam(ham[ 1], {eggs: 2})
        E201: spam(ham[1], { eggs: 2})
        E202: spam(ham[1], {eggs: 2} )
        E202: spam(ham[1 ], {eggs: 2})
        E202: spam(ham[1], {eggs: 2 })
        
        E203: if x == 4: print x, y; x, y = y , x
        E203: if x == 4: print x, y ; x, y = y, x
        E203: if x == 4 : print x, y; x, y = y, x

        Line too long (82 > 79 characters)
        Open

                    # The key_strokes list is storing the time at which the key is pressed
        Severity: Minor
        Found in mitype/app.py by pep8

        Limit all lines to a maximum of 79 characters.

        There are still many devices around that are limited to 80 character
        lines; plus, limiting windows to 80 characters makes it possible to
        have several windows side-by-side.  The default wrapping on such
        devices looks ugly.  Therefore, please limit all lines to a maximum
        of 79 characters. For flowing long blocks of text (docstrings or
        comments), limiting the length to 72 characters is recommended.
        
        Reports error E501.

        Whitespace before ':'
        Open

                win.addstr(2, 0, self.text[0 : len(self.current_string)], curses.A_DIM)
        Severity: Minor
        Found in mitype/app.py by pep8

        Avoid extraneous whitespace.

        Avoid extraneous whitespace in these situations:
        - Immediately inside parentheses, brackets or braces.
        - Immediately before a comma, semicolon, or colon.
        
        Okay: spam(ham[1], {eggs: 2})
        E201: spam( ham[1], {eggs: 2})
        E201: spam(ham[ 1], {eggs: 2})
        E201: spam(ham[1], { eggs: 2})
        E202: spam(ham[1], {eggs: 2} )
        E202: spam(ham[1 ], {eggs: 2})
        E202: spam(ham[1], {eggs: 2 })
        
        E203: if x == 4: print x, y; x, y = y , x
        E203: if x == 4: print x, y ; x, y = y, x
        E203: if x == 4 : print x, y; x, y = y, x

        Line too long (81 > 79 characters)
        Open

                    self.accuracy = accuracy(self.total_chars_typed, wrongly_typed_chars)
        Severity: Minor
        Found in mitype/app.py by pep8

        Limit all lines to a maximum of 79 characters.

        There are still many devices around that are limited to 80 character
        lines; plus, limiting windows to 80 characters makes it possible to
        have several windows side-by-side.  The default wrapping on such
        devices looks ugly.  Therefore, please limit all lines to a maximum
        of 79 characters. For flowing long blocks of text (docstrings or
        comments), limiting the length to 72 characters is recommended.
        
        Reports error E501.

        Line too long (87 > 79 characters)
        Open

                    self.time_taken = get_elapsed_minutes_since_first_keypress(self.start_time)
        Severity: Minor
        Found in mitype/app.py by pep8

        Limit all lines to a maximum of 79 characters.

        There are still many devices around that are limited to 80 character
        lines; plus, limiting windows to 80 characters makes it possible to
        have several windows side-by-side.  The default wrapping on such
        devices looks ugly.  Therefore, please limit all lines to a maximum
        of 79 characters. For flowing long blocks of text (docstrings or
        comments), limiting the length to 72 characters is recommended.
        
        Reports error E501.

        Line too long (80 > 79 characters)
        Open

        from mitype.commandline import load_from_database, resolve_commandline_arguments
        Severity: Minor
        Found in mitype/app.py by pep8

        Limit all lines to a maximum of 79 characters.

        There are still many devices around that are limited to 80 character
        lines; plus, limiting windows to 80 characters makes it possible to
        have several windows side-by-side.  The default wrapping on such
        devices looks ugly.  Therefore, please limit all lines to a maximum
        of 79 characters. For flowing long blocks of text (docstrings or
        comments), limiting the length to 72 characters is recommended.
        
        Reports error E501.

        Line too long (81 > 79 characters)
        Open

                This is where the infinite loop is executed to continuously serve events.
        Severity: Minor
        Found in mitype/app.py by pep8

        Limit all lines to a maximum of 79 characters.

        There are still many devices around that are limited to 80 character
        lines; plus, limiting windows to 80 characters makes it possible to
        have several windows side-by-side.  The default wrapping on such
        devices looks ugly.  Therefore, please limit all lines to a maximum
        of 79 characters. For flowing long blocks of text (docstrings or
        comments), limiting the length to 72 characters is recommended.
        
        Reports error E501.

        Line too long (83 > 79 characters)
        Open

                win.addstr(self.number_of_lines_to_print_text, 0, " Your typing speed is ")
        Severity: Minor
        Found in mitype/app.py by pep8

        Limit all lines to a maximum of 79 characters.

        There are still many devices around that are limited to 80 character
        lines; plus, limiting windows to 80 characters makes it possible to
        have several windows side-by-side.  The default wrapping on such
        devices looks ugly.  Therefore, please limit all lines to a maximum
        of 79 characters. For flowing long blocks of text (docstrings or
        comments), limiting the length to 72 characters is recommended.
        
        Reports error E501.

        Line too long (86 > 79 characters)
        Open

                    save_history(self.text_id, self.current_speed_wpm, f"{self.accuracy:.2f}")
        Severity: Minor
        Found in mitype/app.py by pep8

        Limit all lines to a maximum of 79 characters.

        There are still many devices around that are limited to 80 character
        lines; plus, limiting windows to 80 characters makes it possible to
        have several windows side-by-side.  The default wrapping on such
        devices looks ugly.  Therefore, please limit all lines to a maximum
        of 79 characters. For flowing long blocks of text (docstrings or
        comments), limiting the length to 72 characters is recommended.
        
        Reports error E501.

        Line too long (86 > 79 characters)
        Open

                win.addstr(self.number_of_lines_to_print_text + 2, 0, " " * self.window_width)
        Severity: Minor
        Found in mitype/app.py by pep8

        Limit all lines to a maximum of 79 characters.

        There are still many devices around that are limited to 80 character
        lines; plus, limiting windows to 80 characters makes it possible to
        have several windows side-by-side.  The default wrapping on such
        devices looks ugly.  Therefore, please limit all lines to a maximum
        of 79 characters. For flowing long blocks of text (docstrings or
        comments), limiting the length to 72 characters is recommended.
        
        Reports error E501.

        Line too long (81 > 79 characters)
        Open

                spc = get_space_count_after_ith_word(len(self.current_string), self.text)
        Severity: Minor
        Found in mitype/app.py by pep8

        Limit all lines to a maximum of 79 characters.

        There are still many devices around that are limited to 80 character
        lines; plus, limiting windows to 80 characters makes it possible to
        have several windows side-by-side.  The default wrapping on such
        devices looks ugly.  Therefore, please limit all lines to a maximum
        of 79 characters. For flowing long blocks of text (docstrings or
        comments), limiting the length to 72 characters is recommended.
        
        Reports error E501.

        Line too long (83 > 79 characters)
        Open

                    number_of_lines_to_fit_text_in_window(self.text, self.window_width) + 3
        Severity: Minor
        Found in mitype/app.py by pep8

        Limit all lines to a maximum of 79 characters.

        There are still many devices around that are limited to 80 character
        lines; plus, limiting windows to 80 characters makes it possible to
        have several windows side-by-side.  The default wrapping on such
        devices looks ugly.  Therefore, please limit all lines to a maximum
        of 79 characters. For flowing long blocks of text (docstrings or
        comments), limiting the length to 72 characters is recommended.
        
        Reports error E501.

        Line too long (83 > 79 characters)
        Open

                index = first_index_at_which_strings_differ(self.current_string, self.text)
        Severity: Minor
        Found in mitype/app.py by pep8

        Limit all lines to a maximum of 79 characters.

        There are still many devices around that are limited to 80 character
        lines; plus, limiting windows to 80 characters makes it possible to
        have several windows side-by-side.  The default wrapping on such
        devices looks ugly.  Therefore, please limit all lines to a maximum
        of 79 characters. For flowing long blocks of text (docstrings or
        comments), limiting the length to 72 characters is recommended.
        
        Reports error E501.

        There are no issues that match your filters.

        Category
        Status