mambax7/smartobject

View on GitHub
include/projax_/js/controls.js

Summary

Maintainability
F
1 mo
Test Coverage

File controls.js has 671 lines of code (exceeds 250 allowed). Consider refactoring.
Open

// script.aculo.us controls.js v1.6.4, Wed Sep 06 11:30:58 CEST 2006

// Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
//           (c) 2005 Ivan Krstic (http://blogs.law.harvard.edu/ivan)
//           (c) 2005 Jon Tirsen (http://www.tirsen.com)
Severity: Major
Found in include/projax_/js/controls.js - About 1 day to fix

    Function setOptions has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
    Open

        setOptions: function (options) {
            this.options = Object.extend({
                choices: 10,
                partialSearch: true,
                partialChars: 2,
    Severity: Minor
    Found in include/projax_/js/controls.js - About 4 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

    prototype has 23 functions (exceeds 20 allowed). Consider refactoring.
    Open

    Autocompleter.Base.prototype = {
        baseInitialize: function (element, update, options) {
            this.element = $(element);
            this.update = $(update);
            this.hasFocus = false;
    Severity: Minor
    Found in include/projax_/js/controls.js - About 2 hrs to fix

      prototype has 22 functions (exceeds 20 allowed). Consider refactoring.
      Open

      Ajax.InPlaceEditor.prototype = {
          initialize: function (element, url, options) {
              this.url = url;
              this.element = $(element);
      
      
      Severity: Minor
      Found in include/projax_/js/controls.js - About 2 hrs to fix

        Function initialize has 57 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            initialize: function (element, url, options) {
                this.url = url;
                this.element = $(element);
        
                this.options = Object.extend({
        Severity: Major
        Found in include/projax_/js/controls.js - About 2 hrs to fix

          Function setOptions has 41 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              setOptions: function (options) {
                  this.options = Object.extend({
                      choices: 10,
                      partialSearch: true,
                      partialChars: 2,
          Severity: Minor
          Found in include/projax_/js/controls.js - About 1 hr to fix

            Function onKeyPress has a Cognitive Complexity of 13 (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 include/projax_/js/controls.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 createEditField has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

                createEditField: function () {
                    var text;
                    if (this.options.loadTextURL) {
                        text = this.options.loadingText;
                    } else {
            Severity: Minor
            Found in include/projax_/js/controls.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 createEditField has 38 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                createEditField: function () {
                    var text;
                    if (this.options.loadTextURL) {
                        text = this.options.loadingText;
                    } else {
            Severity: Minor
            Found in include/projax_/js/controls.js - About 1 hr to fix

              Function baseInitialize has 37 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  baseInitialize: function (element, update, options) {
                      this.element = $(element);
                      this.update = $(update);
                      this.hasFocus = false;
                      this.changed = false;
              Severity: Minor
              Found in include/projax_/js/controls.js - About 1 hr to fix

                Function onKeyPress has 32 lines of code (exceeds 25 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 include/projax_/js/controls.js - About 1 hr to fix

                  Function selector has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                              selector: function (instance) {
                                  var ret = []; // Beginning matches
                                  var partial = []; // Inside matches
                                  var entry = instance.getToken();
                                  var count = 0;
                  Severity: Minor
                  Found in include/projax_/js/controls.js - About 1 hr to fix

                    Function updateChoices has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                    Open

                        updateChoices: function (choices) {
                            if (!this.changed && this.hasFocus) {
                                this.update.innerHTML = choices;
                                Element.cleanWhitespace(this.update);
                                Element.cleanWhitespace(this.update.firstChild);
                    Severity: Minor
                    Found in include/projax_/js/controls.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 onSubmit has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        onSubmit: function () {
                            // onLoading resets these so we need to save them away for the Ajax call
                            var form = this.form;
                            var value = this.editField.value;
                    
                    
                    Severity: Minor
                    Found in include/projax_/js/controls.js - About 1 hr to fix

                      Function updateElement has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                      Open

                          updateElement: function (selectedElement) {
                              if (this.options.updateElement) {
                                  this.options.updateElement(selectedElement);
                                  return;
                              }
                      Severity: Minor
                      Found in include/projax_/js/controls.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 render has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                      Open

                          render: function () {
                              if (this.entryCount > 0) {
                                  for (var i = 0; i < this.entryCount; i++)
                                      this.index == i ?
                                          Element.addClassName(this.getEntry(i), "selected") :
                      Severity: Minor
                      Found in include/projax_/js/controls.js - 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 initialize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                      Open

                          initialize: function (element, url, options) {
                              this.url = url;
                              this.element = $(element);
                      
                              this.options = Object.extend({
                      Severity: Minor
                      Found in include/projax_/js/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 baseInitialize has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                          baseInitialize: function (element, update, options) {
                              this.element = $(element);
                              this.update = $(update);
                              this.hasFocus = false;
                              this.changed = false;
                      Severity: Minor
                      Found in include/projax_/js/controls.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

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

                      Ajax.InPlaceEditor.prototype = {
                          initialize: function (element, url, options) {
                              this.url = url;
                              this.element = $(element);
                      
                      
                      Severity: Major
                      Found in include/projax_/js/controls.js and 2 other locations - About 3 wks to fix
                      include/projax/js/controls.js on lines 472..783
                      include/scriptaculous/src/controls.js on lines 472..783

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

                      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 3 locations. Consider refactoring.
                      Open

                      Autocompleter.Base.prototype = {
                          baseInitialize: function (element, update, options) {
                              this.element = $(element);
                              this.update = $(update);
                              this.hasFocus = false;
                      Severity: Major
                      Found in include/projax_/js/controls.js and 2 other locations - About 2 wks to fix
                      include/projax/js/controls.js on lines 44..330
                      include/scriptaculous/src/controls.js on lines 44..330

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

                      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 3 locations. Consider refactoring.
                      Open

                      Autocompleter.Local.prototype = Object.extend(new Autocompleter.Base(), {
                          initialize: function (element, update, array, options) {
                              this.baseInitialize(element, update, options);
                              this.options.array = array;
                          },
                      Severity: Major
                      Found in include/projax_/js/controls.js and 2 other locations - About 4 days to fix
                      include/projax/js/controls.js on lines 397..455
                      include/scriptaculous/src/controls.js on lines 397..455

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

                      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 3 locations. Consider refactoring.
                      Open

                      Object.extend(Ajax.InPlaceCollectionEditor.prototype, {
                          createEditField: function () {
                              if (!this.cached_selectTag) {
                                  var selectTag = document.createElement("select");
                                  var collection = this.options.collection || [];
                      Severity: Major
                      Found in include/projax_/js/controls.js and 2 other locations - About 2 days to fix
                      include/projax/js/controls.js on lines 787..812
                      include/scriptaculous/src/controls.js on lines 787..812

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

                      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 3 locations. Consider refactoring.
                      Open

                      Object.extend(Object.extend(Ajax.Autocompleter.prototype, Autocompleter.Base.prototype), {
                          initialize: function (element, update, url, options) {
                              this.baseInitialize(element, update, options);
                              this.options.asynchronous = true;
                              this.options.onComplete = this.onComplete.bind(this);
                      Severity: Major
                      Found in include/projax_/js/controls.js and 2 other locations - About 2 days to fix
                      include/projax/js/controls.js on lines 333..359
                      include/scriptaculous/src/controls.js on lines 333..359

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

                      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 3 locations. Consider refactoring.
                      Open

                      Form.Element.DelayedObserver.prototype = {
                          initialize: function (element, delay, callback) {
                              this.delay = delay || 0.5;
                              this.element = $(element);
                              this.callback = callback;
                      Severity: Major
                      Found in include/projax_/js/controls.js and 2 other locations - About 1 day to fix
                      include/projax/js/controls.js on lines 819..838
                      include/scriptaculous/src/controls.js on lines 819..838

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

                      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 3 locations. Consider refactoring.
                      Open

                      Autocompleter.Local = Class.create();
                      Severity: Major
                      Found in include/projax_/js/controls.js and 2 other locations - About 55 mins to fix
                      include/projax/js/controls.js on lines 396..396
                      include/scriptaculous/src/controls.js on lines 396..396

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

                      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 3 locations. Consider refactoring.
                      Open

                      if (typeof Effect == 'undefined')
                          throw("controls.js requires including script.aculo.us' effects.js library");
                      Severity: Minor
                      Found in include/projax_/js/controls.js and 2 other locations - About 40 mins to fix
                      include/projax/js/controls.js on lines 38..39
                      include/scriptaculous/src/controls.js on lines 38..39

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

                      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 3 locations. Consider refactoring.
                      Open

                      Field.scrollFreeActivate = function (field) {
                          setTimeout(function () {
                              Field.activate(field);
                          }, 1);
                      }
                      Severity: Minor
                      Found in include/projax_/js/controls.js and 2 other locations - About 40 mins to fix
                      include/projax/js/controls.js on lines 464..468
                      include/scriptaculous/src/controls.js on lines 464..468

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

                      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

                      There are no issues that match your filters.

                      Category
                      Status