| Total Complexity | 1 |
| Total Lines | 11 |
| Duplicated Lines | 100 % |
| 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 |
||
| 4 | View Code Duplication | class CreateSurveyParticipants < ActiveRecord::Migration[5.1] |
|
|
|
|||
| 5 | def change |
||
| 6 | create_table :survey_participants do |t| |
||
| 7 | t.references :participant, null: false, foreign_key: true |
||
| 8 | t.references :survey, null: false, foreign_key: true |
||
| 9 | t.timestamps null: false, default: -> { 'CURRENT_TIMESTAMP' } |
||
| 10 | end |
||
| 11 | |||
| 12 | add_index :survey_participants, %i[participant_id survey_id], unique: true, name: 'index_by_participant_survey' |
||
| 13 | end |
||
| 14 | end |
||
| 15 |