SylvainDe/DidYouMean-Python

View on GitHub

Showing 142 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

              Similar blocks of code found in 4 locations. Consider refactoring.
              Open

                  def test_nb_args5(self):
                      """Should have 3 args."""
                      typo, good = '1, 2', '1, 2, 3'
                      before, after = before_and_after((3, 3))
                      func_code = func_gen(param='so, much, args', args='{0}')
              Severity: Major
              Found in didyoumean/didyoumean_sugg_tests.py and 3 other locations - About 7 hrs to fix
              didyoumean/didyoumean_sugg_tests.py on lines 1458..1468
              didyoumean/didyoumean_sugg_tests.py on lines 1470..1480
              didyoumean/didyoumean_sugg_tests.py on lines 1482..1492

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 119.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 4 locations. Consider refactoring.
              Open

                  def test_nb_args2(self):
                      """Should have 1 arg."""
                      typo, good = '', '1'
                      before, after = before_and_after((3, 3))
                      func_code = func_gen(param='a', args='{0}')
              Severity: Major
              Found in didyoumean/didyoumean_sugg_tests.py and 3 other locations - About 7 hrs to fix
              didyoumean/didyoumean_sugg_tests.py on lines 1470..1480
              didyoumean/didyoumean_sugg_tests.py on lines 1482..1492
              didyoumean/didyoumean_sugg_tests.py on lines 1494..1504

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 119.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 4 locations. Consider refactoring.
              Open

                  def test_nb_args4(self):
                      """Should have 3 args."""
                      typo, good = '', '1, 2, 3'
                      before, after = before_and_after((3, 3))
                      func_code = func_gen(param='so, much, args', args='{0}')
              Severity: Major
              Found in didyoumean/didyoumean_sugg_tests.py and 3 other locations - About 7 hrs to fix
              didyoumean/didyoumean_sugg_tests.py on lines 1458..1468
              didyoumean/didyoumean_sugg_tests.py on lines 1470..1480
              didyoumean/didyoumean_sugg_tests.py on lines 1494..1504

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 119.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 4 locations. Consider refactoring.
              Open

                  def test_nb_args3(self):
                      """Should have 3 args."""
                      typo, good = '1', '1, 2, 3'
                      before, after = before_and_after((3, 3))
                      func_code = func_gen(param='so, much, args', args='{0}')
              Severity: Major
              Found in didyoumean/didyoumean_sugg_tests.py and 3 other locations - About 7 hrs to fix
              didyoumean/didyoumean_sugg_tests.py on lines 1458..1468
              didyoumean/didyoumean_sugg_tests.py on lines 1482..1492
              didyoumean/didyoumean_sugg_tests.py on lines 1494..1504

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 119.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                  def test_keyword_arg_lambda(self):
                      """Test with lambda functions instead of usual function."""
                      before, after = before_and_after((3, 13))
                      typo, good = 'abcdf', 'abcdef'
                      sugg = quote(good)
              Severity: Major
              Found in didyoumean/didyoumean_sugg_tests.py and 1 other location - About 6 hrs to fix
              didyoumean/didyoumean_sugg_tests.py on lines 1637..1647

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 108.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 3 locations. Consider refactoring.
              Open

                  def test_keyword_arg_multiples_instances(self):
                      """If multiple functions are found, suggestions should be unique."""
                      before, after = before_and_after((3, 13))
                      typo, good = 'abcdf', 'abcdef'
                      code = 'class MyClass:\n\tdef func(self, ' + good + '):' \
              Severity: Major
              Found in didyoumean/didyoumean_sugg_tests.py and 2 other locations - About 6 hrs to fix
              didyoumean/didyoumean_sugg_tests.py on lines 1580..1590
              didyoumean/didyoumean_sugg_tests.py on lines 1600..1611

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 108.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 3 locations. Consider refactoring.
              Open

                  def test_keyword_arg_class_method2(self):
                      """Should be the same as previous test but on a class method."""
                      before, after = before_and_after((3, 13))
                      typo, good = 'abcdf', 'abcdef'
                      code = 'class MyClass:\n\t@classmethod ' \
              Severity: Major
              Found in didyoumean/didyoumean_sugg_tests.py and 2 other locations - About 6 hrs to fix
              didyoumean/didyoumean_sugg_tests.py on lines 1580..1590
              didyoumean/didyoumean_sugg_tests.py on lines 1613..1623

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 108.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 3 locations. Consider refactoring.
              Open

                  def test_keyword_arg_method2(self):
                      """Should be the same as previous test but on a method."""
                      before, after = before_and_after((3, 13))
                      typo, good = 'abcdf', 'abcdef'
                      code = 'class MyClass:\n\tdef func(self, ' + good + '):' \
              Severity: Major
              Found in didyoumean/didyoumean_sugg_tests.py and 2 other locations - About 6 hrs to fix
              didyoumean/didyoumean_sugg_tests.py on lines 1600..1611
              didyoumean/didyoumean_sugg_tests.py on lines 1613..1623

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 108.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                  def test_keyword_arg_lambda_method(self):
                      """Test with lambda methods instead of usual methods."""
                      before, after = before_and_after((3, 13))
                      typo, good = 'abcdf', 'abcdef'
                      sugg = quote(good)
              Severity: Major
              Found in didyoumean/didyoumean_sugg_tests.py and 1 other location - About 6 hrs to fix
              didyoumean/didyoumean_sugg_tests.py on lines 1625..1635

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 108.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                  def test_from_module(self):
                      """Should be math.pi."""
                      code = 'import math\nmath.{0}'
                      typo, good = 'pie', 'pi'
                      sugg = quote(good)
              Severity: Major
              Found in didyoumean/didyoumean_sugg_tests.py and 1 other location - About 5 hrs to fix
              didyoumean/didyoumean_sugg_tests.py on lines 1072..1081

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 96.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                  def test_from_module2(self):
                      """Should be math.pi."""
                      code = 'import math\nm = math\nm.{0}'
                      typo, good = 'pie', 'pi'
                      sugg = quote(good)
              Severity: Major
              Found in didyoumean/didyoumean_sugg_tests.py and 1 other location - About 5 hrs to fix
              didyoumean/didyoumean_sugg_tests.py on lines 1061..1070

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 96.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              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

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                  def test_nb_args1(self):
                      """Should have 0 args."""
                      typo, good = '1', ''
                      func_code = func_gen(param='', args='{0}')
                      meth_code = meth_gen(param='self', args='{0}')
              Severity: Major
              Found in didyoumean/didyoumean_sugg_tests.py and 1 other location - About 5 hrs to fix
              didyoumean/didyoumean_sugg_tests.py on lines 1438..1446

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 90.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                  def test_nb_args(self):
                      """Should have 1 arg."""
                      typo, good = '1, 2', '1'
                      func_code = func_gen(param='a', args='{0}')
                      meth_code = meth_gen(param='self, a', args='{0}')
              Severity: Major
              Found in didyoumean/didyoumean_sugg_tests.py and 1 other location - About 5 hrs to fix
              didyoumean/didyoumean_sugg_tests.py on lines 1448..1456

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 90.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Severity
              Category
              Status
              Source
              Language