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.

archive/2.8.x/js/directive.screen.js   A
last analyzed

Complexity

Total Complexity 21
Complexity/F 2.33

Size

Lines of Code 93
Function Count 9

Duplication

Duplicated Lines 93
Ratio 100 %

Importance

Changes 0
Metric Value
eloc 53
dl 93
loc 93
rs 10
c 0
b 0
f 0
wmc 21
mnd 12
bc 12
fnc 9
bpm 1.3333
cpm 2.3333
noi 6

4 Functions

Rating   Name   Duplication   Size   Complexity  
A directive.screen.js ➔ ScreenConstructor 9 9 4
A directive.screen.js ➔ templateUrlFunction 18 18 5
C directive.screen.js ➔ compile 42 42 11
A directive.screen.js ➔ templateFunction 6 6 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
2
/**
3
 * <screen> element to display a share html
4
 * <screen
5
    program-id=""
6
    >
7
 * @param {String} program-id - optional to define, default as parent scope.programId
8
 */
9 View Code Duplication
app.directive('screen', ['Core', 'Security', '$rootScope', '$timeout', function(Core, Security, $rootScope, $timeout) {
10
    function ScreenConstructor($scope, $element, $attrs) {
11
		if(Core.GetConfig().debugLog.DirectiveFlow)
12
            console.log("1 screen - ScreenConstructor()");
0 ignored issues
show
Debugging Code introduced by
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
13
        
14
    	function Initialize() {
0 ignored issues
show
introduced by
The function Initialize does not seem to be used and can be removed.
Loading history...
15
            $scope.screenURL = "";
16
    	}
17
        
18
    }
19
    function templateUrlFunction(tElement, tAttrs) {
0 ignored issues
show
introduced by
The function templateUrlFunction does not seem to be used and can be removed.
Loading history...
20
    	var templateURL = "";
21
    	var programId = "";
22
    	if(typeof(tAttrs.programId) != "undefined"){
23
    		if(tAttrs.programId != ""){
24
    			programId = tAttrs.programId;
25
    		}
26
    	}
27
    	if(typeof(tAttrs.screenId) != "undefined"){
28
    		if(tAttrs.screenId != ""){
29
    			programId = tAttrs.screenId;
30
    		}
31
    	}
32
33
    	templateURL = $rootScope.screenTemplate + programId.toLowerCase() + ".html";
34
35
    	return templateURL;
36
    }
37
    function templateFunction(tElement, tAttrs){
38
        var template = "" +
39
            "<div ng-include='screenURL'></div>";
40
41
        return template;
42
    }
43
44
	return {
45
        require: ['?editbox', '?pageview', '^ngModel'],
46
		restrict: 'E',
47
		transclude: true,
48
		scope: true,
49
50
		controller: ScreenConstructor,
51
		controllerAs: 'screenCtrl',
52
53
		// bindToController: {
54
		// 	ngModel: '=',
55
		// },
56
//		templateUrl : templateUrlFunction,
57
        template: templateFunction,
58
		compile: function compile(tElement, tAttrs, transclude) {
59
		    return {
60
		        pre: function preLink(scope, iElement, iAttrs, controller) {
61
                    if(Core.GetConfig().debugLog.DirectiveFlow)
62
                        console.log("2 screen - ScreenConstructor()");
0 ignored issues
show
Debugging Code introduced by
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
63
                    
64
                    transclude(scope, function(clone, scope) {
65
                        var element = angular.element(iElement);
66
                        var programId = "";
67
68
                        // find the attr programId
69
                        var isProgramIdFound = false;
70
                        if(typeof(iAttrs.programId) != undefined){
71
                            if(iAttrs.programId != null && iAttrs.programId !=""){
72
                                isProgramIdFound = true;
73
								programId = iAttrs.programId;
74
                            }
75
                        }
76
                        if(typeof(iAttrs.screenId) != undefined){
77
                            if(iAttrs.screenId != null && iAttrs.screenId !=""){
78
                                isProgramIdFound = true;
79
								programId = iAttrs.screenId;
80
                            }
81
                        }
82
                        // assign parent programId if programId attribute not found
83
                        if(isProgramIdFound){
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...
84
							
85
                        }
86
                        else{
87
							//console.dir(scope.$parent)
88
                            programId = scope.$parent.programId.toLowerCase();
89
						}
90
91
                        scope.screenURL = $rootScope.screenTemplate + programId.toLowerCase() + ".html";
92
                    });
93
		        },
94
		        post: function postLink(scope, iElement, iAttrs, controller) {
95
                    if(Core.GetConfig().debugLog.DirectiveFlow)
96
                        console.log("3 screen - ScreenConstructor()");
0 ignored issues
show
Debugging Code introduced by
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
97
		        }
98
		    }
99
		},
100
	};
101
}]);