Total Complexity | 1 |
Total Lines | 13 |
Duplicated Lines | 30.77 % |
Changes | 2 | ||
Bugs | 0 | Features | 1 |
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 |
||
4 | class StudyParticipant < ApplicationRecord |
||
5 | belongs_to :participant, inverse_of: :study_participants |
||
6 | belongs_to :study, inverse_of: :study_participants |
||
7 | validates :participant, presence: true |
||
8 | validates :study, presence: true |
||
9 | |||
10 | validates_uniqueness_of :study, scope: :participant |
||
11 | validates_uniqueness_of :participant, scope: :study |
||
12 | |||
13 | View Code Duplication | def to_s |
|
|
|||
14 | "#{participant} #{study}" |
||
15 | end |
||
16 | end |
||
17 | |||
36 |