File common.php
has 668 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/*
* Carbon-Forum-F
* https://github.com/lincanbin/Carbon-Forum
*
Function AddingNotifications
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
function AddingNotifications($Content, $TopicID, $PostID, $FilterUser = '')
{
/*
Type:
1:新回复
- Read upRead up
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',
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) {
- Read upRead up
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:新回复
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 {
- Read upRead up
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);
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"])) {
- Read upRead up
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])) {
- Read upRead up
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);
}
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);
}
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) {
- Read upRead up
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':
- Read upRead up
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;
- Read upRead up
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;
Avoid too many return
statements within this method. Open
return ($Seconds + 1) . ' ' . $Lang['Time_Seconds_Ago'];
Avoid too many return
statements within this method. Open
return isset($_OPTIONS[$Key]) ? trim($_OPTIONS[$Key]) : $DefaultValue;
Avoid too many return
statements within this method. Open
return date("Y-m-d", $UnixTimeStamp);
Avoid too many return
statements within this method. Open
return false;
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) {
- Read upRead up
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"