CreateStudyEvents   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 13
Duplicated Lines 100 %

Importance

Changes 0
Metric Value
dl 13
loc 13
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A change() 11 11 1

How to fix   Duplicated Code   

Duplicated Code

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
2
3
# Table to represent study events in an arm
4 View Code Duplication
class CreateStudyEvents < ActiveRecord::Migration[5.1]
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
5
  def change
6
    create_table :study_events do |t|
7
      t.string :name, null: false, index: true
8
      t.integer :order, null: false, index: true, default: 1
9
      t.references :arm, null: false, foreign_key: true, index: true 
10
      t.datetime :event_date, null: false, default: -> { 'CURRENT_TIMESTAMP' }
11
      t.timestamps null: false, default: -> { 'CURRENT_TIMESTAMP' }
12
    end
13
14
    add_index :study_events, %i[arm_id name], unique: true, name: 'index_by_arm_name'
15
  end
16
end
17