Completed
Push — master ( 5ddb56...074734 )
by Daniel
01:37
created

module.exports.buildAuthenticationHeader   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
c 1
b 0
f 0
nc 3
dl 0
loc 7
rs 9.4285
nop 1
1
2
module.exports = {
3
    buildAuthenticationHeader: function (inAuthenticationArray) {
4
        if (inAuthenticationArray.type === 'Addin') {
5
            return inAuthenticationArray.credentials_Addin;
6
        } else if (inAuthenticationArray.type === 'SAML') {
0 ignored issues
show
Complexity Best Practice introduced by
There is no return statement if inAuthenticationArray.type === "SAML" is false. Are you sure this is correct? If so, consider adding return; explicitly.

This check looks for functions where a return statement is found in some execution paths, but not in all.

Consider this little piece of code

function isBig(a) {
    if (a > 5000) {
        return "yes";
    }
}

console.log(isBig(5001)); //returns yes
console.log(isBig(42)); //returns undefined

The function isBig will only return a specific value when its parameter is bigger than 5000. In any other case, it will implicitly return undefined.

This behaviour may not be what you had intended. In any case, you can add a return undefined to the other execution path to make the return value explicit.

Loading history...
7
            return inAuthenticationArray.credentials_SAML;
8
        }
9
    },
10
    buildCurrentListAttributeValues: function (inObjectListsConfiguredAttributes, inCurrentList) {
11
        var crtListAttributes = [];
12
        Object.keys(inObjectListsConfiguredAttributes).map(function (itemList) {
13
            if (itemList.substring(0, 4) === 'Date') {
14
                if (inCurrentList[inObjectListsConfiguredAttributes[itemList]] === null) {
15
                    crtListAttributes[itemList] = '';
16
                } else {
17
                    crtListAttributes[itemList] = inCurrentList[inObjectListsConfiguredAttributes[itemList]].replace('T', ' ').replace('Z', '');
18
                }
19
            } else {
20
                crtListAttributes[itemList] = inCurrentList[inObjectListsConfiguredAttributes[itemList]];
21
            }
22
        });
23
        return crtListAttributes;
24
    },
25
    buildRequestQuery: function (targetSharePointURL, crtListName, queryType, headerOptions, maxRecords) {
26
        var queryPrefix = '';
27
        switch (queryType) {
28
            case 'Fields':
29
                queryPrefix = '_api/Web/lists/GetByTitle(\'' + crtListName + '\')/' + queryType;
30
                break;
31
            case 'Items':
32
                queryPrefix = '_api/Web/lists/GetByTitle(\'' + crtListName + '\')/' + queryType + '?$top=' + maxRecords;
33
                break;
34
            default:
35
                queryPrefix = '_api/Web/' + queryType;
36
                break;
37
        }
38
        return {
39
            url: targetSharePointURL + queryPrefix,
40
            headers: headerOptions,
41
            json: true
42
        };
43
    },
44
    decideBlackListWhiteList: function (inDecisionValue, inEvaluatedValueForBlackList, inBlackListArray, inEvaluatedValueForWhiteList, inWhiteListArray, inValueToEvaluate) {
45
        if ((inDecisionValue === inEvaluatedValueForBlackList) && (inBlackListArray.indexOf(inValueToEvaluate) === -1)) {
46
            return true;
47
        }
48
        if ((inDecisionValue === inEvaluatedValueForWhiteList) && (inWhiteListArray.indexOf(inValueToEvaluate) > -1)) {
49
            return true;
50
        }
51
        return false;
52
    }
53
};
54