Python: Fix query names that inclde __ (dunder)

Without backticks, the text UNDERSCORE UNDERSCORE eq UNDERSCORE UNDERSCORE would
be considered to make things bold in our markdown output, making the query info
look strange.

Example https://codeql.github.com/codeql-query-help/python/py-slots-in-old-style-class/
This commit is contained in:
Rasmus Wriedt Larsen
2021-02-04 15:49:37 +01:00
parent 5db1984315
commit 3fe715abb6
24 changed files with 36 additions and 36 deletions

View File

@@ -1,5 +1,5 @@
/**
* @name __eq__ not overridden when adding attributes
* @name `__eq__` not overridden when adding attributes
* @description When adding new attributes to instances of a class, equality for that class needs to be defined.
* @kind problem
* @tags reliability

View File

@@ -1,6 +1,6 @@
/**
* @name __init__ method calls overridden method
* @description Calling a method from __init__ that is overridden by a subclass may result in a partially
* @name `__init__` method calls overridden method
* @description Calling a method from `__init__` that is overridden by a subclass may result in a partially
* initialized instance being observed.
* @kind problem
* @tags reliability

View File

@@ -1,6 +1,6 @@
/**
* @name Maybe undefined class attribute
* @description Accessing an attribute of 'self' that is not initialized in the __init__ method may cause an AttributeError at runtime
* @description Accessing an attribute of `self` that is not initialized in the `__init__` method may cause an AttributeError at runtime
* @kind problem
* @tags reliability
* correctness

View File

@@ -1,6 +1,6 @@
/**
* @name Missing call to __del__ during object destruction
* @description An omitted call to a super-class __del__ method may lead to class instances not being cleaned up properly.
* @name Missing call to `__del__` during object destruction
* @description An omitted call to a super-class `__del__` method may lead to class instances not being cleaned up properly.
* @kind problem
* @tags efficiency
* correctness

View File

@@ -1,6 +1,6 @@
/**
* @name Missing call to __init__ during object initialization
* @description An omitted call to a super-class __init__ method may lead to objects of this class not being fully initialized.
* @name Missing call to `__init__` during object initialization
* @description An omitted call to a super-class `__init__` method may lead to objects of this class not being fully initialized.
* @kind problem
* @tags reliability
* correctness

View File

@@ -1,5 +1,5 @@
/**
* @name Mutation of descriptor in __get__ or __set__ method.
* @name Mutation of descriptor in `__get__` or `__set__` method.
* @description Descriptor objects can be shared across many instances. Mutating them can cause strange side effects or race conditions.
* @kind problem
* @tags reliability

View File

@@ -1,6 +1,6 @@
/**
* @name Overwriting attribute in super-class or sub-class
* @description Assignment to self attribute overwrites attribute previously defined in subclass or superclass __init__ method.
* @description Assignment to self attribute overwrites attribute previously defined in subclass or superclass `__init__` method.
* @kind problem
* @tags reliability
* maintainability

View File

@@ -1,6 +1,6 @@
/**
* @name '__slots__' in old-style class
* @description Overriding the class dictionary by declaring '__slots__' is not supported by old-style
* @name `__slots__` in old-style class
* @description Overriding the class dictionary by declaring `__slots__` is not supported by old-style
* classes.
* @kind problem
* @problem.severity error

View File

@@ -1,6 +1,6 @@
/**
* @name Multiple calls to __del__ during object destruction
* @description A duplicated call to a super-class __del__ method may lead to class instances not be cleaned up properly.
* @name Multiple calls to `__del__` during object destruction
* @description A duplicated call to a super-class `__del__` method may lead to class instances not be cleaned up properly.
* @kind problem
* @tags efficiency
* correctness

View File

@@ -1,6 +1,6 @@
/**
* @name Multiple calls to __init__ during object initialization
* @description A duplicated call to a super-class __init__ method may lead to objects of this class not being properly initialized.
* @name Multiple calls to `__init__` during object initialization
* @description A duplicated call to a super-class `__init__` method may lead to objects of this class not being properly initialized.
* @kind problem
* @tags reliability
* correctness

View File

@@ -1,6 +1,6 @@
/**
* @name Undefined class attribute
* @description Accessing an attribute of 'self' that is not initialized anywhere in the class in the __init__ method may cause an AttributeError at runtime
* @description Accessing an attribute of `self` that is not initialized anywhere in the class in the `__init__` method may cause an AttributeError at runtime
* @kind problem
* @tags reliability
* correctness

View File

@@ -1,6 +1,6 @@
/**
* @name Useless class
* @description Class only defines one public method (apart from __init__ or __new__) and should be replaced by a function
* @description Class only defines one public method (apart from `__init__` or `__new__`) and should be replaced by a function
* @kind problem
* @tags maintainability
* useless-code

View File

@@ -1,6 +1,6 @@
/**
* @name Wrong number of arguments in a class instantiation
* @description Using too many or too few arguments in a call to the __init__
* @description Using too many or too few arguments in a call to the `__init__`
* method of a class will result in a TypeError at runtime.
* @kind problem
* @tags reliability

View File

@@ -1,6 +1,6 @@
/**
* @name __del__ is called explicitly
* @description The __del__ special method is called by the virtual machine when an object is being finalized. It should not be called explicitly.
* @name `__del__` is called explicitly
* @description The `__del__` special method is called by the virtual machine when an object is being finalized. It should not be called explicitly.
* @kind problem
* @tags reliability
* correctness

View File

@@ -1,5 +1,5 @@
/**
* @name Comparison using is when operands support __eq__
* @name Comparison using is when operands support `__eq__`
* @description Comparison using 'is' when equivalence is not the same as identity
* @kind problem
* @tags reliability

View File

@@ -1,5 +1,5 @@
/**
* @name Non-portable comparison using is when operands support __eq__
* @name Non-portable comparison using is when operands support `__eq__`
* @description Comparison using 'is' when equivalence is not the same as identity and may not be portable.
* @kind problem
* @tags portability

View File

@@ -1,6 +1,6 @@
/**
* @name __init__ method returns a value
* @description Explicitly returning a value from an __init__ method will raise a TypeError.
* @name `__init__` method returns a value
* @description Explicitly returning a value from an `__init__` method will raise a TypeError.
* @kind problem
* @tags reliability
* correctness

View File

@@ -1,6 +1,6 @@
/**
* @name __init__ method is a generator
* @description __init__ method is a generator.
* @name `__init__` method is a generator
* @description `__init__` method is a generator.
* @kind problem
* @tags reliability
* correctness

View File

@@ -1,6 +1,6 @@
/**
* @name __iter__ method returns a non-iterator
* @description The '__iter__' method returns a non-iterator which, if used in a 'for' loop, would raise a 'TypeError'.
* @name `__iter__` method returns a non-iterator
* @description The `__iter__` method returns a non-iterator which, if used in a 'for' loop, would raise a 'TypeError'.
* @kind problem
* @tags reliability
* correctness

View File

@@ -1,6 +1,6 @@
/**
* @name Iterator does not return self from __iter__ method
* @description Iterator does not return self from __iter__ method, violating the iterator protocol.
* @name Iterator does not return self from `__iter__` method
* @description Iterator does not return self from `__iter__` method, violating the iterator protocol.
* @kind problem
* @tags reliability
* correctness

View File

@@ -1,6 +1,6 @@
/**
* @name Overly complex __del__ method
* @description __del__ methods may be called at arbitrary times, perhaps never called at all, and should be simple.
* @name Overly complex `__del__` method
* @description `__del__` methods may be called at arbitrary times, perhaps never called at all, and should be simple.
* @kind problem
* @tags efficiency
* maintainability

View File

@@ -1,7 +1,7 @@
/**
* @name 'import *' may pollute namespace
* @description Importing a module using 'import *' may unintentionally pollute the global
* namespace if the module does not define '__all__'
* namespace if the module does not define `__all__`
* @kind problem
* @tags maintainability
* modularity

View File

@@ -1,6 +1,6 @@
/**
* @name Use of a print statement at module level
* @description Using a print statement at module scope (except when guarded by if __name__ == '__main__') will cause surprising output when the module is imported.
* @description Using a print statement at module scope (except when guarded by `if __name__ == '__main__'`) will cause surprising output when the module is imported.
* @kind problem
* @tags reliability
* maintainability

View File

@@ -1,6 +1,6 @@
/**
* @name Explicit export is not defined
* @description Including an undefined attribute in __all__ causes an exception when
* @description Including an undefined attribute in `__all__` causes an exception when
* the module is imported using '*'
* @kind problem
* @tags reliability