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
Branch master (b17032)
by Keith
68:36
created

doc/v3/js/controller/home.js   A

Complexity

Total Complexity 31
Complexity/F 1.15

Size

Lines of Code 169
Function Count 27

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 112
dl 0
loc 169
rs 9.92
c 0
b 0
f 0
wmc 31
mnd 4
bc 4
fnc 27
bpm 0.1481
cpm 1.148
noi 4

4 Functions

Rating   Name   Duplication   Size   Complexity  
A home.js ➔ myError 0 3 1
A home.js ➔ mySuccess 0 12 5
A home.js ➔ start_milestones 0 24 2
A home.js ➔ createCountUpOptions 0 9 2
1
"use strict";
2
3
app.controller('homeController', ['$scope', '$q', '$http', '$interval', '$rootScope', function ($scope, $q, $http, $interval, $rootScope) {
4
    var options = createCountUpOptions();
0 ignored issues
show
Unused Code introduced by
The variable options seems to be never used. Consider removing it.
Loading history...
5
		
6
	$scope.start_milestones = function(){
7
        $scope.milstones_interval = $interval(function(){
8
            start_milestones($scope.stack);
9
        }, 7000)
10
	}
11
	
12
	// cancel $interval on leaving ui-state?
13
	// https://stackoverflow.com/questions/30938963/how-to-stop-interval-on-leaving-ui-state
14
	$scope.$on("$destroy",function(){
15
		if (angular.isDefined($scope.milstones_interval)) {
16
			$interval.cancel($scope.milstones_interval);
17
		}
18
	});
19
	
20
	$scope.get_milestones_information = function(){
21
		$scope.initial_variable();
22
	
23
		var getPrjectInfoResule = $scope.get_project_info();
24
		getPrjectInfoResule.then(function(infoObj) {
25
			$scope.stack.push(infoObj);
26
		}, function(reason) {
27
		});
28
		
29
		var getCommitInfoResule = $scope.get_github_commit_info();
30
		getCommitInfoResule.then(function(infoObjList) {
31
			//$scope.stack.push(infoObj);
32
			$scope.stack = $scope.stack.concat(infoObjList)
33
		}, function(reason) {
34
		});
35
		
36
		var getReleaseInfoResule = $scope.get_github_release_info();
37
		getReleaseInfoResule.then(function(infoObjList) {
38
			$scope.stack = $scope.stack.concat(infoObjList)
39
		}, function(reason) {
40
		});
41
		
42
		$q.all([getPrjectInfoResule, getCommitInfoResule, getReleaseInfoResule]).then(function() {
43
            start_milestones($scope.stack);
44
			$scope.start_milestones();
45
		});
46
	}
47
	$scope.get_project_info = function(){
48
		var options = createCountUpOptions();
49
		var promise = $q(function(resolve, reject) {
50
			var array = {text:"was borned in", amt:"2015", options};
51
			if(true){
52
				resolve(array);
53
			}else{
54
				reject(new Error('get project info error'));
55
			}
56
			
57
		});
58
		
59
		return promise;
60
	}
61
	$scope.get_github_commit_info = function(){
62
		var options = createCountUpOptions();
63
		var arrayList = [];
64
        
65
		var promise = $q(function(resolve, reject) {
66
			var array = {text:"commits", amt:"10101", options};
0 ignored issues
show
Unused Code introduced by
The variable array seems to be never used. Consider removing it.
Loading history...
67
			
68
			$http({
69
				method : "GET",
70
				url : "https://api.github.com/repos/Otaku-Projects/AngularJS-CRUD-PHP/stats/contributors"
71
			}).then(function mySuccess(response) {
72
				var returnData = response.data;
73
				var totalContributorsCount = 0;
74
				var totalCommitsCount = 0;
75
				returnData.forEach(function(contributorsObj){
76
					totalContributorsCount+=1;
77
					totalCommitsCount+=contributorsObj.total;
78
				});
79
				arrayList.push({text:"Contributor(s)", amt:totalContributorsCount, options});
80
				arrayList.push({text:"Commits", amt:totalCommitsCount, options});
81
				resolve(arrayList);
82
			}, function myError(response) {
83
				reject(new Error('get project commit info error'));
84
			});
85
			
86
		});
87
		
88
		return promise;
89
	}
90
	$scope.get_github_release_info = function(){
91
		var options = createCountUpOptions();
92
		var arrayList = [];
93
        
94
		var promise = $q(function(resolve, reject) {
95
			var array = {text:"commits", amt:"10101", options};
0 ignored issues
show
Unused Code introduced by
The variable array seems to be never used. Consider removing it.
Loading history...
96
			
97
			$http({
98
				method : "GET",
99
				url : "https://api.github.com/repos/Otaku-Projects/AngularJS-CRUD-PHP/releases"
100
			}).then(function mySuccess(response) {
101
				var returnData = response.data;
102
				var totalReleasesCount = 0;
103
				returnData.forEach(function(releasesObj){
104
					totalReleasesCount+=1;
105
				});
106
				
107
				if(returnData.length >0){
108
					arrayList.push({text:"Releases Count", amt:totalReleasesCount, options});
109
					
110
					var releasesObj = returnData[0];
111
					
112
					var url = $('<a/>', {
113
						text: releasesObj.tag_name,
114
						href: releasesObj.html_url,
115
						target: "_blanks"
116
					})
117
					var spanEnd = $('<span/>', {
0 ignored issues
show
Unused Code introduced by
The variable spanEnd seems to be never used. Consider removing it.
Loading history...
118
						text: "."
119
					})
120
					$("#latest_release").html('The latest release ver. <i class="fas fa-tag fa-fw"></i> ').append(url);//.append(spanEnd);
121
				}
122
				resolve(arrayList);
123
			}, function myError(response) {
124
				reject(new Error('get project release info error'));
125
			});
126
			
127
		});
128
		
129
		return promise;
130
	}
131
    $scope.initial_variable = function(){
132
        $scope.stack = [];
133
    }
134
    function createCountUpOptions(){
135
		var options = {
136
			startVal: 1,
137
			duration: 1,
138
			useGrouping: false,
139
			separator: ',',
140
		};
141
        return options;
142
    }
143
	function start_milestones(stackObjectList){
144
        $("#milestones").html("");
145
        
146
        var infoObj = stackObjectList.shift();
147
        var elementContent = infoObj.text;
148
        var countUpAmt = infoObj.amt;
149
        var options = infoObj.options;
150
        $("#milestones").html("<div class='animated'>"+elementContent+"</div>");
151
        //$("#milestones div").animateCSS("fadeInUp");
152
        $("#milestones div").addClass("fadeInUp");
153
		
154
		//$("#count_up_amt_container").html('<span id="count_up_amt" style="display:none"></span>');
155
        
156
		if(!$scope.countUp){
157
			$scope.countUp = new CountUp("count_up_amt", 0, options);
158
			$scope.countUp.start();
159
			$("#count_up_amt").hide();
160
		}
161
		$("#count_up_amt").show();
162
		$scope.countUp.update(countUpAmt);
163
		
164
        
165
        stackObjectList.push(infoObj);
166
	}
167
	
168
	$scope.get_milestones_information();
169
}]);
170
171