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.
Passed
Push — master ( 4f400b...27c2a7 )
by Keith
80:08
created

demo/v2/js/controller/rc-55-entry-third-party.js   A

Complexity

Total Complexity 31
Complexity/F 1.41

Size

Lines of Code 159
Function Count 22

Duplication

Duplicated Lines 159
Ratio 100 %

Importance

Changes 0
Metric Value
eloc 91
dl 159
loc 159
rs 9.92
c 0
b 0
f 0
wmc 31
mnd 9
bc 9
fnc 22
bpm 0.4089
cpm 1.409
noi 4

3 Functions

Rating   Name   Duplication   Size   Complexity  
A rc-55-entry-third-party.js ➔ Initialize 6 6 2
F rc-55-entry-third-party.js ➔ ExtractComputerLang 19 19 16
A rc-55-entry-third-party.js ➔ ExtractThirdPartyLang 20 20 5

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 View Code Duplication
"use strict";
2
app.controller('thirdPartyEntry2EntryController', ['$scope', '$state', 'Security', function ($scope, $state, Security, $rootScope) {
3
	$scope.directiveScopeDict = {};
4
    $scope.directiveCtrlDict = {};
5
	
6
	$scope.thirdPartyID = $state.params.thirdPartyID;
7
	
8
    function Initialize(){
9
        var processForm = {};
10
11
        $scope.processForm = processForm;
12
		$scope.processForm.Record = {};
13
    }
14
    Initialize();
15
	
16
	$scope.BackToParentState = function(){
17
		$state.go('^');
18
	}
19
20
    $scope.EventListener = function(scope, iElement, iAttrs, controller){
21
		var tagName = iElement[0].tagName.toLowerCase();
22
		var prgmID = scope.programId;
23
		var scopeID = scope.$id;
0 ignored issues
show
Unused Code introduced by
The variable scopeID seems to be never used. Consider removing it.
Loading history...
24
		var hashID = tagName + '_' + prgmID;
25
26
		if($scope.directiveScopeDict[hashID] == null || typeof($scope.directiveScopeDict[hashID]) == "undefined"){
27
			$scope.directiveScopeDict[hashID] = scope;
28
			$scope.directiveCtrlDict[hashID] = controller;
29
30
		}
31
		
32
        iElement.ready(function() {
33
			if(tagName=="process"){
34
				$scope.GetThirdPartyRecord();
35
			}
36
        })
37
    }
38
	
39
	$scope.GetThirdPartyRecord = function(){
40
		var name = "process_dp54tp"
41
		$scope.directiveCtrlDict[name].ngModel.Record.ThirdPartyID = $scope.thirdPartyID;
42
		$scope.directiveCtrlDict[name].ngModel.InquiryCriteria.Action = "amend";
43
	
44
		$scope.directiveScopeDict[name].InquiryData();
45
	}
46
47
    $scope.SetDefaultValue = function(scope, iElement, iAttrs, controller){
48
		
49
    }
50
51
    $scope.StatusChange = function(fieldName, newValue, newObj, scope, iElement, iAttrs, controller){
52
    }
53
54
    $scope.ValidateBuffer = function(scope, iElement, iAttrs, controller){
55
        return true;
56
    }
57
	$scope.CustomInquiryDataResult = function(responseObj, httpStatusCode, scope, iElement, attrs, ctrl){
58
		if(responseObj.data.thirdParty.num_rows){
59
			ctrl.ThirdParty = responseObj.data.thirdParty.data[0];
60
			
61
			ctrl.ngModel.ProcessRecord = ctrl.ThirdParty;
62
			ctrl.ngModel.ProcessCriteria.ThirdPartyLang = [];
63
			
64
			if(responseObj.data.computerLanguage.num_rows){
65
				ctrl.ThirdPartyLang = responseObj.data.thirdPartyLang.data;
66
				ctrl.ComputerLanguage = ExtractComputerLang(responseObj.data.computerLanguage.data, responseObj.data.thirdPartyLang.data);
67
				ctrl.ngModel.ProcessCriteria.ThirdPartyLang = ExtractThirdPartyLang(responseObj.data.computerLanguage.data, responseObj.data.thirdPartyLang.data);
68
			}
69
		}
70
		
71
	}
72
	
73
	function ExtractComputerLang(comLangRows, thirdPartyLang){
74
		var name = "process_dp54tp";
75
		var ctrl = $scope.directiveCtrlDict[name];
0 ignored issues
show
Unused Code introduced by
The variable ctrl seems to be never used. Consider removing it.
Loading history...
76
		
77
		var langArray = comLangRows.slice();
78
		
79
		// use forEach() will actual update the array
80
		langArray.forEach(comLangObj => {
81
			var thirdPartLangObj = thirdPartyLang.filter(x => x.LanguageID === comLangObj.LanguageID);
82
			
83
			// if exist in thirdPartyLang set true
84
			if(Object.keys(thirdPartLangObj).length === 0){
85
				comLangObj.isSelect = false;
86
			}else{
87
				comLangObj.isSelect = true;
88
			}
89
		});
90
		return langArray;
91
	}
92
	
93
	function ExtractThirdPartyLang(comLangRows, thirdPartyLang){
94
		var name = "process_dp54tp";
95
		var ctrl = $scope.directiveCtrlDict[name];
0 ignored issues
show
Unused Code introduced by
The variable ctrl seems to be never used. Consider removing it.
Loading history...
96
		
97
		var langArray = comLangRows.slice();
98
		
99
		// use forEach() will actual update the array
100
		langArray.forEach(comLangObj => {
101
			var thirdPartLangObj = thirdPartyLang.filter(x => x.LanguageID === comLangObj.LanguageID);
102
			
103
			// if exist in thirdPartyLang, assign to processCriteria
104
			if(Object.keys(thirdPartLangObj).length === 0){
0 ignored issues
show
Comprehensibility Documentation Best Practice introduced by
This code block is empty. Consider removing it or adding a comment to explain.
Loading history...
105
			}else{
106
				comLangObj.isSelect = true;
107
				//ctrl.ngModel.ProcessCriteria.ThirdPartyLang.push(comLangObj);
108
			}
109
		});
110
		var selectedLangArray = langArray.filter(x => x.isSelect == true);
111
		return selectedLangArray;
112
	}
113
	
114
	$scope.ToggleThirdPartyLang = function(comLangRow){
115
		var name = "process_dp54tp";
116
		var ctrl = $scope.directiveCtrlDict[name];
117
		var thirdPartyLangArray = ctrl.ngModel.ProcessCriteria.ThirdPartyLang;
118
		comLangRow.isSelect = !comLangRow.isSelect;
119
		
120
		// remove from ProcessCriteria
121
		var selectedLangArray = thirdPartyLangArray.filter(x => x.LanguageID != comLangRow.LanguageID);
122
		
123
		// add to ProcessCriteria
124
		if(comLangRow.isSelect){
125
			selectedLangArray.push(comLangRow);
126
		}
127
		
128
		ctrl.ngModel.ProcessCriteria.ThirdPartyLang = selectedLangArray;
129
	}
130
	
131
	$scope.UpdateData = function(){
132
		var name = "process_dp54tp";
133
		var scope = $scope.directiveScopeDict[name];
134
		var ctrl = $scope.directiveCtrlDict[name];
135
		ctrl.ngModel.ProcessCriteria.Editmode = "amend";
136
		scope.SubmitData();
137
	}
138
	
139
	$scope.DeleteData = function(){
140
		var name = "process_dp54tp";
141
		var scope = $scope.directiveScopeDict[name];
142
		var ctrl = $scope.directiveCtrlDict[name];
143
		ctrl.ngModel.ProcessCriteria.Editmode = "delete";
144
		
145
		scope.SubmitData();
146
	}
147
	
148
	$scope.CustomSubmitDataResult = function(responseObj, httpStatusCode, scope, iElement, attrs, ctrl){
149
		//$scope.GetThirdPartyRecord();
150
		var editmode = ctrl.ngModel.ProcessCriteria.Editmode;
151
		
152
		if(editmode == "delete"){
153
			if(responseObj.status == "success"){
154
				$scope.BackToParentState();
155
			}
156
		}
157
	}
158
	
159
}]);
160