File rails.validations.js
has 622 lines of code (exceeds 250 allowed). Consider refactoring. Open
(function() {
var $, validateElement, validateForm, validatorsFor,
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
$ = jQuery;
Function input
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
input: function(input) {
var $form, $input, binding, event, form, _ref;
$input = $(input);
form = input.form;
$form = $(form);
Function uniqueness
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
uniqueness: function(element, options) {
var data, key, message, name, scope_value, scoped_element, scoped_name, _ref;
message = ClientSideValidations.validators.local.presence(element, options);
if (message) {
if (options.allow_blank === true) {
Function numericality
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
numericality: function(element, options) {
var CHECKS, check, check_value, fn, form, operator, val;
val = jQuery.trim(element.val());
if (!ClientSideValidations.patterns.numericality.test(val)) {
if (options.allow_blank === true && this.presence(element, {
Function form
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
form: function(form) {
var $form, binding, event, _ref;
$form = $(form);
form.ClientSideValidations = {
settings: window.ClientSideValidations.forms[$form.attr('id')],
Function inclusion
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
inclusion: function(element, options) {
var lower, message, option, upper, _ref;
message = this.presence(element, options);
if (message) {
if (options.allow_blank === true) {
Function exclusion
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
exclusion: function(element, options) {
var lower, message, option, upper, _ref;
message = this.presence(element, options);
if (message) {
if (options.allow_blank === true) {
Function length
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
length: function(element, options) {
var CHECKS, blankOptions, check, fn, message, operator, tokenized_length, tokenizer;
tokenizer = options.js_tokenizer || "split('')";
tokenized_length = new Function('element', "return (element.val()." + tokenizer + " || '').length")(element);
CHECKS = {
Function uniqueness
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
uniqueness: function(element, options) {
var form, matches, name, name_prefix, name_suffix, valid, value;
name = element.attr('name');
if (/_attributes\]\[\d/.test(name)) {
matches = name.match(/^(.+_attributes\])\[\d+\](.+)$/);
Avoid deeply nested control flow statements. Open
if ($(this).data('notLocallyUnique')) {
return $(this).removeData('notLocallyUnique').data('changed', true);
}
Avoid too many return
statements within this function. Open
return;
Avoid too many return
statements within this function. Open
return options.message;
Avoid too many return
statements within this function. Open
return options.messages.odd;
Avoid too many return
statements within this function. Open
return options.messages[check];
Avoid too many return
statements within this function. Open
return options.messages.even;
Similar blocks of code found in 2 locations. Consider refactoring. Open
if (_ref = element.val(), __indexOf.call((function() {
var _i, _len, _ref1, _results;
_ref1 = options["in"];
_results = [];
for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
- 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 134.
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 (_ref = element.val(), __indexOf.call((function() {
var _i, _len, _ref1, _results;
_ref1 = options["in"];
_results = [];
for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
- 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 134.
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
this.filter(ClientSideValidations.selectors.inputs).each(function() {
return ClientSideValidations.enablers.input(this);
});
- 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
this.filter(ClientSideValidations.selectors.forms).each(function() {
return ClientSideValidations.enablers.form(this);
});
- 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