CreateStudyParticipants   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 13
Duplicated Lines 100 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 13
loc 13
rs 10
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
# Creates tables for association class between participants and studies
4 View Code Duplication
class CreateStudyParticipants < 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_participants do |t|
7
      t.references :participant, null: false, foreign_key: true
8
      t.references :study, null: false, foreign_key: true
9
      t.string :subject_number, null: true
10
      t.timestamps null: false, default: -> { 'CURRENT_TIMESTAMP' }
11
    end
12
13
    add_index :study_participants, %i[participant_id study_id], unique: true, name: 'index_participant_study'
14
    add_index :study_participants, %i[study_id subject_number], name: 'index_study_subject_number'
15
  end
16
end
17