File TimeStep.js
has 508 lines of code (exceeds 250 allowed). Consider refactoring. Open
var moment = require('../module/moment');
var DateUtil = require('./DateUtil');
var util = require('../util');
/**
Function next
has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring. Open
TimeStep.prototype.next = function() {
var prev = this.current.valueOf();
// Two cases, needed to prevent issues with switching daylight savings
// (end of March and end of October)
- 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 setMinimumStep
has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring. Open
TimeStep.prototype.setMinimumStep = function(minimumStep) {
if (minimumStep == undefined) {
return;
}
- 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 snap
has 102 lines of code (exceeds 25 allowed). Consider refactoring. Open
TimeStep.snap = function(date, scale, step) {
var clone = moment(date);
if (scale == 'year') {
var year = clone.year() + Math.round(clone.month() / 12);
Function snap
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
TimeStep.snap = function(date, scale, step) {
var clone = moment(date);
if (scale == 'year') {
var year = clone.year() + Math.round(clone.month() / 12);
- 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 getClassName
has 79 lines of code (exceeds 25 allowed). Consider refactoring. Open
TimeStep.prototype.getClassName = function() {
var _moment = this.moment;
var m = this.moment(this.current);
var current = m.locale ? m.locale('en') : m.lang('en'); // old versions of moment have .lang() function
var step = this.step;
Function getClassName
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
TimeStep.prototype.getClassName = function() {
var _moment = this.moment;
var m = this.moment(this.current);
var current = m.locale ? m.locale('en') : m.lang('en'); // old versions of moment have .lang() function
var step = this.step;
- 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 isMajor
has 63 lines of code (exceeds 25 allowed). Consider refactoring. Open
TimeStep.prototype.isMajor = function() {
if (this.switchedYear == true) {
switch (this.scale) {
case 'year':
case 'month':
Function next
has 59 lines of code (exceeds 25 allowed). Consider refactoring. Open
TimeStep.prototype.next = function() {
var prev = this.current.valueOf();
// Two cases, needed to prevent issues with switching daylight savings
// (end of March and end of October)
Function setMinimumStep
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
TimeStep.prototype.setMinimumStep = function(minimumStep) {
if (minimumStep == undefined) {
return;
}
Function roundToMinor
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
TimeStep.prototype.roundToMinor = function() {
// round to floor
// to prevent year & month scales rounding down to the first day of week we perform this separately
if (this.scale == 'week') {
this.current.weekday(0);
Function isMajor
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
TimeStep.prototype.isMajor = function() {
if (this.switchedYear == true) {
switch (this.scale) {
case 'year':
case 'month':
- 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 deeply nested control flow statements. Open
else if (scale == 'hour') {
switch (step) {
case 4:
clone.minutes(Math.round(clone.minutes() / 60) * 60); break;
default:
Avoid deeply nested control flow statements. Open
switch (step) {
case 5:
case 2:
clone.hours(Math.round(clone.hours() / 12) * 12); break;
default:
Function getLabelMinor
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
TimeStep.prototype.getLabelMinor = function(date) {
if (date == undefined) {
date = this.current;
}
if (date instanceof Date) {
- 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 TimeStep
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
function TimeStep(start, end, minimumStep, hiddenDates, options) {