qcminecraft/Carbon-Forum-F

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

Summary

Maintainability
F
5 days
Test Coverage

File scrawl.js has 616 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/**
 * Created with JetBrains PhpStorm.
 * User: xuheng
 * Date: 12-5-22
 * Time: 上午11:38
Severity: Major
Found in static/editor/dialogs/scrawl/scrawl.js - About 1 day to fix

    Function _addBoardListener has 71 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            _addBoardListener:function (saveNum) {
                var me = this,
                    margin = 0,
                    startX = -1,
                    startY = -1,
    Severity: Major
    Found in static/editor/dialogs/scrawl/scrawl.js - About 2 hrs to fix

      Function exec has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

      function exec(scrawlObj) {
          if (scrawlObj.isScrawl) {
              addMaskLayer(lang.scrawlUpLoading);
              var base64 = scrawlObj.getCanvasData();
              if (!!base64) {
      Severity: Minor
      Found in static/editor/dialogs/scrawl/scrawl.js - About 2 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

      Function ue_callback has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

      function ue_callback(url, state) {
          var doc = document,
              picBorard = $G("J_picBoard"),
              img = doc.createElement("img");
      
      
      Severity: Minor
      Found in static/editor/dialogs/scrawl/scrawl.js - About 2 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

      Function exec has 38 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function exec(scrawlObj) {
          if (scrawlObj.isScrawl) {
              addMaskLayer(lang.scrawlUpLoading);
              var base64 = scrawlObj.getCanvasData();
              if (!!base64) {
      Severity: Minor
      Found in static/editor/dialogs/scrawl/scrawl.js - About 1 hr to fix

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

        function ue_callback(url, state) {
            var doc = document,
                picBorard = $G("J_picBoard"),
                img = doc.createElement("img");
        
        
        Severity: Minor
        Found in static/editor/dialogs/scrawl/scrawl.js - About 1 hr to fix

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

                  _addOPerateListener:function (saveNum) {
                      var me = this;
                      domUtils.on($G("J_previousStep"), "click", function () {
                          if (drawStepIndex > 1) {
                              drawStepIndex -= 1;
          Severity: Minor
          Found in static/editor/dialogs/scrawl/scrawl.js - About 1 hr to fix

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

                        if (rect[dir][2] != 0) {
                            tmp = dom.clientWidth + rect[dir][2] * offset.x;
                            dom.style.width = me._validScaledProp('width', tmp) + 'px';
                        }
            Severity: Major
            Found in static/editor/dialogs/scrawl/scrawl.js and 1 other location - About 2 hrs to fix
            static/editor/dialogs/scrawl/scrawl.js on lines 532..535

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

            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 (rect[dir][3] != 0) {
                            tmp = dom.clientHeight + rect[dir][3] * offset.y;
                            dom.style.height = me._validScaledProp('height', tmp) + 'px';
                        }
            Severity: Major
            Found in static/editor/dialogs/scrawl/scrawl.js and 1 other location - About 2 hrs to fix
            static/editor/dialogs/scrawl/scrawl.js on lines 528..531

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

            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 (rect[dir][1] != 0) {
                            tmp = parseInt(dom.style.top) + offset.y;
                            dom.style.top = me._validScaledProp('top', tmp) + 'px';
                        }
            Severity: Major
            Found in static/editor/dialogs/scrawl/scrawl.js and 1 other location - About 1 hr to fix
            static/editor/dialogs/scrawl/scrawl.js on lines 520..523

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

            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 (rect[dir][0] != 0) {
                            tmp = parseInt(dom.style.left) + offset.x;
                            dom.style.left = me._validScaledProp('left', tmp) + 'px';
                        }
            Severity: Major
            Found in static/editor/dialogs/scrawl/scrawl.js and 1 other location - About 1 hr to fix
            static/editor/dialogs/scrawl/scrawl.js on lines 524..527

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

            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

                        } else {
                            if (height = oh - max) {
                                percent = (height / oh).toFixed(2);
                                img.width = ow - ow * percent;
                                img.height = max;
            Severity: Major
            Found in static/editor/dialogs/scrawl/scrawl.js and 1 other location - About 1 hr to fix
            static/editor/dialogs/scrawl/scrawl.js on lines 579..585

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

            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 (ow >= oh) {
                            if (width = ow - max) {
                                percent = (width / ow).toFixed(2);
                                img.height = oh - oh * percent;
                                img.width = max;
            Severity: Major
            Found in static/editor/dialogs/scrawl/scrawl.js and 1 other location - About 1 hr to fix
            static/editor/dialogs/scrawl/scrawl.js on lines 585..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 67.

            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

                        for (var j = 0, node; node = eraserList[j++];) {
                            if (node.tagName.toLowerCase() == "a") {
                                node.style.opacity = 0.3;
                            }
                        }
            Severity: Major
            Found in static/editor/dialogs/scrawl/scrawl.js and 2 other locations - About 1 hr to fix
            static/editor/dialogs/scrawl/scrawl.js on lines 348..352
            static/editor/dialogs/scrawl/scrawl.js on lines 361..365

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

            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

                        for (var j = 0, node; node = eraserList[j++];) {
                            if (node.tagName.toLowerCase() == "a") {
                                node.style.opacity = 0.3;
                            }
                        }
            Severity: Major
            Found in static/editor/dialogs/scrawl/scrawl.js and 2 other locations - About 1 hr to fix
            static/editor/dialogs/scrawl/scrawl.js on lines 361..365
            static/editor/dialogs/scrawl/scrawl.js on lines 366..370

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

            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

                        for (var i = 0, ele; ele = brushList[i++];) {
                            if (ele.tagName.toLowerCase() == "a") {
                                ele.style.opacity = 0.3;
                            }
                        }
            Severity: Major
            Found in static/editor/dialogs/scrawl/scrawl.js and 2 other locations - About 1 hr to fix
            static/editor/dialogs/scrawl/scrawl.js on lines 348..352
            static/editor/dialogs/scrawl/scrawl.js on lines 366..370

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

            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

                            case 'height':
                                return value <= 0 ? 1 : (value + ele.offsetTop) > wrap.clientHeight ? wrap.clientHeight - ele.offsetTop : value;
            Severity: Major
            Found in static/editor/dialogs/scrawl/scrawl.js and 3 other locations - About 50 mins to fix
            static/editor/dialogs/scrawl/scrawl.js on lines 556..557
            static/editor/dialogs/scrawl/scrawl.js on lines 558..559
            static/editor/dialogs/scrawl/scrawl.js on lines 560..561

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

                            case 'left':
                                return value < 0 ? 0 : (value + ele.clientWidth) > wrap.clientWidth ? wrap.clientWidth - ele.clientWidth : value;
            Severity: Major
            Found in static/editor/dialogs/scrawl/scrawl.js and 3 other locations - About 50 mins to fix
            static/editor/dialogs/scrawl/scrawl.js on lines 558..559
            static/editor/dialogs/scrawl/scrawl.js on lines 560..561
            static/editor/dialogs/scrawl/scrawl.js on lines 562..563

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

                            case 'width':
                                return value <= 0 ? 1 : (value + ele.offsetLeft) > wrap.clientWidth ? wrap.clientWidth - ele.offsetLeft : value;
            Severity: Major
            Found in static/editor/dialogs/scrawl/scrawl.js and 3 other locations - About 50 mins to fix
            static/editor/dialogs/scrawl/scrawl.js on lines 556..557
            static/editor/dialogs/scrawl/scrawl.js on lines 558..559
            static/editor/dialogs/scrawl/scrawl.js on lines 562..563

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

                            case 'top':
                                return value < 0 ? 0 : (value + ele.clientHeight) > wrap.clientHeight ? wrap.clientHeight - ele.clientHeight : value;
            Severity: Major
            Found in static/editor/dialogs/scrawl/scrawl.js and 3 other locations - About 50 mins to fix
            static/editor/dialogs/scrawl/scrawl.js on lines 556..557
            static/editor/dialogs/scrawl/scrawl.js on lines 560..561
            static/editor/dialogs/scrawl/scrawl.js on lines 562..563

            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

            There are no issues that match your filters.

            Category
            Status