qcminecraft/Carbon-Forum-F

View on GitHub
controller/manage.php

Summary

Maintainability
F
3 days
Test Coverage

File manage.php has 574 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
require(LanguagePath . 'manage.php');
SetStyle('api', 'API');

$ID     = intval(Request('Post', 'ID', 0));
Severity: Major
Found in controller/manage.php - About 1 day to fix

    Method favorite has 97 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

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

      Manage has 26 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class Manage
      {
          private $id;
          private $action;
          private $db;
      Severity: Minor
      Found in controller/manage.php - About 3 hrs to fix

        Method topicAddTag has 56 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function topicAddTag($TopicInfo)
            {
                global $TimeStamp;
                Auth(4, $TopicInfo['UserID'], true);
                $TagName = TagsDiff(array(
        Severity: Major
        Found in controller/manage.php - About 2 hrs to fix

          Function topicAddTag has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              public function topicAddTag($TopicInfo)
              {
                  global $TimeStamp;
                  Auth(4, $TopicInfo['UserID'], true);
                  $TagName = TagsDiff(array(
          Severity: Minor
          Found in controller/manage.php - 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

          Method postEdit has 34 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function postEdit($PostInfo)
              {
                  global $CurUserRole, $CurUserName, $TimeStamp;
                  if ($this->config['AllowEditing'] === 'true') {
                      Auth(4, $PostInfo['UserID'], true);
          Severity: Minor
          Found in controller/manage.php - About 1 hr to fix

            Method getManageInfo has 34 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function getManageInfo($manageType)
                {
                    global $CurUserID;
                    switch ($manageType) {
                        case 'topic':
            Severity: Minor
            Found in controller/manage.php - About 1 hr to fix

              Function postEdit has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function postEdit($PostInfo)
                  {
                      global $CurUserRole, $CurUserName, $TimeStamp;
                      if ($this->config['AllowEditing'] === 'true') {
                          Auth(4, $PostInfo['UserID'], true);
              Severity: Minor
              Found in controller/manage.php - About 45 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

              Function getManageInfo has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function getManageInfo($manageType)
                  {
                      global $CurUserID;
                      switch ($manageType) {
                          case 'topic':
              Severity: Minor
              Found in controller/manage.php - About 35 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

              Avoid too many return statements within this method.
              Open

                              return $this->db->row("SELECT * FROM " . PREFIX . "tags WHERE ID=:ID", array(
                                  "ID" => $this->id
                              ));
              Severity: Major
              Found in controller/manage.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                                return [];
                Severity: Major
                Found in controller/manage.php - About 30 mins to fix

                  Function tagUploadIcon has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function tagUploadIcon($TagInfo)
                      {
                          Auth(3);
                          if ($_FILES['TagIcon']['size'] && $_FILES['TagIcon']['size'] < 1048576) {
                              require(LibraryPath . "ImageResize.class.php");
                  Severity: Minor
                  Found in controller/manage.php - 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

                  Function deleteUpload has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                      private function deleteUpload($uploadRecordList)
                      {
                          foreach ($uploadRecordList as $uploadRecord) {
                              $numberDuplicateFiles = $this->db->single('SELECT count(*) FROM ' . PREFIX . 'upload 
                                      WHERE 
                  Severity: Minor
                  Found in controller/manage.php - 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

                  There are no issues that match your filters.

                  Category
                  Status