netzke/netzke-basepack

View on GitHub

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)
Severity: Minor
Found in lib/netzke/basepack/data_adapters/active_record_adapter.rb - About 5 hrs to fix

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
Severity: Minor
Found in lib/netzke/basepack/data_adapters/abstract_adapter.rb - About 4 hrs to fix

    Class ActiveRecordAdapter has 36 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class ActiveRecordAdapter < AbstractAdapter
        def self.for_class?(model)
          model && model <= ActiveRecord::Base
        end
    
    
    Severity: Minor
    Found in lib/netzke/basepack/data_adapters/active_record_adapter.rb - About 4 hrs to fix

      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
      Severity: Minor
      Found in lib/netzke/basepack/data_adapters/active_record_adapter.rb - About 4 hrs to fix

        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
        Severity: Minor
        Found in lib/netzke/basepack/data_adapters/active_record_adapter.rb - About 3 hrs to fix

        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 = {};
        
        
        Severity: Major
        Found in lib/netzke/basepack/search_panel/client/condition_field.js - About 3 hrs to fix

          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]
          
          
          Severity: Minor
          Found in lib/netzke/basepack/data_adapters/active_record_adapter.rb - About 1 hr to fix

          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
          Severity: Minor
          Found in lib/netzke/basepack/data_adapters/active_record_adapter.rb - About 1 hr to fix

          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;
          Severity: Minor
          Found in javascripts/xdatetime.js - About 1 hr to fix

            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)
            Severity: Minor
            Found in lib/netzke/basepack/data_adapters/active_record_adapter.rb - About 1 hr to fix

              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){
              Severity: Minor
              Found in javascripts/grid/columns.js - About 1 hr to fix

              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);
              Severity: Minor
              Found in javascripts/grid/columns.js - About 1 hr to fix

              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
              
              
              Severity: Minor
              Found in lib/netzke/basepack/fields.rb - About 1 hr to fix

              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
              Severity: Minor
              Found in lib/netzke/grid/services.rb - About 1 hr to fix

              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]
              
              
              Severity: Minor
              Found in lib/netzke/basepack/data_adapters/active_record_adapter.rb - About 1 hr to fix

                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
                Severity: Minor
                Found in lib/netzke/basepack/data_adapters/active_record_adapter.rb - About 1 hr to fix

                  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)
                  
                  
                  Severity: Minor
                  Found in lib/netzke/basepack/column_config.rb - About 55 mins to fix

                  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
                  Severity: Minor
                  Found in lib/netzke/form/services.rb - About 55 mins to fix

                  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
                  Severity: Minor
                  Found in lib/netzke/basepack/columns.rb - About 55 mins to fix

                  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) {
                  Severity: Major
                  Found in lib/netzke/grid/base/client/extensions.js - About 50 mins to fix
                    Severity
                    Category
                    Status
                    Source
                    Language