netzke/netzke-basepack

View on GitHub

Showing 58 of 58 total issues

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

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

  read: function(operation, callback, scope) {
    this.grid.server.read(this.paramsFromOperation(operation), function(res) {
      this.processResponse(true, operation, {}, res, callback, scope);
    }, this);
    return {};
Severity: Major
Found in lib/netzke/tree/base/client/extensions.js and 1 other location - About 1 hr to fix
lib/netzke/grid/base/client/extensions.js on lines 123..128

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

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

  read: function(operation, callback, scope) {
    this.grid.server.read(this.paramsFromOperation(operation), function(res) {
      this.processResponse(true, operation, {}, res, callback, scope);
    }, this);
    return {};
Severity: Major
Found in lib/netzke/grid/base/client/extensions.js and 1 other location - About 1 hr to fix
lib/netzke/tree/base/client/extensions.js on lines 12..17

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

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

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

          callback: function(w){
            w.show();
            w.on('close', function(){
              if (w.closeRes === "ok") {
                this.netzkeReloadStore();
    Severity: Major
    Found in javascripts/grid/event_handlers.js and 1 other location - About 1 hr to fix
    javascripts/grid/event_handlers.js on lines 106..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 64.

    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

          callback: function(w) {
            w.show();
            w.on('close', function(){
              if (w.closeRes === "ok") {
                this.netzkeReloadStore();
    Severity: Major
    Found in javascripts/grid/event_handlers.js and 1 other location - About 1 hr to fix
    javascripts/grid/event_handlers.js on lines 159..166

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

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

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

                if (errors.length == 0) {
                  this.grid.getStore().load();
                } else {
                  this.grid.netzkeNotify(errors);
                }
          Severity: Major
          Found in lib/netzke/grid/base/client/extensions.js and 1 other location - About 1 hr to fix
          lib/netzke/grid/base/client/extensions.js on lines 115..119

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

          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

                if (errors.length == 0) {
                  this.grid.getStore().load();
                } else {
                  this.grid.netzkeNotify(errors);
                }
          Severity: Major
          Found in lib/netzke/grid/base/client/extensions.js and 1 other location - About 1 hr to fix
          lib/netzke/grid/base/client/extensions.js on lines 88..92

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

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