Development of an internal social media platform with personalised dashboards for students
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

statement_without_effect.py 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. """Test for statements without effects."""
  2. # pylint: disable=too-few-public-methods
  3. # +1:[pointless-string-statement]
  4. """inline doc string should use a separated message"""
  5. __revision__ = ''
  6. __revision__ # [pointless-statement]
  7. __revision__ <= 1 # [pointless-statement]
  8. __revision__.lower()
  9. [i for i in __revision__] # [pointless-statement]
  10. # +1:[pointless-string-statement]
  11. """inline doc string should use a separated message"""
  12. __revision__.lower(); # [unnecessary-semicolon]
  13. list() and tuple() # [expression-not-assigned]
  14. def to_be():
  15. """return 42"""
  16. return "42"
  17. ANSWER = to_be() # ok
  18. ANSWER == to_be() # [expression-not-assigned]
  19. to_be() or not to_be() # [expression-not-assigned]
  20. to_be().title # [expression-not-assigned]
  21. GOOD_ATTRIBUTE_DOCSTRING = 42
  22. """Module level attribute docstring is fine. """
  23. class ClassLevelAttributeTest(object):
  24. """ test attribute docstrings. """
  25. good_attribute_docstring = 24
  26. """ class level attribute docstring is fine either. """
  27. second_good_attribute_docstring = 42
  28. # Comments are good.
  29. # empty lines are good, too.
  30. """ Still a valid class level attribute docstring. """
  31. def __init__(self):
  32. self.attr = 42
  33. """ Good attribute docstring """
  34. attr = 24
  35. """ Still a good __init__ level attribute docstring. """
  36. val = 0
  37. for val in range(42):
  38. val += attr
  39. # +1:[pointless-string-statement]
  40. """ Invalid attribute docstring """
  41. self.val = val
  42. def test(self):
  43. """ invalid attribute docstrings here. """
  44. self.val = 42
  45. # +1:[pointless-string-statement]
  46. """ this is an invalid attribute docstring. """