qcminecraft/Carbon-Forum-F

View on GitHub
common.php

Summary

Maintainability
F
4 days
Test Coverage

File common.php has 668 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/*
 * Carbon-Forum-F
 * https://github.com/lincanbin/Carbon-Forum
 *
Severity: Major
Found in common.php - About 1 day to fix

    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

    Method AlertMsg has 75 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function AlertMsg($PageTitle, $Error, $StatusCode = 200)
    {
        global $Lang, $CurProtocol, $RequestURI, $UrlPath, $IsAjax, $IsMobile, $IsApp, $DB, $Config, $HotTagsArray, $CurUserID, $CurUserName, $CurUserCode, $CurUserRole, $CurUserInfo, $FormHash, $StartTime, $PageMetaKeyword, $TemplatePath;
        $HttpStatuses = [
            100 => 'Continue',
    Severity: Major
    Found in common.php - About 3 hrs to fix

      Function FormatTime has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

      function FormatTime($UnixTimeStamp)
      {
          global $Lang;
          $Seconds = $_SERVER['REQUEST_TIME'] - $UnixTimeStamp;
          if ($Seconds < 2592000) {
      Severity: Minor
      Found in common.php - 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

      Method AddingNotifications has 50 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function AddingNotifications($Content, $TopicID, $PostID, $FilterUser = '')
      {
          /*
          Type:
          1:新回复
      Severity: Minor
      Found in common.php - About 2 hrs to fix

        Function Filter has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

        function Filter($Content)
        {
            if (is_file(LibraryPath . 'Filtering.words.config.json')) {
                $FilteringWords = JsonDecode(file_get_contents(LibraryPath . 'Filtering.words.config.json'));
            } else {
        Severity: Minor
        Found in common.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 XssEscape has 38 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function XssEscape($html)
        {
            $filter = new WhiteHTMLFilter();
            $urlFilter = function($url) {
                $token = parse_url($url);
        Severity: Minor
        Found in common.php - About 1 hr to fix

          Function CurIP has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

          function CurIP()
          {
              $IsCDN = false; //未使用CDN时,应直接使用 $_SERVER['REMOTE_ADDR'] 以防止客户端伪造IP
              $IP = false;
              if (!empty($_SERVER["HTTP_CLIENT_IP"])) {
          Severity: Minor
          Found in common.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

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

          function GetCookie($Key, $DefaultValue = false)
          {
              global $Config, $IsApp;
              if (!$IsApp) {
                  if (!empty($_COOKIE[$Config['CookiePrefix'] . $Key])) {
          Severity: Minor
          Found in common.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

          Consider simplifying this complex logical expression.
          Open

          if ($CurUserExpirationTime > $TimeStamp && $CurUserExpirationTime < ($TimeStamp + 2678400) && $CurUserID && $CurUserCode) {
              $TempUserInfo = array();
              if ($MCache) {
                  $TempUserInfo = $MCache->get(MemCachePrefix . 'UserInfo_' . $CurUserID);
              }
          Severity: Major
          Found in common.php - About 40 mins to fix

            Consider simplifying this complex logical expression.
            Open

                if (!$SignatureTime || !$SignatureKey || !$SignatureValue || empty($APISignature[$SignatureKey]) || abs($SignatureTime - $TimeStamp) > 600 || !HashEquals($SignatureValue, md5($SignatureKey . $APISignature[$SignatureKey] . $SignatureTime))) {
                    AlertMsg('403', 'Forbidden', 403);
                }
            Severity: Major
            Found in common.php - About 40 mins to fix

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

              function ArrayColumn($Input, $ColumnKey)
              {
                  if (version_compare(PHP_VERSION, '5.5.0') < 0) {
                      $Result = array();
                      if ($Input) {
              Severity: Minor
              Found in common.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

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

              function Request($Type, $Key, $DefaultValue = '')
              {
                  global $_PUT, $_DELETE, $_OPTIONS;
                  switch ($Type) {
                      case 'Get':
              Severity: Minor
              Found in common.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

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

              function UpdateUserInfo($NewUserInfo, $UserID = 0)
              {
                  global $DB, $CurUserID, $CurUserInfo, $MCache;
                  if ($UserID == 0) {
                      $UserID = $CurUserID;
              Severity: Minor
              Found in common.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 isset($_REQUEST[$Key]) ? trim($_REQUEST[$Key]) : $DefaultValue;
              Severity: Major
              Found in common.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                            return ($Seconds + 1) . '&nbsp;' . $Lang['Time_Seconds_Ago'];
                Severity: Major
                Found in common.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                              return isset($_OPTIONS[$Key]) ? trim($_OPTIONS[$Key]) : $DefaultValue;
                  Severity: Major
                  Found in common.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                            return date("Y-m-d", $UnixTimeStamp);
                    Severity: Major
                    Found in common.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                          return false;
                      Severity: Major
                      Found in common.php - About 30 mins to fix

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

                        function UpdateConfig($NewConfig)
                        {
                            global $DB, $Config, $MCache;
                            if ($NewConfig) {
                                foreach ($NewConfig as $Key => $Value) {
                        Severity: Minor
                        Found in common.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