File DateTimeInputWidget.js
has 566 lines of code (exceeds 250 allowed). Consider refactoring. Open
( function () {
/**
* @classdesc DateTimeInputWidgets can be used to input a date, a time, or
* a date and time, in either UTC or the user's local timezone.
Function setupFields
has 113 lines of code (exceeds 25 allowed). Consider refactoring. Open
mw.widgets.datetime.DateTimeInputWidget.prototype.setupFields = function () {
var i, $field, spec, placeholder, sz, maxlength,
spanValFunc = function ( v ) {
if ( v === undefined ) {
return this.data( 'mw-widgets-datetime-dateTimeInputWidget-value' );
Function MwWidgetsDatetimeDateTimeInputWidget
has 102 lines of code (exceeds 25 allowed). Consider refactoring. Open
mw.widgets.datetime.DateTimeInputWidget = function MwWidgetsDatetimeDateTimeInputWidget( config ) {
// Configuration initialization
config = $.extend( {
type: 'datetime',
clearable: true,
Function updateFieldsFromValue
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
mw.widgets.datetime.DateTimeInputWidget.prototype.updateFieldsFromValue = function () {
var i, $field, spec, intercalary, sz,
date = this.getValueAsDate();
if ( date === null ) {
Consider simplifying this complex logical expression. Open
if ( date.getTime() < -62167219200000 || date.getTime() > 253402300799999 ||
date.getUTCFullYear() !== +m[ 1 ] ||
date.getUTCMonth() + 1 !== +m[ 2 ] ||
date.getUTCDate() !== +m[ 3 ] ||
date.getUTCHours() !== +m[ 4 ] ||
Function updateValueFromFields
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
mw.widgets.datetime.DateTimeInputWidget.prototype.updateValueFromFields = function () {
var i, v, $field, spec, curDate, newDate,
components = {},
anyInvalid = false,
anyEmpty = false,
Function cleanUpValue
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
mw.widgets.datetime.DateTimeInputWidget.prototype.cleanUpValue = function ( value ) {
var date, pad;
if ( value === '' ) {
return '';
Function parseDateValue
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
mw.widgets.datetime.DateTimeInputWidget.prototype.parseDateValue = function ( value ) {
var date, m;
value = String( value );
switch ( this.type ) {
Function onFieldWheel
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
mw.widgets.datetime.DateTimeInputWidget.prototype.onFieldWheel = function ( $field, e ) {
var delta = 0,
spec = $field.data( 'mw-widgets-datetime-dateTimeInputWidget-fieldSpec' );
if ( this.isDisabled() || !this.getFocusedField().length ) {
Function onFieldKeyDown
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
mw.widgets.datetime.DateTimeInputWidget.prototype.onFieldKeyDown = function ( $field, e ) {
var spec = $field.data( 'mw-widgets-datetime-dateTimeInputWidget-fieldSpec' );
if ( !this.isDisabled() ) {
switch ( e.which ) {
Similar blocks of code found in 2 locations. Consider refactoring. Open
if ( !this.sawWheelEvent ) {
if ( e.originalEvent.wheelDeltaX ) {
delta = -e.originalEvent.wheelDeltaX;
} else if ( e.originalEvent.wheelDeltaY ) {
delta = e.originalEvent.wheelDeltaY;
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 142.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Identical blocks of code found in 2 locations. Consider refactoring. Open
if ( config.formatter instanceof mw.widgets.datetime.DateTimeFormatter ) {
this.formatter = config.formatter;
} else if ( $.isPlainObject( config.formatter ) ) {
this.formatter = new mw.widgets.datetime.ProlepticGregorianDateTimeFormatter( config.formatter );
} else {
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 104.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Identical blocks of code found in 2 locations. Consider refactoring. Open
if ( config.max instanceof Date && config.max.getTime() <= 253402300799999 ) {
this.max = config.max;
} else {
this.max = new Date( 253402300799999 ); // 9999-12-31T12:59:59.999Z
}
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 70.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
if ( e.originalEvent.deltaY ) {
delta = -e.originalEvent.deltaY;
} else if ( e.originalEvent.deltaX ) {
delta = e.originalEvent.deltaX;
}
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 65.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 5 locations. Consider refactoring. Open
mw.widgets.datetime.DateTimeInputWidget.prototype.onFieldChange = function () {
this.updateValueFromFields();
};
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 46.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 5 locations. Consider refactoring. Open
mw.widgets.datetime.DateTimeInputWidget.prototype.onHandleClick = function () {
this.focus();
};
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 46.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76