gunthercox/ChatterBot

View on GitHub

Showing 42 of 296 total issues

File languages.py has 1612 lines of code (exceeds 250 allowed). Consider refactoring.
Open

class AAR:
    ISO_639_1 = ''
    ISO_639 = 'aar'
    ENGLISH_NAME = 'Afar'

Severity: Major
Found in chatterbot/languages.py - About 4 days to fix

    File parsing.py has 690 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import re
    from datetime import timedelta, datetime
    import calendar
    
    # Variations of dates that the parser can capture
    Severity: Major
    Found in chatterbot/parsing.py - About 1 day to fix

      File test_django_adapter.py has 367 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      from django.test import TestCase
      from chatterbot.storage import DjangoStorageAdapter
      from chatterbot.conversation import Statement as StatementObject
      from chatterbot.ext.django_chatterbot.models import Statement
      
      
      Severity: Minor
      Found in tests_django/test_django_adapter.py - About 4 hrs to fix

        Function filter has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
        Open

            def filter(self, **kwargs):
                """
                Returns a list of statements in the database
                that match the parameters specified.
                """
        Severity: Minor
        Found in chatterbot/storage/mongodb.py - About 4 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

        Function date_from_relative_week_year has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
        Open

        def date_from_relative_week_year(base_date, time, dow, ordinal=1):
            """
            Converts relative day to time
            Eg. this tuesday, last tuesday
            """
        Severity: Minor
        Found in chatterbot/parsing.py - About 4 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

        Function generate_response has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
        Open

            def generate_response(self, input_statement, additional_response_selection_parameters=None):
                """
                Return a response based on a given input statement.
        
                :param input_statement: The input statement to be processed.
        Severity: Minor
        Found in chatterbot/chatterbot.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

        ChatBotTests has 28 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class ChatBotTests(ChatterBotTestCase):
        
            def test_get_response_text(self):
                self.chatbot.get_response(text='Test')
        
        
        Severity: Minor
        Found in tests_django/test_chatbot.py - About 3 hrs to fix

          Function train has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
          Open

              def train(self):
                  import glob
          
                  tagger = PosLemmaTagger(language=self.chatbot.storage.tagger.language)
          
          
          Severity: Minor
          Found in chatterbot/trainers.py - About 2 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

          File sql_storage.py has 265 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          from chatterbot.storage import StorageAdapter
          
          
          class SQLStorageAdapter(StorageAdapter):
              """
          Severity: Minor
          Found in chatterbot/storage/sql_storage.py - About 2 hrs to fix

            Function create_many has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
            Open

                def create_many(self, statements):
                    """
                    Creates multiple statement entries.
                    """
                    Statement = self.get_model('statement')
            Severity: Minor
            Found in chatterbot/storage/sql_storage.py - About 2 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

            File trainers.py has 255 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            import os
            import sys
            import csv
            import time
            from dateutil import parser as date_parser
            Severity: Minor
            Found in chatterbot/trainers.py - About 2 hrs to fix

              Function get_response has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
              Open

                  def get_response(self, statement=None, **kwargs):
                      """
                      Return the bot's response based on the input.
              
                      :param statement: An statement object or string.
              Severity: Minor
              Found in chatterbot/chatterbot.py - About 2 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

              Function filter has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
              Open

                  def filter(self, **kwargs):
                      """
                      Returns a list of objects from the database.
                      The kwargs parameter can contain any number
                      of attributes. Only objects which contain all
              Severity: Minor
              Found in chatterbot/storage/sql_storage.py - About 1 hr 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 update has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
              Open

                  def update(self, statement):
                      """
                      Modifies an entry in the database.
                      Creates an entry if one does not exist.
                      """
              Severity: Minor
              Found in chatterbot/storage/sql_storage.py - About 1 hr 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_many has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
              Open

                  def create_many(self, statements):
                      """
                      Creates multiple statement entries.
                      """
                      Statement = self.get_model('statement')
              Severity: Minor
              Found in chatterbot/storage/django_storage.py - About 1 hr 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 date_from_duration has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
              Open

              def date_from_duration(base_date, number_as_string, unit, duration, base_time=None):
                  """
                  Find dates from duration
                  Eg: 20 days from now
                  Currently does not support strings like "20 days from last monday".
              Severity: Minor
              Found in chatterbot/parsing.py - About 1 hr 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 train has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
              Open

                  def train(self, *corpus_paths):
                      from chatterbot.corpus import load_corpus, list_corpus_files
              
                      data_file_paths = []
              
              
              Severity: Minor
              Found in chatterbot/trainers.py - About 1 hr 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_text_index_string has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

                  def get_text_index_string(self, text):
                      """
                      Return a string of text containing part-of-speech, lemma pairs.
                      """
                      bigram_pairs = []
              Severity: Minor
              Found in chatterbot/tagging.py - About 1 hr 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 filter has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                  def filter(self, **kwargs):
                      """
                      Returns a list of statements in the database
                      that match the parameters specified.
                      """
              Severity: Minor
              Found in chatterbot/storage/django_storage.py - About 1 hr 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 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  def process(self, input_statement, additional_response_selection_parameters=None):
                      search_results = self.search_algorithm.search(input_statement)
              
                      # Use the input statement as the closest match if no other results are found
                      closest_match = next(search_results, input_statement)
              Severity: Minor
              Found in chatterbot/logic/best_match.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

              Severity
              Category
              Status
              Source
              Language