| Total Complexity | 6 |
| Total Lines | 32 |
| Duplicated Lines | 12.5 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 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 | # frozen_string_literal: true |
||
| 14 | class Variable < Type |
||
| 15 | # @!attribute type |
||
| 16 | # @return [AMA::Entity::Mapper::Type] |
||
| 17 | attr_reader :owner |
||
| 18 | # @!attribute id |
||
| 19 | # @return [Symbol] |
||
| 20 | attr_reader :id |
||
| 21 | |||
| 22 | # @param [AMA::Entity::Mapper::Type] owner |
||
| 23 | # @param [Symbol] id |
||
| 24 | def initialize(owner, id) |
||
| 25 | @owner = owner |
||
| 26 | @id = id |
||
| 27 | end |
||
| 28 | |||
| 29 | def resolved? |
||
| 30 | false |
||
| 31 | end |
||
| 32 | |||
| 33 | def to_s |
||
| 34 | "Variable Type :#{id} (declared in #{owner})" |
||
| 35 | end |
||
| 36 | |||
| 37 | def hash |
||
| 38 | @owner.hash ^ @id.hash |
||
| 39 | end |
||
| 40 | |||
| 41 | View Code Duplication | def eql?(other) |
|
|
|
|||
| 42 | return false unless other.is_a?(self.class) |
||
| 43 | id == other.id && owner == other.owner |
||
| 44 | end |
||
| 45 | end |
||
| 46 | end |
||
| 50 |