| Total Complexity | 1 |
| Total Lines | 21 |
| Duplicated Lines | 100 % |
| Changes | 0 | ||
Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
| 1 | from .model import * |
||
| 4 | View Code Duplication | class TagRelations(Base): |
|
|
|
|||
| 5 | __tablename__ = 'tag_relations' |
||
| 6 | |||
| 7 | id = Column(Integer, primary_key=True, nullable=False) |
||
| 8 | tag_id = Column(Integer, ForeignKey('tags.id'), nullable=False) |
||
| 9 | parent_tag_id = Column(Integer, ForeignKey('tags.id'), nullable=False) |
||
| 10 | |||
| 11 | deleted = Column(Boolean, default=False, nullable=False) |
||
| 12 | |||
| 13 | tag = relationship(tagobject.Tag, |
||
| 14 | primaryjoin=tag_id==tagobject.Tag.id, |
||
| 15 | backref='parents') |
||
| 16 | |||
| 17 | parent = relationship(tagobject.Tag, |
||
| 18 | primaryjoin=parent_tag_id==tagobject.Tag.id, |
||
| 19 | backref='children') |
||
| 20 | |||
| 21 | |||
| 22 | def __init__(self, tag, parent_tag): |
||
| 23 | self.tag_id = tag.id |
||
| 24 | self.parent_tag_id = parent_tag.id |
||
| 25 |