GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

lib/position.js   A
last analyzed

Complexity

Total Complexity 7
Complexity/F 1.4

Size

Lines of Code 63
Function Count 5

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
cc 0
c 3
b 0
f 0
nc 1
dl 0
loc 63
rs 10
wmc 7
mnd 1
bc 7
fnc 5
bpm 1.4
cpm 1.4
noi 0

4 Functions

Rating   Name   Duplication   Size   Complexity  
A position.js ➔ Position 0 7 1
A position.js ➔ isCoordinates 0 3 1
A Position.isValid 0 8 3
A position.js ➔ isCardinal 0 3 1
1
"use strict";
2
3
var _ = require('lodash');
4
5
// Expose `Position`
6
7
module.exports = Position;
8
9
var cardinalPoints = ['N','E','S','W'];
10
11
/**
12
 * Set up Position with `coordinate` and `cardinal`
13
14
 * @param {Object} coordinate
15
 * @param {String} cardinal
16
 * @api public
17
 */
18
19
function Position(coordinate, cardinal) {
20
    this.x = coordinate.x;
21
    this.y = coordinate.y;
22
    this.c = cardinal;
23
24
    this.isValid();
25
}
26
27
/**
28
 * Types validator
29
 *
30
 * @api public
31
 */
32
33
Position.prototype.isValid = function() {
34
    if(!isCoordinates(this.x,this.y)) {
35
        throw new Error('Coordinates are not valid');
36
    }
37
    if(!isCardinal(this.c)) {
38
        throw new Error('Cardinal point is not valid');
39
    }
40
};
41
42
/**
43
 * Coordinates validator helper
44
 *
45
 * @param {Number} x
46
 * @param {Number} y
47
 * @api protected
48
 */
49
50
function isCoordinates(x,y) {
51
    return x === parseInt(x, 10) && y === parseInt(y, 10);
52
}
53
54
/**
55
 * Cardinal validator helper
56
 *
57
 * @param {String} cardinal
58
 * @api protected
59
 */
60
61
function isCardinal(cardinal) {
62
    return _.isString(cardinal) && !_.isUndefined( _.find(cardinalPoints, function(c) { return c === cardinal; }) );
63
}
64