CreateInstruments   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 16
Duplicated Lines 100 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A change() 14 14 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
# Migration to create instruments table
4 View Code Duplication
class CreateInstruments < 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 :instruments, comment: 'Instruments table' do |t|
7
      t.string :name, null: false, unique: true, index: true
8
      t.string :version_number, null: false, default: '1.0'
9
      t.string :instrument_type, null: false, default: 'json'
10
      t.jsonb :json_content, null: false, default: '{}'
11
      t.text :csv_content, null: false, index: true, default: ''
12
      t.text :instructions, null: false, default: ''
13
      t.timestamps null: false, default: -> { 'CURRENT_TIMESTAMP' }
14
    end
15
16
    add_index :instruments, :json_content, using: :gin, name: 'instrument_json_content'
17
    add_index :instruments, %i[name version_number], unique: true
18
  end
19
end
20