Total Complexity | 1 |
Total Lines | 14 |
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 | # frozen_string_literal: true |
||
4 | View Code Duplication | class CreateStudyEventInstruments < ActiveRecord::Migration[5.1] |
|
|
|||
5 | def change |
||
6 | create_table :study_event_instruments do |t| |
||
7 | t.references :study_event, null: false |
||
8 | t.references :instrument, null: false |
||
9 | t.timestamps null: false, default: -> { 'CURRENT_TIMESTAMP' } |
||
10 | end |
||
11 | |||
12 | add_index :study_event_instruments, %i[study_event_id instrument_id], \ |
||
13 | unique: true, name: 'index_by_study_event_instrument' |
||
14 | add_foreign_key :study_event_instruments, :study_events |
||
15 | add_foreign_key :study_event_instruments, :instruments |
||
16 | end |
||
17 | end |
||
18 |