gunthercox/ChatterBot

View on GitHub

Showing 42 of 296 total issues

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

    def download(self, url, show_status=True):
        """
        Download a file from the given url.
        Show a progress indicator for the download status.
        Based on: http://stackoverflow.com/a/15645088/1547223
Severity: Minor
Found in chatterbot/trainers.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 get_latest_response has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def get_latest_response(self, conversation):
        """
        Returns the latest response in a conversation if it exists.
        Returns None if a matching conversation cannot be found.
        """
Severity: Minor
Found in chatterbot/chatterbot.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 process has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def process(self, statement, additional_response_selection_parameters=None):
        response = Statement(text='')
        input_text = statement.text
        try:
            # Use the result cached by the process method if it exists
Severity: Minor
Found in chatterbot/logic/unit_conversion.py - About 45 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

Avoid deeply nested control flow statements.
Open

                        if len(row) > 0:
                            statement = Statement(
                                text=row[3],
                                in_response_to=previous_statement_text,
                                conversation='training',
Severity: Major
Found in chatterbot/trainers.py - About 45 mins to fix

    Function date_from_duration has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def date_from_duration(base_date, number_as_string, unit, duration, base_time=None):
    Severity: Minor
    Found in chatterbot/parsing.py - About 35 mins to fix

      Function get_recent_repeated_responses has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def get_recent_repeated_responses(chatbot, conversation, sample=10, threshold=3, quantity=3):
      Severity: Minor
      Found in chatterbot/filters.py - About 35 mins to fix

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

        def datetime_parsing(text, base_date=datetime.now()):
            """
            Extract datetime objects from a string of text.
            """
            matches = []
        Severity: Minor
        Found in chatterbot/parsing.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 create has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def create(self, **kwargs):
                """
                Creates a new statement matching the keyword arguments specified.
                Returns the created statement.
                """
        Severity: Minor
        Found in chatterbot/storage/sql_storage.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

        Avoid too many return statements within this function.
        Open

                    return datetime(relative_date.year, relative_date.month, relative_date.day, 23, 59, 59)
        Severity: Major
        Found in chatterbot/parsing.py - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                      return datetime(relative_date.year, relative_date.month - 1, relative_date.day)
          Severity: Major
          Found in chatterbot/parsing.py - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                            return datetime(year, month, day)
            Severity: Major
            Found in chatterbot/parsing.py - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                          return relative_date + timedelta(weeks=ord)
              Severity: Major
              Found in chatterbot/parsing.py - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                            return relative_date - timedelta(days=relative_date.weekday())
                Severity: Major
                Found in chatterbot/parsing.py - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                              return day_of_week + timedelta(days=6 - relative_date.weekday())
                  Severity: Major
                  Found in chatterbot/parsing.py - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                                return relative_date
                    Severity: Major
                    Found in chatterbot/parsing.py - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                                  return relative_date - timedelta(weeks=1)
                      Severity: Major
                      Found in chatterbot/parsing.py - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                    return relative_date + timedelta(days=ord)
                        Severity: Major
                        Found in chatterbot/parsing.py - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                                          return datetime(relative_date.year, relative_date.month + ord, relative_date.day)
                          Severity: Major
                          Found in chatterbot/parsing.py - About 30 mins to fix

                            Avoid too many return statements within this function.
                            Open

                                        return relative_date - timedelta(days=1)
                            Severity: Major
                            Found in chatterbot/parsing.py - About 30 mins to fix

                              Avoid too many return statements within this function.
                              Open

                                          return datetime(relative_date.year, relative_date.month, relative_date.day)
                              Severity: Major
                              Found in chatterbot/parsing.py - About 30 mins to fix
                                Severity
                                Category
                                Status
                                Source
                                Language