thiagopradi/octopus

View on GitHub

Showing 170 of 237 total issues

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

  getTokenBounds: function() {
    if (null != this.tokenBounds) return this.tokenBounds;
    var value = this.element.value;
    if (value.strip().empty()) return [-1, 0];
    var diff = arguments.callee.getFirstDifferencePos(value, this.oldElementValue);
Severity: Minor
Found in sample_app/public/javascripts/controls.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

Avoid deeply nested control flow statements.
Open

          if (node.tagName !== "!") // Filter out comment nodes.
            results.push(node);
Severity: Major
Found in sample_app/public/javascripts/prototype.js - About 45 mins to fix

    Function attr has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        attr: function(nodes, root, attr, value, operator, combinator) {
    Severity: Minor
    Found in sample_app/public/javascripts/prototype.js - About 45 mins to fix

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

        create: function(element) {
          element = $(element);
          var options = Object.extend({
            element:     element,
            tag:         'li',       // assumes li children, override with tag: 'tagname'
      Severity: Minor
      Found in sample_app/public/javascripts/dragdrop.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 insert has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def insert(arel, name = nil, pk = nil, id_value = nil, sequence_name = nil, binds = [])
      Severity: Minor
      Found in lib/octopus/proxy.rb - About 45 mins to fix

        Consider simplifying this complex logical expression.
        Open

              if (child.className && (cn = ' ' + child.className + ' ') && (cn.include(className) ||
                  (classNames && classNames.all(function(name) {
                    return !name.toString().blank() && cn.include(' ' + name + ' ');
                  }))))
                elements.push(Element.extend(child));
        Severity: Major
        Found in sample_app/public/javascripts/prototype.js - About 40 mins to fix

          Consider simplifying this complex logical expression.
          Open

              if (Object.isString(insertions) || Object.isNumber(insertions) ||
                  Object.isElement(insertions) || (insertions && (insertions.toElement || insertions.toHTML)))
                    insertions = {bottom:insertions};
          Severity: Major
          Found in sample_app/public/javascripts/prototype.js - About 40 mins to fix

            Consider simplifying this complex logical expression.
            Open

                  if((tag_name = src.tagName.toUpperCase()) && (
                    tag_name=='INPUT' ||
                    tag_name=='SELECT' ||
                    tag_name=='OPTION' ||
                    tag_name=='BUTTON' ||
            Severity: Major
            Found in sample_app/public/javascripts/dragdrop.js - About 40 mins to fix

              Function nth has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  nth: function(nodes, formula, root, reverse, ofType) {
              Severity: Minor
              Found in sample_app/public/javascripts/prototype.js - About 35 mins to fix

                Function pseudo has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    pseudo: function(nodes, name, value, root, combinator) {
                Severity: Minor
                Found in sample_app/public/javascripts/prototype.js - About 35 mins to fix

                  Function byClassName has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                      byClassName: function(nodes, root, className) {
                        if (!nodes) nodes = Selector.handlers.descendant([root]);
                        var needle = ' ' + className + ' ';
                        for (var i = 0, results = [], node, nodeClassName; node = nodes[i]; i++) {
                          nodeClassName = node.className;
                  Severity: Minor
                  Found in sample_app/public/javascripts/prototype.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

                  Function initialize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                    initialize: function(element, url, options) {
                      this.url = url;
                      this.element = element = $(element);
                      this.prepareOptions();
                      this._controls = { };
                  Severity: Minor
                  Found in sample_app/public/javascripts/controls.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

                  Function request has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                    request: function(form, options) {
                      form = $(form), options = Object.clone(options || { });
                  
                      var params = options.parameters, action = form.readAttribute('action') || '';
                      if (action.blank()) action = window.location.href;
                  Severity: Minor
                  Found in sample_app/public/javascripts/prototype.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

                  Function baseInitialize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                    baseInitialize: function(element, update, options) {
                      element          = $(element);
                      this.element     = element;
                      this.update      = $(update);
                      this.hasFocus    = false;
                  Severity: Minor
                  Found in sample_app/public/javascripts/controls.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 run_on_shard has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def run_on_shard(&block)
                        if (cs = current_shard)
                          r = ActiveRecord::Base.connection_proxy.run_queries_on_shard(cs, &block)
                          # Use a case statement to avoid any path through ActiveRecord::Delegation's
                          # respond_to? code. We want to avoid the respond_to? code because it can have
                  Severity: Minor
                  Found in lib/octopus/shard_tracking.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 child has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                      child: function(nodes) {
                        var h = Selector.handlers;
                        for (var i = 0, results = [], node; node = nodes[i]; i++) {
                          for (var j = 0, child; child = node.childNodes[j]; j++)
                            if (child.nodeType == 1 && child.tagName != '!') results.push(child);
                  Severity: Minor
                  Found in sample_app/public/javascripts/prototype.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

                  Function onKeyPress has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                    onKeyPress: function(event) {
                      if(this.active)
                        switch(event.keyCode) {
                         case Event.KEY_TAB:
                         case Event.KEY_RETURN:
                  Severity: Minor
                  Found in sample_app/public/javascripts/controls.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

                  Function attr has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                      attr: function(nodes, root, attr, value, operator, combinator) {
                        if (!nodes) nodes = root.getElementsByTagName("*");
                        if (nodes && combinator) nodes = this[combinator](nodes);
                        var handler = Selector.operators[operator], results = [];
                        for (var i = 0, node; node = nodes[i]; i++) {
                  Severity: Minor
                  Found in sample_app/public/javascripts/prototype.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 connection_on_association= has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                        def connection_on_association=(record)
                          return unless ::Octopus.enabled?
                          return if !self.class.connection.respond_to?(:current_shard) || !self.respond_to?(:current_shard)
                  
                          if !record.current_shard.nil? && !current_shard.nil? && record.current_shard.to_s != current_shard.to_s
                  Severity: Minor
                  Found in lib/octopus/association_shard_tracking.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 legacy_method_missing_logic has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def legacy_method_missing_logic(method, *args, &block)
                        if should_clean_connection_proxy?(method)
                          conn = select_connection
                          clean_connection_proxy
                          conn.send(method, *args, &block)
                  Severity: Minor
                  Found in lib/octopus/proxy.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

                  Severity
                  Category
                  Status
                  Source
                  Language