netzke/netzke-basepack

View on GitHub

Showing 58 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

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

      Ext.each(op.records, function(r) {
        var rid = r.getId(),
            recordData = res[rid].record,
            error = res[rid].error;
        if (recordData) {
Severity: Major
Found in lib/netzke/tree/base/client/extensions.js and 1 other location - About 5 hrs to fix
lib/netzke/grid/base/client/extensions.js on lines 103..113

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 139.

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

      Ext.each(records, function(r) {
        var rid = r.getId(),
            recordData = res[rid].record,
            error = res[rid].error;
        if (recordData) {
Severity: Major
Found in lib/netzke/grid/base/client/extensions.js and 1 other location - About 5 hrs to fix
lib/netzke/tree/base/client/extensions.js on lines 24..34

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 139.

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

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

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

          },{
            xtype: 'menucheckitem',
            checked: false,
            itemId: 'item-false',
            text: '&nbsp;',
        Severity: Major
        Found in javascripts/tristate.js and 1 other location - About 3 hrs to fix
        javascripts/tristate.js on lines 18..34

        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 110.

        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

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

          items: [{
            xtype: 'menucheckitem',
            checked: true,
            text: '&nbsp;',
            itemId: 'item-true',
        Severity: Major
        Found in javascripts/tristate.js and 1 other location - About 3 hrs to fix
        javascripts/tristate.js on lines 34..50

        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 110.

        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

              for (var id in res) {
                var error;
                if (error = res[id].error) {
                  errors.push(error);
                  store.getRemovedRecords().forEach(function(record, i){
        Severity: Major
        Found in lib/netzke/grid/base/client/extensions.js and 1 other location - About 3 hrs to fix
        lib/netzke/tree/base/client/extensions.js on lines 49..59

        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 109.

        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

              for (var id in res) {
                var error;
                if (error = res[id].error) {
                  errors.push(error);
                  store.getRemovedRecords().forEach(function(record, i){
        Severity: Major
        Found in lib/netzke/tree/base/client/extensions.js and 1 other location - About 3 hrs to fix
        lib/netzke/grid/base/client/extensions.js on lines 46..56

        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 109.

        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

        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

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

            batch: function(options) {
              if (!options) return;
              for (operation in options.operations) {
                var op = new Ext.data.Operation({action: operation, records: options.operations[operation]});
                this[op.action](op, Ext.emptyFn, this);
          Severity: Major
          Found in lib/netzke/tree/base/client/extensions.js and 1 other location - About 2 hrs to fix
          lib/netzke/grid/base/client/extensions.js on lines 32..38

          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 90.

          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

            batch: function(options) {
              if (!options) return;
              for (operation in options.operations) {
                var op = new Ext.data.Operation({action: operation, records: options.operations[operation]});
                this[op.action](op, Ext.emptyFn, this);
          Severity: Major
          Found in lib/netzke/grid/base/client/extensions.js and 1 other location - About 2 hrs to fix
          lib/netzke/tree/base/client/extensions.js on lines 4..10

          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 90.

          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

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

                  me.dateField = Ext.create('Ext.form.field.Date', Ext.apply({
                      format:me.dateFormat,
                      flex:1,
                      isFormField:false, //exclude from field query's
                      submitValue:false,
          Severity: Major
          Found in javascripts/xdatetime.js and 1 other location - About 2 hrs to fix
          javascripts/xdatetime.js on lines 65..72

          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 78.

          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

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

                  me.timeField = Ext.create('Ext.form.field.Time', Ext.apply({
                      format:me.timeFormat,
                      flex:1,
                      isFormField:false, //exclude from field query's
                      submitValue:false,
          Severity: Major
          Found in javascripts/xdatetime.js and 1 other location - About 2 hrs to fix
          javascripts/xdatetime.js on lines 55..62

          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 78.

          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

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

            netzkeOnEdit: function(){
              var selection = this.getSelectionModel().getSelection();
              if (selection.length == 1) {
                this.doEdit(selection[0]);
              } else {
          Severity: Major
          Found in javascripts/grid/event_handlers.js and 1 other location - About 2 hrs to fix
          javascripts/grid/event_handlers.js on lines 95..102

          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 76.

          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

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

            netzkeOnEditInForm: function(){
              var selection = this.getSelectionModel().getSelection();
              if (selection.length == 1) {
                this.doEditInForm(selection[0]);
              } else {
          Severity: Major
          Found in javascripts/grid/event_handlers.js and 1 other location - About 2 hrs to fix
          javascripts/grid/event_handlers.js on lines 86..93

          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 76.

          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

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

            netzkeFilterTypeForAttrType: function(type){
              var map = {
                integer   : 'number',
                decimal   : 'number',
                float     : 'number',
          Severity: Major
          Found in javascripts/grid/columns.js and 1 other location - About 1 hr to fix
          javascripts/grid/columns.js on lines 197..209

          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 70.

          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 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

          Severity
          Category
          Status
          Source
          Language