AssessmentInstrument   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 14
Duplicated Lines 42.86 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 6
loc 14
rs 10
c 1
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A to_s() 3 3 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
# Association class between assessments and instruments
4
class AssessmentInstrument < ApplicationRecord
5
  belongs_to :assessment, inverse_of: :assessment_instruments
6
  belongs_to :instrument, inverse_of: :assessment_instruments
7
8
  validates :assessment, presence: true
9
  validates :instrument, presence: true
10
11
  validates_uniqueness_of :instrument, scope: :assessment
12 View Code Duplication
  validates_uniqueness_of :assessment, scope: :instrument
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
13
  
14
  def to_s
15
    "#{assessment} #{instrument}"
16
  end
17
end
18
19
# == Schema Information
20
#
21
# Table name: assessment_instruments
22
#
23
#  id            :integer          not null, primary key
24
#  assessment_id :integer          not null
25
#  instrument_id :integer          not null
26
#  created_at    :datetime         not null
27
#  updated_at    :datetime         not null
28
#
29
# Indexes
30
#
31
#  index_assessment_instruments_on_assessment_id  (assessment_id)
32
#  index_assessment_instruments_on_instrument_id  (instrument_id)
33
#  index_by_assessment_instrument                 (assessment_id,instrument_id) UNIQUE
34
#
35