SylvainDe/DidYouMean-Python

View on GitHub

Showing 29 of 142 total issues

File didyoumean_sugg_tests.py has 2286 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8
"""Unit tests for get_suggestions_for_exception."""
from didyoumean_internal import get_suggestions_for_exception, quote, \
    STAND_MODULES, AVOID_REC_MSG, \
    APPLY_REMOVED_MSG, BUFFER_REMOVED_MSG, CMP_REMOVED_MSG, \
Severity: Major
Found in didyoumean/didyoumean_sugg_tests.py - About 6 days to fix

    File didyoumean_internal.py has 749 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    # -*- coding: utf-8
    """Logic to add suggestions to exceptions."""
    import keyword
    import difflib
    import didyoumean_re as re
    Severity: Major
    Found in didyoumean/didyoumean_internal.py - About 1 day to fix

      File didyoumean_re_tests.py has 735 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      # -*- coding: utf-8
      """Unit tests for regexps from didyoumean_re.py."""
      import didyoumean_re as re
      import sys
      from didyoumean_internal import get_subclasses
      Severity: Major
      Found in didyoumean/didyoumean_re_tests.py - About 1 day to fix

        RegexTests has 73 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class RegexTests(unittest_module.TestCase):
            """Tests to check that error messages match the regexps."""
        
            def assertRegexp(self, text, regex, msg=None):
                """Wrapper around the different names for assertRegexp...."""
        Severity: Major
        Found in didyoumean/didyoumean_re_tests.py - About 1 day to fix

          TypeErrorTests has 60 functions (exceeds 20 allowed). Consider refactoring.
          Open

          class TypeErrorTests(GetSuggestionsTests):
              """Class for tests related to TypeError."""
          
              def test_unhashable(self):
                  """Test for UNHASHABLE exception."""
          Severity: Major
          Found in didyoumean/didyoumean_sugg_tests.py - About 1 day to fix

            File didyoumean_internal_tests.py has 518 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            # -*- coding: utf-8
            """Unit tests for code in didyoumean_internal.py."""
            from didyoumean_internal import quote, get_suggestion_string,\
                add_string_to_exception, get_func_by_name,\
                get_objects_in_frame, get_subclasses, get_types_for_str,\
            Severity: Major
            Found in didyoumean/didyoumean_internal_tests.py - About 1 day to fix

              Function suggest_attribute_alternative has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
              Open

              def suggest_attribute_alternative(attribute, type_str, attributes):
                  """Suggest alternative to the non-found attribute."""
                  for s in suggest_attribute_synonyms(attribute, attributes):
                      yield s
                  is_iterable = '__iter__' in attributes or \
              Severity: Minor
              Found in didyoumean/didyoumean_internal.py - About 5 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

              NameErrorTests has 40 functions (exceeds 20 allowed). Consider refactoring.
              Open

              class NameErrorTests(GetSuggestionsTests):
                  """Class for tests related to NameError."""
              
                  aiter_sugg = []
                  try:
              Severity: Minor
              Found in didyoumean/didyoumean_sugg_tests.py - About 5 hrs to fix

                AttributeErrorTests has 29 functions (exceeds 20 allowed). Consider refactoring.
                Open

                class AttributeErrorTests(GetSuggestionsTests):
                    """Class for tests related to AttributeError."""
                
                    def test_nonetype(self):
                        """In-place methods like sort returns None.
                Severity: Minor
                Found in didyoumean/didyoumean_sugg_tests.py - About 3 hrs to fix

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

                  class SyntaxErrorTests(GetSuggestionsTests):
                      """Class for tests related to SyntaxError."""
                  
                      def test_no_error(self):
                          """No error."""
                  Severity: Minor
                  Found in didyoumean/didyoumean_sugg_tests.py - About 3 hrs to fix

                    Function test_attr_name has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def test_attr_name(self):
                            """Test ATTR_NAME."""
                            regex = r"^" + re.ATTR_NAME + r"$"
                            # Tests based on hardcoded values
                            attrs = ["do_stuff", "__magic__"]
                    Severity: Minor
                    Found in didyoumean/didyoumean_re_tests.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 add_string_to_exception has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                    Open

                    def add_string_to_exception(value, string):
                        """Add string to the exception parameter."""
                        # The point is to have the string visible when the exception is printed
                        # or converted to string - may it be via `str()`, `repr()` or when the
                        # exception is uncaught and displayed (which seems to use `str()`).
                    Severity: Minor
                    Found in didyoumean/didyoumean_internal.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 suggest_name_as_attribute has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                    Open

                    def suggest_name_as_attribute(name, objdict):
                        """Suggest that name could be an attribute of an object.
                    
                        Example: 'do_stuff()' -> 'self.do_stuff()'.
                        """
                    Severity: Minor
                    Found in didyoumean/didyoumean_internal.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_instance has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                    Open

                    def get_instance(klass):
                        """Get instance for class by bruteforcing the parameters.
                    
                        Construction is attempted with a decreasing number of arguments so that
                        the instanciated object has as many non-null attributes set as possible.
                    Severity: Minor
                    Found in didyoumean/didyoumean_internal_tests.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 check_more_about_re has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def check_more_about_re(self, text, regexp):
                            """Check various properties about the regexp.
                    
                            Properties checked are configurable via global constants. These
                            properties are not stricly speaking required but they help to
                    Severity: Minor
                    Found in didyoumean/didyoumean_re_tests.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_code_with_exc_before_and_after has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                    def get_code_with_exc_before_and_after(code, exc_types, exception_to_str_func):
                        exc = common.get_exception(code)
                        if exc is None:
                            before = after = "No exception thrown on this version of Python"
                        else:
                    Severity: Minor
                    Found in didyoumean/readme_examples.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

                    Function __exit__ has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def __exit__(self, type_, value, traceback):
                            """Method called when exiting the context manager.
                    
                            Add suggestions to the exception (if any).
                            """
                    Severity: Minor
                    Found in didyoumean/didyoumean_api.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

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

                    def main(exception_to_str_func):
                        """Main."""
                        print(datetime.datetime.now())
                        print(
                            "## Exception on Python {0} printed with {1}".format(
                    Severity: Minor
                    Found in didyoumean/readme_examples.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

                    Function suggest_unsupported_op has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                    def suggest_unsupported_op(value, frame, groups):
                        """Get suggestions for UNSUPPORTED_OP_RE/UNSUPPORTED_OP_SUGG_RE."""
                        del value  # unused param
                        binary, type1, type2 = groups[:3]
                        sugg = "" if len(groups) < 3 + 1 else groups[3]
                    Severity: Minor
                    Found in didyoumean/didyoumean_internal.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

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

                    def meth_gen(class_name='MyClass', name='some_method',
                    Severity: Minor
                    Found in didyoumean/didyoumean_sugg_tests.py - About 35 mins to fix
                      Severity
                      Category
                      Status
                      Source
                      Language