Files
codeql/python/ql/src/Classes/OverwritingAttributeInSuperClass.qhelp
2018-11-19 15:10:42 +00:00

30 lines
704 B
XML

<!DOCTYPE qhelp PUBLIC
"-//Semmle//qhelp//EN"
"qhelp.dtd">
<qhelp>
<overview>
<p>
Subclasses should not set attributes that are set in the superclass.
Doing so may violate invariants in the superclass. </p>
</overview>
<recommendation>
<p>
If you did not intend to override the attribute value set in the superclass,
then rename the subclass attribute.
If you do want to be able to set a new value for the attribute of the superclass,
then convert the superclass attribute to a property.
Otherwise the value should be passed as a parameter to the superclass
<code>__init__</code> method.
</p>
</recommendation>
<example>
<sample src="OverwritingAttributeInSuperClass.py" />
</example>
</qhelp>