qcminecraft/Carbon-Forum-F

View on GitHub

Showing 851 of 851 total issues

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

    } else if (AllowEmptyTags === false && $("#SelectTags li").length <= 1) {
        if ($("#AlternativeTag").val().length != 0) {
            AddTag($("#AlternativeTag").val(), Math.round(new Date().getTime() / 1000));
        }else{
            CarbonAlert(Lang['Tags_Empty']);
Severity: Major
Found in static/js/mobile/topic.function.js and 1 other location - About 3 hrs to fix
static/js/default/new.function.js on lines 188..239

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

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

Function cleanNodes has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

    private function cleanNodes(DOMElement $elem, $isFirstNode = false)
    {
        $nodeName = strtolower($elem->nodeName);
        $textContent = $elem->textContent;
        if ($isFirstNode || array_key_exists($nodeName, $this->config->WhiteListTag)) {
Severity: Minor
Found in library/WhiteHTMLFilter.php - 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 parseAddresses has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

    public function parseAddresses($addrstr, $useimap = true)
    {
        $addresses = array();
        if ($useimap and function_exists('imap_rfc822_parse_adrlist')) {
            //Use this built-in parser if it's available
Severity: Minor
Found in library/PHPMailer.class.php - 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

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

            $upload.on('click', function () {
                if ($(this).hasClass('disabled')) {
                    return false;
                }

Severity: Major
Found in static/editor/dialogs/attachment/attachment.js and 2 other locations - About 3 hrs to fix
static/editor/dialogs/image/image.js on lines 741..753
static/editor/dialogs/video/video.js on lines 756..768

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

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

            $upload.on('click', function () {
                if ($(this).hasClass('disabled')) {
                    return false;
                }

Severity: Major
Found in static/editor/dialogs/image/image.js and 2 other locations - About 3 hrs to fix
static/editor/dialogs/attachment/attachment.js on lines 526..538
static/editor/dialogs/video/video.js on lines 756..768

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

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

            $upload.on('click', function () {
                if ($(this).hasClass('disabled')) {
                    return false;
                }

Severity: Major
Found in static/editor/dialogs/video/video.js and 2 other locations - About 3 hrs to fix
static/editor/dialogs/attachment/attachment.js on lines 526..538
static/editor/dialogs/image/image.js on lines 741..753

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

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

Function Reply has 86 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function Reply(UserName, PostFloor, PostID, FormHash, TopicID) {
    $.afui.loadContent(
        "#Reply", 
        false, 
        false, 
Severity: Major
Found in static/js/mobile/global.js - About 3 hrs to fix

    Function favorite has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
    Open

        private function favorite($IsFavorite, $FavoriteType)
        {
            global $TimeStamp, $CurUserID;
            Auth(1);
            //$IsFavorite: 检查主题/标签/用户/帖子是否存在
    Severity: Minor
    Found in controller/manage.php - 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

    Method smtpConnect has 85 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function smtpConnect($options = null)
        {
            if (is_null($this->smtp)) {
                $this->smtp = $this->getSMTPInstance();
            }
    Severity: Major
    Found in library/PHPMailer.class.php - About 3 hrs to fix

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

      function TagRemove(TagName, id) {
          $("#Tag" + id).remove();
          TagsListAppend(TagName, id);
          if ($("input[name='Tag[]']").length < MaxTagNum) {
              $("#AlternativeTag").attr("disabled", false);
      Severity: Major
      Found in static/js/mobile/topic.function.js and 1 other location - About 3 hrs to fix
      static/js/default/new.function.js on lines 314..322

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

      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

      function TagRemove(TagName, id) {
          $("#Tag" + id).remove();
          TagsListAppend(TagName, id);
          if ($("input[name='Tag[]']").length < MaxTagNum) {
              $("#AlternativeTag").attr("disabled", false);
      Severity: Major
      Found in static/js/default/new.function.js and 1 other location - About 3 hrs to fix
      static/js/mobile/topic.function.js on lines 166..174

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

      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

                  for (var i = 0; i < 6; i++) {
                      arr.push("<tr>");
                      if(hasTitleCol) { arr.push("<th>" + lang.titleName + "</th>") }
                      for (var k = 0; k < 5; k++) {
                          arr.push("<td>" + lang.cellsName + "</td>")
      Severity: Major
      Found in static/editor/dialogs/table/edittable.js and 1 other location - About 3 hrs to fix
      static/editor/dialogs/table/edittable.js on lines 79..86

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

      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 (hasTitle) {
                      arr.push("<tr>");
                      if(hasTitleCol) { arr.push("<th>" + lang.titleName + "</th>"); }
                      for (var j = 0; j < 5; j++) {
                          arr.push("<th>" + lang.titleName + "</th>");
      Severity: Major
      Found in static/editor/dialogs/table/edittable.js and 1 other location - About 3 hrs to fix
      static/editor/dialogs/table/edittable.js on lines 87..94

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

      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

      Function Toast has 82 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          var Toast = (function () {
              var Toast = function (containerEl, opts) {
      
                  if (typeof containerEl === "string" || containerEl instanceof String) {
                      this.container = document.getElementById(containerEl);
      Severity: Major
      Found in static/js/mobile/global.js - About 3 hrs to fix

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

                    domUtils.on($G("height"), 'keyup', function(){
                        updatePreview();
                        if(locker.checked) {
                            var proportion =locker.getAttribute('data-proportion');
                            $G('width').value = Math.round(this.value * proportion);
        Severity: Major
        Found in static/editor/dialogs/image/image.js and 1 other location - About 3 hrs to fix
        static/editor/dialogs/image/image.js on lines 179..187

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

        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

                    domUtils.on($G("width"), 'keyup', function(){
                        updatePreview();
                        if(locker.checked) {
                            var proportion =locker.getAttribute('data-proportion');
                            $G('height').value = Math.round(this.value / proportion);
        Severity: Major
        Found in static/editor/dialogs/image/image.js and 1 other location - About 3 hrs to fix
        static/editor/dialogs/image/image.js on lines 188..196

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

        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

        File charts.js has 299 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        /*
         * 图片转换对话框脚本
         **/
        
        var tableData = [],
        Severity: Minor
        Found in static/editor/dialogs/charts/charts.js - About 3 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 sendmailSend has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
          Open

              protected function sendmailSend($header, $body)
              {
                  if ($this->Sender != '') {
                      if ($this->Mailer == 'qmail') {
                          $sendmail = sprintf('%s -f%s', escapeshellcmd($this->Sendmail), escapeshellarg($this->Sender));
          Severity: Minor
          Found in library/PHPMailer.class.php - 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 AddingNotifications has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
          Open

          function AddingNotifications($Content, $TopicID, $PostID, $FilterUser = '')
          {
              /*
              Type:
              1:新回复
          Severity: Minor
          Found in common.php - 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

          Severity
          Category
          Status
          Source
          Language