Showing 36 of 58 total issues
Method set_record_value_for_attribute
has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring. Open
def set_record_value_for_attribute(record, attr, value)
value = value.to_time_in_current_zone if value.is_a?(Date) # convert Date to Time
unless attr[:read_only]
if attr[:setter]
attr[:setter].call(record, value)
- 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 AbstractAdapter
has 37 methods (exceeds 20 allowed). Consider refactoring. Open
class AbstractAdapter
attr_accessor :model
# Returns primary key name of the model
def primary_key
Class ActiveRecordAdapter
has 36 methods (exceeds 20 allowed). Consider refactoring. Open
class ActiveRecordAdapter < AbstractAdapter
def self.for_class?(model)
model && model <= ActiveRecord::Base
end
File active_record_adapter.rb
has 347 lines of code (exceeds 250 allowed). Consider refactoring. Open
module Netzke::Basepack::DataAdapters
# Implementation of {Netzke::Basepack::DataAdapters::AbstractAdapter}
class ActiveRecordAdapter < AbstractAdapter
def self.for_class?(model)
model && model <= ActiveRecord::Base
Method record_value_for_attribute
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
def record_value_for_attribute(r, a, through_association = false)
v = if association_attr?(a)
split = a[:name].to_s.split(/\.|__/)
assoc = @model.reflect_on_association(split.first.to_sym)
if through_association
- 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 initComponent
has 77 lines of code (exceeds 25 allowed). Consider refactoring. Open
initComponent: function(){
if (!this.type || this.assoc) this.type = 'string';
this.typeHash = {};
Method get_relation
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def get_relation(params = {})
relation = @model.all
query = params[:query]
- 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 combo_data
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def combo_data(attr, query = "")
method, assoc = method_and_assoc(attr[:name])
if assoc
# Options for an asssociation attribute
- 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 initComponent
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
initComponent: function(){
var me = this
,i = 0
,key
,tab;
Method set_record_value_for_attribute
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def set_record_value_for_attribute(record, attr, value)
value = value.to_time_in_current_zone if value.is_a?(Date) # convert Date to Time
unless attr[:read_only]
if attr[:setter]
attr[:setter].call(record, value)
Function netzkeNormalizeAssociationRenderer
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
netzkeNormalizeAssociationRenderer: function(c) {
var passedRenderer = c.renderer, // renderer we got from netzkeNormalizeRenderer
assocValue;
c.scope = this;
c.renderer = function(value, a, r, ri, ci, store, view){
- 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 netzkeExtendColumnConfig
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
netzkeExtendColumnConfig: function(c){
// Set rendeder for association columns (the one displaying associations by the specified method instead of id)
if (c.assoc) {
// Editor for association column
if (c.editor) c.editor = Ext.apply({ name: c.name, netzkeParent: this }, c.editor);
- 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 extend_field
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def extend_field(field)
Netzke::Basepack::FieldConfig.new(field, model_adapter).tap do |c|
# not binding to a model attribute
return c if c.bind == false
- 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 normalize_filters
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def normalize_filters(filters)
filters.map do |f|
{ attr: f["property"], value: f["value"], operator: f["operator"] }.tap do |norm|
# Ext JS filters send us date in the American format
- 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 get_relation
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def get_relation(params = {})
relation = @model.all
query = params[:query]
Method record_value_for_attribute
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def record_value_for_attribute(r, a, through_association = false)
v = if association_attr?(a)
split = a[:name].to_s.split(/\.|__/)
assoc = @model.reflect_on_association(split.first.to_sym)
if through_association
Method set_defaults
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def set_defaults
super
self.type ||= @model_adapter.attr_type(name)
- 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 build_form_errors
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def build_form_errors(record)
form_errors = {}
foreign_keys = model_adapter.hash_fk_model
record.errors.to_hash.map{|field, error|
# some ORM return an array for error
- 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 extend_column_with_filter
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def extend_column_with_filter(column, filter)
if filter[:value].is_a?(Hash)
val = {}
filter[:value].each do |k,v|
val[k] = (v.is_a?(Time) || v.is_a?(Date) || v.is_a?(ActiveSupport::TimeWithZone)) ? Netzke::Core::JsonLiteral.new("new Date('#{v.strftime("%m/%d/%Y")}')") : v
- 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 processEvent
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
processEvent: function(type, view, _, _, _, _, record) {