adobe/brackets

View on GitHub
src/extensions/default/InlineColorEditor/ColorEditor.js

Summary

Maintainability
F
4 days
Test Coverage

File ColorEditor.js has 502 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/*
 * Copyright (c) 2012 - present Adobe Systems Incorporated. All rights reserved.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
Severity: Major
Found in src/extensions/default/InlineColorEditor/ColorEditor.js - About 1 day to fix

    Function ColorEditor has 39 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        function ColorEditor($parent, color, callback, swatches) {
            // Create the DOM structure, filling in localized strings via Mustache
            this.$element = $(Mustache.render(ColorEditorTemplate, Strings));
            $parent.append(this.$element);
    
    
    Severity: Minor
    Found in src/extensions/default/InlineColorEditor/ColorEditor.js - About 1 hr to fix

      Function _handleKeydown has 36 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          ColorEditor.prototype._handleKeydown = function (event) {
              var hasCtrl = (brackets.platform === "win") ? (event.ctrlKey) : (event.metaKey);
              if (hasCtrl) {
                  switch (event.keyCode) {
                  case KeyEvent.DOM_VK_Z:
      Severity: Minor
      Found in src/extensions/default/InlineColorEditor/ColorEditor.js - About 1 hr to fix

        Function _handleSelectionKeydown has 35 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            ColorEditor.prototype._handleSelectionKeydown = function (event) {
                var hsv = {},
                    step = 1.5,
                    xOffset,
                    yOffset,
        Severity: Minor
        Found in src/extensions/default/InlineColorEditor/ColorEditor.js - About 1 hr to fix

          Function _bindColorFormatToRadioButton has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              ColorEditor.prototype._bindColorFormatToRadioButton = function (buttonClass, propertyName, value) {
                  var handler,
                      self = this;
                  handler = function (event) {
                      var newFormat   = $(event.currentTarget).html().toLowerCase().replace("%", "p"),
          Severity: Minor
          Found in src/extensions/default/InlineColorEditor/ColorEditor.js - About 1 hr to fix

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

                    case KeyEvent.DOM_VK_RIGHT:
                        step = event.shiftKey ? step * STEP_MULTIPLIER : step;
                        xOffset = Number($.trim(this.$selectionBase[0].style.left.replace("%", "")));
                        adjustedOffset = (event.keyCode === KeyEvent.DOM_VK_LEFT) ? (xOffset - step) : (xOffset + step);
                        xOffset = Math.min(100, Math.max(0, adjustedOffset));
            Severity: Major
            Found in src/extensions/default/InlineColorEditor/ColorEditor.js and 1 other location - About 6 hrs to fix
            src/extensions/default/InlineColorEditor/ColorEditor.js on lines 714..721

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

            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

                    case KeyEvent.DOM_VK_UP:
                        step = event.shiftKey ? step * STEP_MULTIPLIER : step;
                        yOffset = Number($.trim(this.$selectionBase[0].style.bottom.replace("%", "")));
                        adjustedOffset = (event.keyCode === KeyEvent.DOM_VK_DOWN) ? (yOffset - step) : (yOffset + step);
                        yOffset = Math.min(100, Math.max(0, adjustedOffset));
            Severity: Major
            Found in src/extensions/default/InlineColorEditor/ColorEditor.js and 1 other location - About 6 hrs to fix
            src/extensions/default/InlineColorEditor/ColorEditor.js on lines 705..712

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

            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

                    case KeyEvent.DOM_VK_DOWN:
                        step = event.shiftKey ? step * STEP_MULTIPLIER : step;
                        if (alpha > 0) {
                            hsv.a = (alpha - step) <= 0 ? 0 : alpha - step;
                            this.setColorAsHsv(hsv);
            Severity: Major
            Found in src/extensions/default/InlineColorEditor/ColorEditor.js and 1 other location - About 2 hrs to fix
            src/extensions/default/InlineColorEditor/ColorEditor.js on lines 770..776

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

            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

                    case KeyEvent.DOM_VK_UP:
                        step = event.shiftKey ? step * STEP_MULTIPLIER : step;
                        if (alpha < 100) {
                            hsv.a = (alpha + step) >= 1 ? 1 : alpha + step;
                            this.setColorAsHsv(hsv);
            Severity: Major
            Found in src/extensions/default/InlineColorEditor/ColorEditor.js and 1 other location - About 2 hrs to fix
            src/extensions/default/InlineColorEditor/ColorEditor.js on lines 763..769

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

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

                var KeyEvent           = brackets.getModule("utils/KeyEvent"),
                    PreferencesManager = brackets.getModule("preferences/PreferencesManager"),
                    StringUtils        = brackets.getModule("utils/StringUtils"),
                    Strings            = brackets.getModule("strings"),
                    Mustache           = brackets.getModule("thirdparty/mustache/mustache"),
            Severity: Major
            Found in src/extensions/default/InlineColorEditor/ColorEditor.js and 2 other locations - About 1 hr to fix
            src/extensions/default/QuickOpenHTML/main.js on lines 29..33
            src/extensions/default/StaticServer/main.js on lines 27..32

            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

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

                    var height = this.$hueSlider.height(),
                        offset = _getNewOffset(event.clientY, this.$hueSlider.offset().top, height),
                        hsv    = {};
            Severity: Minor
            Found in src/extensions/default/InlineColorEditor/ColorEditor.js and 1 other location - About 55 mins to fix
            src/extensions/default/InlineColorEditor/ColorEditor.js on lines 580..582

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

            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

                    var height = this.$opacitySlider.height(),
                        offset = _getNewOffset(event.clientY, this.$opacitySlider.offset().top, height),
                        hsv    = {};
            Severity: Minor
            Found in src/extensions/default/InlineColorEditor/ColorEditor.js and 1 other location - About 55 mins to fix
            src/extensions/default/InlineColorEditor/ColorEditor.js on lines 568..570

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

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

                    if (!this.$hueSlider.find(".selector-base").is(":focus")) {
                        this.$hueSlider.find(".selector-base").focus();
                    }
            Severity: Major
            Found in src/extensions/default/InlineColorEditor/ColorEditor.js and 2 other locations - About 50 mins to fix
            src/extensions/default/InlineColorEditor/ColorEditor.js on lines 561..563
            src/extensions/default/InlineColorEditor/ColorEditor.js on lines 585..587

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

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

                    if (!this.$selection.find(".selector-base").is(":focus")) {
                        this.$selection.find(".selector-base").focus();
                    }
            Severity: Major
            Found in src/extensions/default/InlineColorEditor/ColorEditor.js and 2 other locations - About 50 mins to fix
            src/extensions/default/InlineColorEditor/ColorEditor.js on lines 573..575
            src/extensions/default/InlineColorEditor/ColorEditor.js on lines 585..587

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

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

                    if (!this.$opacitySlider.find(".selector-base").is(":focus")) {
                        this.$opacitySlider.find(".selector-base").focus();
                    }
            Severity: Major
            Found in src/extensions/default/InlineColorEditor/ColorEditor.js and 2 other locations - About 50 mins to fix
            src/extensions/default/InlineColorEditor/ColorEditor.js on lines 561..563
            src/extensions/default/InlineColorEditor/ColorEditor.js on lines 573..575

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

            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

                        if (event.keyCode === KeyEvent.DOM_VK_RETURN ||
                                event.keyCode === KeyEvent.DOM_VK_ENTER ||
                                event.keyCode === KeyEvent.DOM_VK_SPACE) {
                            // Enter/Space is same as clicking on swatch
            
            
            Severity: Minor
            Found in src/extensions/default/InlineColorEditor/ColorEditor.js and 1 other location - About 35 mins to fix
            src/editor/CodeHintManager.js on lines 582..591

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

            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