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/install03-release-repository.js   A

Complexity

Total Complexity 16
Complexity/F 1.23

Size

Lines of Code 133
Function Count 13

Duplication

Duplicated Lines 133
Ratio 100 %

Importance

Changes 0
Metric Value
eloc 66
dl 133
loc 133
rs 10
c 0
b 0
f 0
wmc 16
mnd 3
bc 3
fnc 13
bpm 0.2307
cpm 1.2306
noi 3

3 Functions

Rating   Name   Duplication   Size   Complexity  
A install03-release-repository.js ➔ start_milestones 20 20 3
D install03-release-repository.js ➔ mySuccess 12 12 12
A install03-release-repository.js ➔ myError 3 3 1

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
3
app.controller('install03Controller', ['$scope', '$q', '$http', '$interval', '$rootScope', '$stateParams', function ($scope, $q, $http, $interval, $rootScope, $stateParams) {
4
	$(".release_info").hide();
5
	
6
	$scope.releaseID = $stateParams.releaseID;
7
	
8
	$scope.mergeContent = function(){
9
		if($scope.latestVersion != null){
10
			var latestRelease = $scope.latestVersion;
11
			var tag_name = latestRelease.tag_name;
12
			var releaseZipDownloadURL = latestRelease.zipball_url;
13
			var releaseTarDownloadURL = latestRelease.tarball_url;
14
			
15
			$("#latest_release_zip").text(tag_name).parent("a").attr("href", releaseZipDownloadURL);
16
			$("#latest_release_tar").text(tag_name).parent("a").attr("href", releaseTarDownloadURL);
17
			
18
			$(".loading_info").hide();
19
			
20
			// convert github release body content from Markdown to HTML
21
			var converter = new showdown.Converter();
22
			//converter.setOption('backslashEscapesHTMLTags', 'true');
23
			var markdown = latestRelease.body;
24
			
25
			/*
26
			// replace \< to <, \> to >
27
			var findStartTag = "\<";
28
			var regularExpressStart = new RegExp(findStartTag, 'g');
29
			var findEndTag = "\>";
30
			var regularExpressEnd = new RegExp(findEndTag, 'g');
31
			markdown = markdown.replace(regularExpressStart, '<');
32
			markdown = markdown.replace(regularExpressEnd, '>');
33
			*/
34
			
35
			// remove all Backslash
36
			// 92 is Backslash
37
			var findBackslash = String.fromCharCode(92)+String.fromCharCode(92); 
38
			var regularExpressBackslash = new RegExp(findBackslash, 'g');
39
			markdown = markdown.replace(regularExpressBackslash, '');
40
			
41
			// encode to html entities
42
			// https://stackoverflow.com/questions/18749591/encode-html-entities-in-javascript
43
			var encodedStr = markdown.replace(/[\u00A0-\u9999<>\&]/gim, function(i) {
44
			   return '&#'+i.charCodeAt(0)+';';
45
			});
46
			
47
			var html = converter.makeHtml(encodedStr);
48
			
49
			latestRelease.html = html;
50
			
51
			/*
52
			console.dir(latestRelease)
53
			console.dir(converter)
54
			console.dir(markdown)
55
			console.dir(encodedStr)
56
			console.dir(html)
57
			console.dir(latestRelease)
58
			*/
59
			
60
			$(".release_info").show();
61
		}
62
	}
63
	
64
	$scope.get_information = function(){
65
		$scope.initial_variable();
66
		
67
		var getReleaseInfoResule = $scope.get_github_release_info($scope.releaseID);
68
		getReleaseInfoResule.then(function(infoObjList) {
69
			if(infoObjList.length > 0){
70
				$scope.latestVersion = infoObjList[0];
71
			}
72
		}, function(reason) {
73
		});
74
		
75
		$q.all([getReleaseInfoResule]).then(function() {
76
			$scope.mergeContent();
77
		});
78
	}
79
	$scope.get_github_release_info = function(releaseID){
80
		var arrayList = [];
81
        
82
		var promise = $q(function(resolve, reject) {
83
			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...
84
			
85
			$http({
86
				method : "GET",
87
				//url : "https://api.github.com/repos/Otaku-Projects/AngularJS-CRUD-PHP/releases/"+releaseID
88
				url : "https://api.github.com/repositories/27926807/releases/"+releaseID
89
			}).then(function mySuccess(response) {
90
				var returnData = response.data;
91
				var totalReleasesCount = 0;
0 ignored issues
show
Unused Code introduced by
The variable totalReleasesCount seems to be never used. Consider removing it.
Loading history...
92
				/*
93
				returnData.forEach(function(releasesObj){
94
					arrayList.push(releasesObj);
95
				});
96
				*/
97
				arrayList.push(returnData);
98
				
99
				resolve(arrayList);
100
			}, function myError(response) {
101
				reject(new Error('get project release info error'));
102
			});
103
			
104
		});
105
		
106
		return promise;
107
	}
108
    $scope.initial_variable = function(){
109
		$scope.latestVersion = null;
110
    }
111
	function start_milestones(stackObjectList){
0 ignored issues
show
introduced by
The function start_milestones does not seem to be used and can be removed.
Loading history...
112
        $("#milestones").html("");
113
        
114
        var infoObj = stackObjectList.shift();
115
        var elementContent = infoObj.text;
116
        var countUpAmt = infoObj.amt;
117
        var options = infoObj.options;
118
        $("#milestones").html("<div class='animated'>"+elementContent+"</div>");
119
        $("#milestones div").addClass("fadeInUp");
120
        
121
		if(!$scope.countUp){
122
			$scope.countUp = new CountUp("count_up_amt", 0, options);
123
			$scope.countUp.start();
124
			$("#count_up_amt").hide();
125
		}
126
		$("#count_up_amt").show();
127
		$scope.countUp.update(countUpAmt);
128
		
129
        stackObjectList.push(infoObj);
130
	}
131
	
132
	$scope.get_information();
133
}]);