qcminecraft/Carbon-Forum-F

View on GitHub
static/editor/dialogs/background/background.js

Summary

Maintainability
F
1 wk
Test Coverage

File background.js has 321 lines of code (exceeds 250 allowed). Consider refactoring.
Open

(function () {

    var onlineImage,
        backupStyle = editor.queryCommandValue('background');

Severity: Minor
Found in static/editor/dialogs/background/background.js - About 3 hrs to fix

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

            getImageData: function () {
                var _this = this;
    
                if(!_this.listEnd && !this.isLoadingData) {
                    this.isLoadingData = true;
    Severity: Minor
    Found in static/editor/dialogs/background/background.js - About 1 hr to fix

      Function initColorSelector has 34 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          function initColorSelector () {
              var obj = editor.queryCommandValue('background');
              if (obj) {
                  var color = obj['background-color'],
                      repeat = obj['background-repeat'] || 'repeat',
      Severity: Minor
      Found in static/editor/dialogs/background/background.js - About 1 hr to fix

        Function initColorPicker has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            function initColorPicker() {
                var me = editor,
                    cp = $G("colorPicker");
        
                /* 生成颜色选择器ui对象 */
        Severity: Minor
        Found in static/editor/dialogs/background/background.js - About 1 hr to fix

          Function updateFormState has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              function updateFormState (radio, color, url, align, x, y) {
                  var nocolorRadio = $G('nocolorRadio'),
                      coloredRadio = $G('coloredRadio');
          
                  if(radio) {
          Severity: Minor
          Found in static/editor/dialogs/background/background.js - About 1 hr to fix

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

                function updateFormState (radio, color, url, align, x, y) {
            Severity: Minor
            Found in static/editor/dialogs/background/background.js - About 45 mins to fix

              Consider simplifying this complex logical expression.
              Open

                      if (obj) {
                          var color = obj['background-color'],
                              repeat = obj['background-repeat'] || 'repeat',
                              image = obj['background-image'] || '',
                              position = obj['background-position'] || 'center center',
              Severity: Major
              Found in static/editor/dialogs/background/background.js - About 40 mins to fix

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

                        getImageData: function () {
                            var _this = this;
                
                            if(!_this.listEnd && !this.isLoadingData) {
                                this.isLoadingData = true;
                Severity: Major
                Found in static/editor/dialogs/background/background.js and 1 other location - About 2 days to fix
                static/editor/dialogs/image/image.js on lines 853..894

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

                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

                        pushData: function (list) {
                            var i, item, img, icon, _this = this,
                                urlPrefix = editor.getOpt('imageManagerUrlPrefix');
                            for (i = 0; i < list.length; i++) {
                                if(list[i] && list[i].url) {
                Severity: Major
                Found in static/editor/dialogs/background/background.js and 1 other location - About 2 days to fix
                static/editor/dialogs/image/image.js on lines 896..920

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

                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

                        scale: function (img, w, h, type) {
                            var ow = img.width,
                                oh = img.height;
                
                            if (type == 'justify') {
                Severity: Major
                Found in static/editor/dialogs/background/background.js and 2 other locations - About 2 days to fix
                static/editor/dialogs/attachment/attachment.js on lines 711..736
                static/editor/dialogs/image/image.js on lines 922..947

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

                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

                        initData: function () {
                
                            /* 拉取数据需要使用的值 */
                            this.state = 0;
                            this.listSize = editor.getOpt('imageManagerListSize');
                Severity: Major
                Found in static/editor/dialogs/background/background.js and 2 other locations - About 2 hrs to fix
                static/editor/dialogs/attachment/attachment.js on lines 616..626
                static/editor/dialogs/image/image.js on lines 836..846

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

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

                    function OnlineImage(target) {
                        this.container = utils.isString(target) ? document.getElementById(target) : target;
                        this.init();
                    }
                Severity: Major
                Found in static/editor/dialogs/background/background.js and 3 other locations - About 55 mins to fix
                static/editor/dialogs/attachment/attachment.js on lines 568..571
                static/editor/dialogs/image/image.js on lines 146..149
                static/editor/dialogs/image/image.js on lines 789..792

                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

                There are no issues that match your filters.

                Category
                Status