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/common.js   A
last analyzed

Complexity

Total Complexity 17
Complexity/F 2.13

Size

Lines of Code 84
Function Count 8

Duplication

Duplicated Lines 84
Ratio 100 %

Importance

Changes 0
Metric Value
eloc 60
dl 84
loc 84
rs 10
c 0
b 0
f 0
wmc 17
mnd 9
bc 9
fnc 8
bpm 1.125
cpm 2.125
noi 5

1 Function

Rating   Name   Duplication   Size   Complexity  
F common.js ➔ getFunctionName 6 6 17

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
// JavaScript Document
2 View Code Duplication
"use strict";
3
4
// https://stackoverflow.com/questions/3280323/get-week-of-the-month
5
// return integer means the date in the which week of month
6
// 6 means "Last", not "Sixth"
7
// pass true to return the actual week of month
8
Date.prototype.getWeekOfMonth = function(exact) {
0 ignored issues
show
Compatibility Best Practice introduced by
You are extending the built-in type Date. This may have unintended consequences on other objects using this built-in type. Consider subclassing instead.
Loading history...
9
    var month = this.getMonth()
10
        , year = this.getFullYear()
11
        , firstWeekday = new Date(year, month, 1).getDay()
12
        , lastDateOfMonth = new Date(year, month + 1, 0).getDate()
13
        , offsetDate = this.getDate() + firstWeekday - 1
14
        , index = 0 // start index at 0 or 1, your choice
15
        , weeksInMonth = index + Math.ceil((lastDateOfMonth + firstWeekday - 7) / 7)
16
        , week = index + Math.floor(offsetDate / 7)
17
    ;
18
    if (exact || week < 2 + index) return week;
19
    return week === weeksInMonth ? index + 5 : week;
20
};
21
22
// https://stackoverflow.com/questions/7423801/given-a-weekday-and-the-day-of-the-month-it-occurs-can-i-get-its-ordinal-positi
23
// https://stackoverflow.com/questions/28162140/how-to-find-ordinal-position-of-any-given-weekday-in-javascript/28163096#28163096
24
Date.prototype.nthofMonthStr = function(){
25
    var today= this.getDate(),m=this.getMonth(),
26
    day= ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday',
27
    'Friday', 'Saturday'][this.getDay()],
28
    month= ['January', 'February', 'March', 'April', 'May', 'June',
29
    'July', 'August', 'September', 'October', 'November', 'December'][m];
30
    return [(m+1)+'-'+today,'the', (Math.ceil((today)/7)).nthStr(), day, 'of', month, 'in', this.getFullYear()].join(' ');
31
}
32
Date.prototype.nthofMonth = function(){
33
    var today= this.getDate(),m=this.getMonth(),
34
    day= ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday',
0 ignored issues
show
Unused Code introduced by
The variable day seems to be never used. Consider removing it.
Loading history...
35
    'Friday', 'Saturday'][this.getDay()],
36
    month= ['January', 'February', 'March', 'April', 'May', 'June',
0 ignored issues
show
Unused Code introduced by
The variable month seems to be never used. Consider removing it.
Loading history...
37
    'July', 'August', 'September', 'October', 'November', 'December'][m];
38
    return (Math.ceil((today)/7));
39
}
40
Number.prototype.nthStr = function(){
0 ignored issues
show
Compatibility Best Practice introduced by
You are extending the built-in type Number. This may have unintended consequences on other objects using this built-in type. Consider subclassing instead.
Loading history...
41
    var n= Math.round(this), t= Math.abs(n%100), i= t%10;
42
    if(i<4 && (t<4 || t> 20)){
43
        switch(i){
44
            case 1:return n+'st';
45
            case 2:return n+'nd';
46
            case 3:return n+'rd';
47
        }
48
    }
49
    return n+'th';
50
}
51
52
Object.defineProperty(Object.prototype, 'IsEmptyObject', {
53
  value : function() {
54
		var obj = this;
55
		for (var prop in obj) {
56
			if (obj.hasOwnProperty(prop))
57
				return false;
58
		}
59
	
60
		return true;
61
	},
62
  enumerable : false
63
});
64
String.prototype.IsNullOrEmpty = function(){
0 ignored issues
show
Compatibility Best Practice introduced by
You are extending the built-in type String. This may have unintended consequences on other objects using this built-in type. Consider subclassing instead.
Loading history...
65
	  	var curStr = this;
66
		var isNullOrEmpty = false;
67
		if(typeof(curStr) == "undefined")
68
			isNullOrEmpty = true;
69
		else if(curStr == null)
70
			isNullOrEmpty = true;
71
		else if(curStr == "")
72
			isNullOrEmpty = true;
73
		return isNullOrEmpty;
74
}
75
String.prototype.ReplaceAll = function(search, replacement) {
76
    var target = this;
77
    return target.replace(new RegExp(search, 'g'), replacement);
78
};
79
80
function getFunctionName(fun) {
81
  var ret = fun.toString();
82
  ret = ret.substr('function '.length);
83
  ret = ret.substr(0, ret.indexOf('('));
84
  return ret;
85
}