Showing 46 of 67 total issues
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;
Consider simplifying this complex logical expression. Open
return false if !response_field.field_options["required"] || # field is not required
(response && response.upload?) || # file has been uploaded
(value && !value.blank? && !value.is_a?(Hash)) || # value isn't blank (ignore hashes)
(response_field.field_type.in?(ResponseField::OPTIONS_FIELDS) && (response_field.field_options["options"] || []).empty?) ||
response_field.field_type == "checkboxes" && value && value.reject{|k, v| !v}.length > 0 || # required checkboxes have at least one checkbox checked
Method add_params_to_query
has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring. Open
def self.add_params_to_query(query, params, args = {})
if args[:vendor_searching]
if !params[:q].blank?
query = query.full_search_vendor(params[:q])
end
- 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
Class User
has 26 methods (exceeds 20 allowed). Consider refactoring. Open
class User < ActiveRecord::Base
include Clearance::User
attr_accessor :is_inviting
attr_accessor :is_admining
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);
Method serialized
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def serialized(*args)
obj = args[0]
is_collection = obj.respond_to?(:each)
if args[1].is_a?(Hash)
- 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 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) {
Method calculate_sortable_value
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def calculate_sortable_value
self.sortable_value = case response_field.field_type
when "date"
['year', 'month', 'day'].each { |x| return 0 unless value[x] && !value[x].blank? }
DateTime.new(value['year'].to_i, value['month'].to_i, value['day'].to_i).to_i rescue 0
- 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
Method initialize
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize(user)
can :read, Project do |project|
project.posted_at
end
Method add_params_to_query
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.add_params_to_query(query, params, args = {})
if args[:vendor_searching]
if !params[:q].blank?
query = query.full_search_vendor(params[:q])
end
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, {
Method required_field
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def required_field(response_field, response, value)
return false if !response_field.field_options["required"] || # field is not required
(response && response.upload?) || # file has been uploaded
(value && !value.blank? && !value.is_a?(Hash)) || # value isn't blank (ignore hashes)
(response_field.field_type.in?(ResponseField::OPTIONS_FIELDS) && (response_field.field_options["options"] || []).empty?) ||
- 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 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')],
Method import
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def import
@csv.each do |row|
row = transform_row(row)
if @params[:associate_vendor_account]
- 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
Method serialized
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def serialized(*args)
obj = args[0]
is_collection = obj.respond_to?(:each)
if args[1].is_a?(Hash)
Method add_params_to_query
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def self.add_params_to_query(query, params, args = {})
if !params[:q].blank?
query = query.full_search(params[:q])
end
- 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
Method add_params_to_query
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def self.add_params_to_query(query, params, args = {})
if params[:q] && !params[:q].blank?
query = query.full_search(params[:q])
end
- 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 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 = {