Completed
Push — master ( eea0b2...e9f487 )
by Justin
01:29
created

module.exports   A

Complexity

Conditions 1
Paths 2

Size

Total Lines 53

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 53
rs 9.5797

4 Functions

Rating   Name   Duplication   Size   Complexity  
A 0 6 2
A 0 3 1
A 0 3 1
A 0 3 1

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
/**
2
 * Record extensions to SourceReference
3
 */
4
module.exports = function(GedcomX){
5
  
6
  // Extend serialization properties
7
  GedcomX.SourceReference.jsonProps.push('qualifiers');
8
  
9
  // Override init()
10
  var oldSourceReferenceInit = GedcomX.SourceReference.prototype.init;
11
  GedcomX.SourceReference.prototype.init = function(json){
12
    oldSourceReferenceInit.call(this, json);
13
    if(json){
14
      this.setQualifiers(json.qualifiers);
15
    }
16
  };
17
  
18
  /**
19
   * Set the qualifiers
20
   * 
21
   * @function setQualifiers
22
   * @instance
23
   * @memberof SourceReference
24
   * @param {Qualifier[]} qualifiers
25
   * @return {SourceReference} this
26
   */
27
  GedcomX.SourceReference.prototype.setQualifiers = function(qualifiers){
28
    return this._setArray(qualifiers, 'qualifiers', 'addQualifier');
29
  };
30
  
31
  /**
32
   * Add a qualifier
33
   * 
34
   * @function addQualifier
35
   * @instance
36
   * @memberof SourceReference
37
   * @param {Qualifiers} qualifier
38
   * @return {SourceReference} this
39
   */
40
  GedcomX.SourceReference.prototype.addQualifier = function(qualifier){
41
    return this._arrayPush(qualifier, 'qualifiers', GedcomX.Qualifier);
42
  };
43
  
44
  /**
45
   * Get the qualifiers
46
   * 
47
   * @function getQualifiers
48
   * @instance
49
   * @memberof SourceReference
50
   * @return {Qualifier[]} qualifiers
51
   */
52
  GedcomX.SourceReference.prototype.getQualifiers = function(){
53
    return this.qualifiers || [];
54
  };
55
  
56
};