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.

js/directive.screen.js   A
last analyzed

Complexity

Total Complexity 17
Complexity/F 1.89

Size

Lines of Code 79
Function Count 9

Duplication

Duplicated Lines 79
Ratio 100 %

Importance

Changes 0
Metric Value
eloc 45
dl 79
loc 79
rs 10
c 0
b 0
f 0
wmc 17
mnd 8
bc 8
fnc 9
bpm 0.8888
cpm 1.8888
noi 5

4 Functions

Rating   Name   Duplication   Size   Complexity  
A directive.screen.js ➔ templateUrlFunction 13 13 3
A directive.screen.js ➔ templateFunction 6 6 1
C directive.screen.js ➔ compile 33 33 9
A directive.screen.js ➔ ScreenConstructor 9 9 4

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
28
    	templateURL = $rootScope.screenTemplate + programId.toLowerCase() + ".html";
29
30
    	return templateURL;
31
    }
32
    function templateFunction(tElement, tAttrs){
33
        var template = "" +
34
            "<div ng-include='screenURL'></div>";
35
36
        return template;
37
    }
38
39
	return {
40
        require: ['?editbox', '?pageview', '^ngModel'],
41
		restrict: 'E',
42
		transclude: true,
43
		scope: true,
44
45
		controller: ScreenConstructor,
46
		controllerAs: 'screenCtrl',
47
48
		// bindToController: {
49
		// 	ngModel: '=',
50
		// },
51
//		templateUrl : templateUrlFunction,
52
        template: templateFunction,
53
		compile: function compile(tElement, tAttrs, transclude) {
54
		    return {
55
		        pre: function preLink(scope, iElement, iAttrs, controller) {
56
                    if(Core.GetConfig().debugLog.DirectiveFlow)
57
                        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...
58
                    
59
                    transclude(scope, function(clone, scope) {
60
                        var element = angular.element(iElement);
61
                        var programId = "";
62
63
                        // find the attr programId
64
                        var isProgramIdFound = false;
65
                        if(typeof(iAttrs.programId) != undefined){
66
                            if(iAttrs.programId != null && iAttrs.programId !=""){
67
                                isProgramIdFound = true;
68
                            }
69
                        }
70
                        // assign parent programId if programId attribute not found
71
                        if(isProgramIdFound){
72
                            programId = iAttrs.programId;
73
                        }
74
                        else
75
                            programId = scope.$parent.programId.toLowerCase();
76
77
                        scope.screenURL = $rootScope.screenTemplate + programId.toLowerCase() + ".html";
78
                    });
79
		        },
80
		        post: function postLink(scope, iElement, iAttrs, controller) {
81
                    if(Core.GetConfig().debugLog.DirectiveFlow)
82
                        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...
83
		        }
84
		    }
85
		},
86
	};
87
}]);