qcminecraft/Carbon-Forum-F

View on GitHub
static/js/default/topic.function.js

Summary

Maintainability
F
3 days
Test Coverage

File topic.function.js has 364 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/* global $ */
/*
 * Carbon-Forum-F
 * https://github.com/lincanbin/Carbon-Forum
 *
Severity: Minor
Found in static/js/default/topic.function.js - About 4 hrs to fix

    Function RenderTopic has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

    function RenderTopic() {
        //强制所有链接在新窗口中打开
        var AllPosts = document.getElementsByClassName("comment-content");
        PostContentLists = {};//Global
        AllPosts[AllPosts.length] = document.getElementsByClassName("topic-content")[0];
    Severity: Minor
    Found in static/js/default/topic.function.js - About 3 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 InitEditor has 77 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function InitEditor() {
        //Initialize editor
        UE.delEditor('editor');
        window.UEDITOR_CONFIG['textarea'] = 'Content';
        window.UEDITOR_CONFIG['elementPathEnabled'] = false;
    Severity: Major
    Found in static/js/default/topic.function.js - About 3 hrs to fix

      Function RenderTopic has 68 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function RenderTopic() {
          //强制所有链接在新窗口中打开
          var AllPosts = document.getElementsByClassName("comment-content");
          PostContentLists = {};//Global
          AllPosts[AllPosts.length] = document.getElementsByClassName("topic-content")[0];
      Severity: Major
      Found in static/js/default/topic.function.js - About 2 hrs to fix

        Function ReplyToTopic has 47 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function ReplyToTopic() {
            if (!UE.getEditor('editor').getContent().length) {
                alert(Lang['Content_Empty']);
                UE.getEditor('editor').focus();
            } else {
        Severity: Minor
        Found in static/js/default/topic.function.js - About 1 hr to fix

          Function ReplyToTopic has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

          function ReplyToTopic() {
              if (!UE.getEditor('editor').getContent().length) {
                  alert(Lang['Content_Empty']);
                  UE.getEditor('editor').focus();
              } else {
          Severity: Minor
          Found in static/js/default/topic.function.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 InitNewTagsEditor has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function InitNewTagsEditor() {
              $("#AlternativeTag").keydown(function (e) {
                  var e = e || event;
                  switch (e.keyCode) {
                      case 13:
          Severity: Minor
          Found in static/js/default/topic.function.js - About 1 hr to fix

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

            function InitEditor() {
                //Initialize editor
                UE.delEditor('editor');
                window.UEDITOR_CONFIG['textarea'] = 'Content';
                window.UEDITOR_CONFIG['elementPathEnabled'] = false;
            Severity: Minor
            Found in static/js/default/topic.function.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 trim3 has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            function trim3(str) {
                if (str) {
                    str = str.replace(/^(\s|\u00A0)+/, '');
                    for (var i = str.length - 1; i >= 0; i--) {
                        if (/\S/.test(str.charAt(i))) {
            Severity: Minor
            Found in static/js/default/topic.function.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

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

            function trim3(str) {
                if (str) {
                    str = str.replace(/^(\s|\u00A0)+/, '');
                    for (var i = str.length - 1; i >= 0; i--) {
                        if (/\S/.test(str.charAt(i))) {
            Severity: Major
            Found in static/js/default/topic.function.js and 1 other location - About 3 hrs to fix
            static/js/mobile/global.js on lines 502..513

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

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

                window.UEDITOR_CONFIG['toolbars'] = [
                    [
                        'fullscreen',
                        'source',
                        '|',
            Severity: Major
            Found in static/js/default/topic.function.js and 1 other location - About 2 hrs to fix
            static/js/default/new.function.js on lines 20..70

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

            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

                        error: function () {
                            alert(Lang['Submit_Failure']);
                            UE.getEditor('editor').setEnabled();
                            $("#ReplyButton").val(Lang['Submit_Again']);
                        }
            Severity: Major
            Found in static/js/default/topic.function.js and 1 other location - About 1 hr to fix
            static/js/default/new.function.js on lines 233..237

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

            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

                try {
                    if (UE.getEditor('editor').getContent().length >= 10) {
                        localStorage.setItem(Prefix + "PostContent" + TopicID, UE.getEditor('editor').getContent());
                    }
                } catch (oException) {
            Severity: Major
            Found in static/js/default/topic.function.js and 1 other location - About 1 hr to fix
            static/js/default/new.function.js on lines 326..345

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

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

                if (DraftContent) {
                    UE.getEditor('editor').setContent(DraftContent);
                } else {
                    UE.getEditor('editor').execCommand('cleardoc');
                }
            Severity: Minor
            Found in static/js/default/topic.function.js and 1 other location - About 40 mins to fix
            static/js/default/new.function.js on lines 364..368

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

            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