Function inputmask
has 864 lines of code (exceeds 25 allowed). Consider refactoring. Open
$.fn.inputmask = function (fn, options) {
var opts = $.extend(true, {}, $.inputmask.defaults, options);
var pasteEvent = isInputEventSupported('paste') ? 'paste' : 'input';
var iphone = navigator.userAgent.match(/iphone/i) != null;
Function mask
has 455 lines of code (exceeds 25 allowed). Consider refactoring. Open
function mask(el) {
var $input = $(el);
if (!$input.is(":input")) return;
//correct greedy setting if needed
File jquery.inputmask.js
has 915 lines of code (exceeds 250 allowed). Consider refactoring. Open
/**
* @license Input Mask plugin for jquery
* http://github.com/RobinHerbots/jquery.inputmask
* Copyright (c) 2010 - 2012 Robin Herbots
* Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
Function keydownEvent
has 76 lines of code (exceeds 25 allowed). Consider refactoring. Open
function keydownEvent(e) {
//Safari 5.1.x - modal dialog fires keypress twice workaround
skipKeyPressEvent = false;
var input = this, k = e.keyCode, pos = caret(input);
Consider simplifying this complex logical expression. Open
if ($.fn.inputmask == undefined) {
$.inputmask = {
//options default
defaults: {
placeholder: "_",
Function keypressEvent
has 74 lines of code (exceeds 25 allowed). Consider refactoring. Open
function keypressEvent(e) {
//Safari 5.1.x - modal dialog fires keypress twice workaround
if (skipKeyPressEvent) return false;
skipKeyPressEvent = true;
Function patchValueProperty
has 61 lines of code (exceeds 25 allowed). Consider refactoring. Open
function patchValueProperty(npt) {
var valueProperty;
if (Object.getOwnPropertyDescriptor)
valueProperty = Object.getOwnPropertyDescriptor(npt, "value");
if (valueProperty && valueProperty.get) {
Function checkVal
has 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
function checkVal(input, buffer, clearInvalid, skipRadixHandling) {
var isRTL = $(input).data('inputmask')['isRTL'],
inputValue = truncateInput(input._valueGet(), isRTL).split('');
if (isRTL) { //align inputValue for RTL/numeric input
Function getTestingChain
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
function getTestingChain() {
var isOptional = false, escaped = false;
var newBlockMarker = false; //indicates wheter the begin/ending of a block should be indicated
return $.map(opts.mask.split(""), function (element, index) {
Function caret
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
function caret(input, begin, end) {
var npt = input.jquery && input.length > 0 ? input[0] : input;
if (typeof begin == 'number') {
end = (typeof end == 'number') ? end : begin;
if (opts.insertMode == false && begin == end) end++; //set visualization for insert/overwrite mode
Function getMaskTemplate
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
function getMaskTemplate() {
var escaped = false, outCount = 0;
if (opts.mask.length == 1 && opts.greedy == false) { opts.placeholder = ""; } //hide placeholder with single non-greedy mask
var singleMask = $.map(opts.mask.split(""), function (element, index) {
var outElem = [];
Avoid deeply nested control flow statements. Open
if ((np = isValid(pos, c, buffer, !clearInvalid)) !== false) {
if (np !== true) {
pos = np.pos || pos; //set new position from isValid
c = np.c || c; //set new char from isValid
}
Avoid deeply nested control flow statements. Open
} else if (c == undefined) break;
Avoid deeply nested control flow statements. Open
if (isRTL) {
beginPos = shiftR(firstMaskPos, beginPos, getPlaceHolder(beginPos), true);
beginPos = (opts.numericInput && opts.greedy && k == opts.keyCode.BACKSPACE && buffer[beginPos + 1] == opts.radixPoint) ? beginPos + 1 : seekNext(buffer, beginPos);
} else beginPos = shiftL(beginPos, maskL);
Avoid deeply nested control flow statements. Open
if (lastMatch == checkPosition) //once outsync the nonmask cannot be the lastmatch
lastMatch = pos;
Avoid deeply nested control flow statements. Open
if (getPlaceHolder(pos) == buffer[pos] || !isMask(pos))
tmpBuffer.splice(0, 1);
else break;
Avoid deeply nested control flow statements. Open
} else if (full !== true) break;
Avoid deeply nested control flow statements. Open
if ((np = isValid(p == maskL || getBufferElement(buffer, p) == opts.radixPoint ? seekPrevious(buffer, p) : p, c, buffer, false)) !== false) {
if (np !== true) {
p = np.pos || pos; //set new position from isValid
c = np.c || c; //set new char from isValid
}
Avoid deeply nested control flow statements. Open
if ((np = isValid(p, c, buffer, false)) !== false) {
if (np !== true) {
p = np.pos || p; //set new position from isValid
c = np.c || c; //set new char from isValid
}
Avoid deeply nested control flow statements. Open
if (Object.getOwnPropertyDescriptor)
valueProperty = Object.getOwnPropertyDescriptor(input, "value");
Avoid deeply nested control flow statements. Open
if (valueProperty && valueProperty.get) {
if (input._valueGet) {
Object.defineProperty(input, "value", {
get: input._valueGet,
set: input._valueSet
Avoid deeply nested control flow statements. Open
if (isOptional == true) //reset newBlockMarker
newBlockMarker = false;
Avoid deeply nested control flow statements. Open
if (inputValue[i] == getBufferElement(buffer, pos))
break;
Avoid deeply nested control flow statements. Open
if (j < getMaskLength() && isValid(i, p, buffer, true) !== false && tests[determineTestPosition(i)].def == tests[determineTestPosition(j)].def) {
setBufferElement(buffer, i, getBufferElement(buffer, j));
setReTargetPlaceHolder(buffer, j); //cleanup next position
} else {
if (isMask(i))
Avoid deeply nested control flow statements. Open
if (arguments.length == 0) {
var $self = $(this);
if ($self.data('inputmask')) {
if ($self.data('inputmask')['autoUnmask'])
return $self.inputmask('unmaskedvalue');
Avoid deeply nested control flow statements. Open
if (j < getMaskLength()) {
if (isValid(j, t, buffer, true) !== false && tests[determineTestPosition(i)].def == tests[determineTestPosition(j)].def)
c = t;
else {
if (isMask(j))
Avoid deeply nested control flow statements. Open
if (opts.numericInput && opts.greedy && k == opts.keyCode.DELETE && buffer[beginPos] == opts.radixPoint) {
beginPos = seekNext(buffer, beginPos);
isRTL = false;
}
Avoid deeply nested control flow statements. Open
if (getPlaceHolder(pos) == buffer[pos] || !isMask(pos))
tmpBuffer.pop();
else break;
Avoid deeply nested control flow statements. Open
if (k == opts.keyCode.RIGHT) {//right
var caretPos = pos.begin == pos.end ? pos.end + 1 : pos.end;
caretPos = caretPos < getMaskLength() ? caretPos : pos.end;
caret(input, e.shiftKey ? pos.begin : caretPos, e.shiftKey ? caretPos + 1 : caretPos);
return false;
Avoid too many return
statements within this function. Open
return false;
Avoid too many return
statements within this function. Open
return false;
Avoid too many return
statements within this function. Open
else return "";
Avoid too many return
statements within this function. Open
return this.each(function () {
mask(this);
});
Avoid too many return
statements within this function. Open
return false;
Avoid too many return
statements within this function. Open
return this.each(function () {
mask(this);
});
Avoid too many return
statements within this function. Open
return false;
Identical blocks of code found in 2 locations. Consider refactoring. Open
get: function () {
var $self = $(this), inputData = $(this).data('inputmask');
return inputData && inputData['autoUnmask'] ? $self.inputmask('unmaskedvalue') : this._valueGet() != inputData['_buffer'].join('') ? this._valueGet() : '';
},
- 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 95.
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
npt.__defineGetter__("value", function () {
var $self = $(this), inputData = $(this).data('inputmask');
return inputData && inputData['autoUnmask'] ? $self.inputmask('unmaskedvalue') : this._valueGet() != inputData['_buffer'].join('') ? this._valueGet() : '';
});
- 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 95.
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 (!$input.hasClass('focus.inputmask') && opts.showMaskOnHover) {
var nptL = input._valueGet().length;
if (nptL == 0) {
buffer = _buffer.slice();
writeBuffer(input, buffer);
- 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 76.
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 (!$input.hasClass('focus.inputmask') && !opts.showMaskOnHover) {
var nptL = input._valueGet().length;
if (nptL == 0) {
buffer = _buffer.slice();
writeBuffer(input, buffer);
- 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 76.
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
caret(input, clickPosition > lastPosition && (isValid(clickPosition, buffer[clickPosition], buffer, true) !== false || !isMask(clickPosition)) ? clickPosition : lastPosition);
- 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 47.
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 3 locations. Consider refactoring. Open
if (np !== true) {
pos = np.pos || pos; //set new position from isValid
c = np.c || c; //set new char from isValid
}
- 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 47.
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
caret(input, clickPosition < lastPosition && (isValid(clickPosition, buffer[clickPosition], buffer, true) !== false || !isMask(clickPosition)) ? clickPosition : lastPosition);
- 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 47.
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 3 locations. Consider refactoring. Open
if (np !== true) {
p = np.pos || p; //set new position from isValid
c = np.c || c; //set new char from isValid
}
- 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 47.
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 3 locations. Consider refactoring. Open
if (np !== true) {
p = np.pos || pos; //set new position from isValid
c = np.c || c; //set new char from isValid
}
- 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 47.
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