File Range.js
has 530 lines of code (exceeds 250 allowed). Consider refactoring. Open
var util = require('../util');
var moment = require('../module/moment');
var Component = require('./component/Component');
var DateUtil = require('./DateUtil');
Function _applyRange
has a Cognitive Complexity of 53 (exceeds 5 allowed). Consider refactoring. Open
Range.prototype._applyRange = function(start, end) {
var newStart = (start != null) ? util.convert(start, 'Date').valueOf() : this.start,
newEnd = (end != null) ? util.convert(end, 'Date').valueOf() : this.end,
max = (this.options.max != null) ? util.convert(this.options.max, 'Date').valueOf() : null,
min = (this.options.min != null) ? util.convert(this.options.min, 'Date').valueOf() : null,
- 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 setRange
has a Cognitive Complexity of 53 (exceeds 5 allowed). Consider refactoring. Open
Range.prototype.setRange = function(start, end, options, callback, frameCallback) {
if (!options) {
options = {};
}
if (options.byUser !== true) {
- 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 _applyRange
has 81 lines of code (exceeds 25 allowed). Consider refactoring. Open
Range.prototype._applyRange = function(start, end) {
var newStart = (start != null) ? util.convert(start, 'Date').valueOf() : this.start,
newEnd = (end != null) ? util.convert(end, 'Date').valueOf() : this.end,
max = (this.options.max != null) ? util.convert(this.options.max, 'Date').valueOf() : null,
min = (this.options.min != null) ? util.convert(this.options.min, 'Date').valueOf() : null,
Function setRange
has 75 lines of code (exceeds 25 allowed). Consider refactoring. Open
Range.prototype.setRange = function(start, end, options, callback, frameCallback) {
if (!options) {
options = {};
}
if (options.byUser !== true) {
Function _onMouseWheel
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
Range.prototype._onMouseWheel = function(event) {
// retrieve delta
var delta = 0;
if (event.wheelDelta) { /* IE/Opera. */
delta = event.wheelDelta / 120;
- 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 Range
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
function Range(body, options) {
var now = moment().hours(0).minutes(0).seconds(0).milliseconds(0);
var start = now.clone().add(-3, 'days').valueOf();
var end = now.clone().add(3, 'days').valueOf();
this.millisecondsPerPixelCache = undefined;
Function _onDrag
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
Range.prototype._onDrag = function (event) {
if (!event) return;
if (!this.props.touch.dragging) return;
Consider simplifying this complex logical expression. Open
if (!((newStart >= this.start && newStart <= this.end) || (newEnd >= this.start && newEnd <= this.end)) &&
!((this.start >= newStart && this.start <= newEnd) || (this.end >= newStart && this.end <= newEnd) )) {
this.body.emitter.emit('checkRangedItems');
}
Function _onPinch
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
Range.prototype._onPinch = function (event) {
// only allow zooming when configured as zoomable and moveable
if (!(this.options.zoomable && this.options.moveable)) return;
// Disable the browser default handling of this event.
Function _onDrag
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
Range.prototype._onDrag = function (event) {
if (!event) return;
if (!this.props.touch.dragging) 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 next
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
var next = function () {
if (!me.props.touch.dragging) {
var now = new Date().valueOf();
var time = now - initTime;
var ease = easingFunction(time / duration);
Function _onMouseWheel
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Range.prototype._onMouseWheel = function(event) {
// retrieve delta
var delta = 0;
if (event.wheelDelta) { /* IE/Opera. */
delta = event.wheelDelta / 120;
Avoid deeply nested control flow statements. Open
if (callback) { return callback() }
Function setRange
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Range.prototype.setRange = function(start, end, options, callback, frameCallback) {
Function setOptions
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
Range.prototype.setOptions = function (options) {
if (options) {
// copy the options that we know
var fields = [
'animation', 'direction', 'min', 'max', 'zoomMin', 'zoomMax', 'moveable', 'zoomable',
- 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
return;
TODO found Open
// TODO: reckon with min and max range
- Exclude checks
TODO found Open
// TODO: this may be redundant in hammerjs2
- Exclude checks
TODO found Open
// TODO: this may be redundant in hammerjs2
- Exclude checks