netzke/netzke-basepack

View on GitHub

Showing 58 of 58 total issues

Function renderer has 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

    c.renderer = function(value, a, r, ri, ci, store, view){
Severity: Major
Found in javascripts/grid/columns.js - About 50 mins to fix

    Function initComponent has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      initComponent: function(){
        if (!this.type || this.assoc) this.type = 'string';
    
        this.typeHash = {};
    
    
    Severity: Minor
    Found in lib/netzke/basepack/search_panel/client/condition_field.js - About 45 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 netzkeSetReadonlyMode has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      netzkeSetReadonlyMode: function(onOff){
        if (this.hidden) return;
    
        if (!this.initialConfig.readOnly) {
          this.setReadOnly(onOff);
    Severity: Minor
    Found in lib/netzke/form/base/client/readonly_mode.js - About 45 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_item has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

          def extend_item(item)
            item = super
            item_id = item[:netzke_component] || item[:item_id] # identify regions by item_id
    
            if item_id
    Severity: Minor
    Found in lib/netzke/basepack/item_persistence.rb - About 45 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

    Avoid deeply nested control flow statements.
    Open

                    if assoc.macro == :has_one
                      assoc_instance = record.send(assoc.name)
                      if assoc_instance
                        assoc_instance.send("#{assoc_method}=", value)
                        assoc_instance.save # what should we do when this fails?..
    Severity: Major
    Found in lib/netzke/basepack/data_adapters/active_record_adapter.rb - About 45 mins to fix

      Method validate_config has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

            def validate_config(c)
              raise ArgumentError, "Grid requires a model" if model.nil?
      
              c.editing = :in_form if c.editing.nil?
      
      
      Severity: Minor
      Found in lib/netzke/grid/configuration.rb - About 45 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 netzkeOnItemContextMenu has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

        netzkeOnItemContextMenu: function(grid, record, item, rowIndex, e){
      Severity: Minor
      Found in javascripts/grid/event_handlers.js - About 35 mins to fix

        Identical blocks of code found in 2 locations. Consider refactoring.
        Open

            var data = Ext.Array.map(op.getRecords(), function(r) { return r.getData().id; });
        Severity: Minor
        Found in lib/netzke/tree/base/client/extensions.js and 1 other location - About 35 mins to fix
        lib/netzke/grid/base/client/extensions.js on lines 42..42

        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

        Further Reading

        Identical blocks of code found in 2 locations. Consider refactoring.
        Open

            var data = Ext.Array.map(op.getRecords(), function(r) { return r.getData().id; });
        Severity: Minor
        Found in lib/netzke/grid/base/client/extensions.js and 1 other location - About 35 mins to fix
        lib/netzke/tree/base/client/extensions.js on lines 45..45

        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

        Further Reading

        Method set_defaults has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

              def set_defaults
                super
        
                self.type ||= @model_adapter.attr_type(name)
        
        
        Severity: Minor
        Found in lib/netzke/basepack/field_config.rb - About 35 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 netzkeSetActionEvents has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

          netzkeSetActionEvents: function(){
            this.getSelectionModel().on('selectionchange', function(selModel, selected){
              if (this.actions.delete) this.actions.delete.setDisabled(selected.length == 0);
        
              if (this.actions.edit) {
        Severity: Minor
        Found in javascripts/grid/event_handlers.js - About 35 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 create_or_update_record has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

              def create_or_update_record(hsh)
                hsh.merge!(config[:strong_values]) if config[:strong_values]
        
                # only pick the record specified in the params if it was not provided in the configuration
                @record ||= model_adapter.find_record hsh.delete(model.primary_key.to_s)
        Severity: Minor
        Found in lib/netzke/form/services.rb - About 35 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 predicates_for_and_conditions has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def predicates_for_and_conditions(conditions)
              return nil if conditions.empty?
        
              predicates = conditions.map do |q|
                q = HashWithIndifferentAccess.new(Netzke::Support.permit_hash_params(q))
        Severity: Minor
        Found in lib/netzke/basepack/data_adapters/active_record_adapter.rb - About 25 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_action_config has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

              def build_action_config(a)
                a = {name: a} if a.is_a?(Symbol)
                a[:handler] ||= a[:name]
                a.tap do |a|
                  a[:tooltip] ||= a[:name].to_s.humanize
        Severity: Minor
        Found in lib/netzke/basepack/action_column.rb - About 25 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 update_record has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

              def update_record(record, attrs)
                attrs.each_pair do |k,v|
                  attr = final_columns_hash[k.to_sym]
                  next if attr.nil?
                  model_adapter.set_record_value_for_attribute(record, attr, v)
        Severity: Minor
        Found in lib/netzke/grid/services.rb - About 25 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 destroy has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

              def destroy(ids)
                out = {}
        
                ids.each {|id|
                  record = model_adapter.find_record(id, scope: config[:scope])
        Severity: Minor
        Found in lib/netzke/grid/services.rb - About 25 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 initial_columns_order has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

              def initial_columns_order
                non_meta_columns.map do |c|
                  # copy the values that are not null
                  {name: c[:name]}.tap do |r|
                    r[:width] = c[:width] if c[:width]
        Severity: Minor
        Found in lib/netzke/basepack/columns.rb - About 25 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 netzkeNormalizeRenderer has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          netzkeNormalizeRenderer: function(c) {
            if (!c.renderer) return;
        
            var name, args = [];
        
        
        Severity: Minor
        Found in javascripts/grid/columns.js - About 25 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

        Severity
        Category
        Status
        Source
        Language