Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f0d5a91

Browse files
authored
Merge pull request #5093 from RasmusWL/fix-query-names-with-dunder
Python: Fix query names with dunder (__)
2 parents 69c7c83 + b94658f commit f0d5a91

25 files changed

Lines changed: 44 additions & 44 deletions

python/ql/src/Classes/DefineEqualsWhenAddingAttributes.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @name __eq__ not overridden when adding attributes
2+
* @name `__eq__` not overridden when adding attributes
33
* @description When adding new attributes to instances of a class, equality for that class needs to be defined.
44
* @kind problem
55
* @tags reliability

python/ql/src/Classes/InitCallsSubclassMethod.ql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
2-
* @name __init__ method calls overridden method
3-
* @description Calling a method from __init__ that is overridden by a subclass may result in a partially
2+
* @name `__init__` method calls overridden method
3+
* @description Calling a method from `__init__` that is overridden by a subclass may result in a partially
44
* initialized instance being observed.
55
* @kind problem
66
* @tags reliability

python/ql/src/Classes/MaybeUndefinedClassAttribute.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* @name Maybe undefined class attribute
3-
* @description Accessing an attribute of 'self' that is not initialized in the __init__ method may cause an AttributeError at runtime
3+
* @description Accessing an attribute of `self` that is not initialized in the `__init__` method may cause an AttributeError at runtime
44
* @kind problem
55
* @tags reliability
66
* correctness

python/ql/src/Classes/MissingCallToDel.ql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
2-
* @name Missing call to __del__ during object destruction
3-
* @description An omitted call to a super-class __del__ method may lead to class instances not being cleaned up properly.
2+
* @name Missing call to `__del__` during object destruction
3+
* @description An omitted call to a super-class `__del__` method may lead to class instances not being cleaned up properly.
44
* @kind problem
55
* @tags efficiency
66
* correctness

python/ql/src/Classes/MissingCallToInit.ql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
2-
* @name Missing call to __init__ during object initialization
3-
* @description An omitted call to a super-class __init__ method may lead to objects of this class not being fully initialized.
2+
* @name Missing call to `__init__` during object initialization
3+
* @description An omitted call to a super-class `__init__` method may lead to objects of this class not being fully initialized.
44
* @kind problem
55
* @tags reliability
66
* correctness

python/ql/src/Classes/MutatingDescriptor.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @name Mutation of descriptor in __get__ or __set__ method.
2+
* @name Mutation of descriptor in `__get__` or `__set__` method.
33
* @description Descriptor objects can be shared across many instances. Mutating them can cause strange side effects or race conditions.
44
* @kind problem
55
* @tags reliability

python/ql/src/Classes/OverwritingAttributeInSuperClass.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* @name Overwriting attribute in super-class or sub-class
3-
* @description Assignment to self attribute overwrites attribute previously defined in subclass or superclass __init__ method.
3+
* @description Assignment to self attribute overwrites attribute previously defined in subclass or superclass `__init__` method.
44
* @kind problem
55
* @tags reliability
66
* maintainability

python/ql/src/Classes/SlotsInOldStyleClass.qhelp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,21 @@
55

66
<overview>
77
<p>The ability to override the class dictionary using a <code>__slots__</code> declaration
8-
is supported only by new-style classes. When you add a <code>__slots__</code> declaration to an
9-
old-style class it just creates a class attribute called '__slots__'.</p>
8+
is supported only by new-style classes. When you add a <code>__slots__</code> declaration to an
9+
old-style class it just creates a class attribute called <code>__slots__</code>.</p>
1010

1111
</overview>
1212
<recommendation>
1313

14-
<p>If you want to override the dictionary for a class, then ensure that the class is a new-style class.
14+
<p>If you want to override the dictionary for a class, then ensure that the class is a new-style class.
1515
You can convert an old-style class to a new-style class by inheriting from <code>object</code>.</p>
1616

1717
</recommendation>
1818
<example>
19-
<p>In the following example the <code>KeyedRef</code> class is an old-style class (no inheritance). The
20-
<code>__slots__</code> declaration in this class creates a class attribute called '__slots__', the class
21-
dictionary is unaffected. The <code>KeyedRef2</code> class is a new-style class so the
22-
<code>__slots__</code> declaration causes special compact attributes to be created for each name in
19+
<p>In the following Python 2 example the <code>Point</code> class is an old-style class (no inheritance). The
20+
<code>__slots__</code> declaration in this class creates a class attribute called <code>__slots__</code>, the class
21+
dictionary is unaffected. The <code>Point2</code> class is a new-style class so the
22+
<code>__slots__</code> declaration causes special compact attributes to be created for each name in
2323
the slots list and saves space by not creating attribute dictionaries.</p>
2424

2525
<sample src="SlotsInOldStyleClass.py" />
@@ -28,7 +28,7 @@ the slots list and saves space by not creating attribute dictionaries.</p>
2828
<references>
2929

3030
<li>Python Glossary: <a href="http://docs.python.org/glossary.html#term-new-style-class">New-style class</a>.</li>
31-
<li>Python Language Reference: <a href="http://docs.python.org/2/reference/datamodel.html#newstyle">New-style and classic
31+
<li>Python Language Reference: <a href="http://docs.python.org/2/reference/datamodel.html#newstyle">New-style and classic
3232
classes</a>,
3333
<a href="http://docs.python.org/reference/datamodel.html#__slots__">__slots__</a>.</li>
3434

python/ql/src/Classes/SlotsInOldStyleClass.ql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
2-
* @name '__slots__' in old-style class
3-
* @description Overriding the class dictionary by declaring '__slots__' is not supported by old-style
2+
* @name `__slots__` in old-style class
3+
* @description Overriding the class dictionary by declaring `__slots__` is not supported by old-style
44
* classes.
55
* @kind problem
66
* @problem.severity error

python/ql/src/Classes/SuperclassDelCalledMultipleTimes.ql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
2-
* @name Multiple calls to __del__ during object destruction
3-
* @description A duplicated call to a super-class __del__ method may lead to class instances not be cleaned up properly.
2+
* @name Multiple calls to `__del__` during object destruction
3+
* @description A duplicated call to a super-class `__del__` method may lead to class instances not be cleaned up properly.
44
* @kind problem
55
* @tags efficiency
66
* correctness

0 commit comments

Comments
 (0)