Function humanize
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
humanize : function(str, shortened) {
var parts = str.split('T')[0].split('-');
var humDate = new Date();
humDate.setFullYear(Number(parts[0]));
Function humanizeBytes
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
humanizeBytes : function(filesize) {
if (filesize === null || filesize <= 0 || filesize === "") { return "—"; }
if (filesize >= 1073741824) {
filesize = Utils.number_format(filesize / 1073741824, 2, '.', '') + ' Gb';
} else {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function distance_of_time_in_words
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
distance_of_time_in_words: function(to, from) {
var distance_in_seconds = ((to - from) / 1000);
var distance_in_minutes = Math.floor(distance_in_seconds / 60);
if (distance_in_minutes <= 0) { return 'less than a minute ago'; }
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function number_format
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
number_format : function( number, decimals, dec_point, thousands_sep ) {
var n = number, c = isNaN(decimals = Math.abs(decimals)) ? 2 : decimals;
var d = dec_point === undefined ? "," : dec_point;
var t = thousands_sep === undefined ? "." : thousands_sep, s = n < 0 ? "-" : "";
var i = parseInt(n = Math.abs(+n || 0).toFixed(c), 10) + "", j = (j = i.length) > 3 ? j % 3 : 0;
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Avoid too many return
statements within this function. Open
if (distance_in_minutes < 1051199) { return 'about 1 year ago'; }
Avoid too many return
statements within this function. Open
if (distance_in_minutes < 43200) { return Math.floor(distance_in_minutes / 1440) + ' days ago'; }
Avoid too many return
statements within this function. Open
return 'over ' + Math.floor(distance_in_minutes / 525960) + ' years ago';
Avoid too many return
statements within this function. Open
if (distance_in_minutes < 1440) { return Math.floor(distance_in_minutes / 60) + ' hours ago'; }
Avoid too many return
statements within this function. Open
if (distance_in_minutes < 525960) { return Math.floor(distance_in_minutes / 43200) + ' months ago'; }
Avoid too many return
statements within this function. Open
if (distance_in_minutes < 86400) { return '1 month ago'; }
Avoid too many return
statements within this function. Open
if (distance_in_minutes < 2880) { return '1 day ago'; }