Showing 300 of 2,846 total issues
The class Post has 23 fields. Consider redesigning Post to keep the number of fields under 15. Open
class Post extends \XoopsObject
{
private $post_id;
private $topic_id;
private $forum_id;
- Read upRead up
- Exclude checks
TooManyFields
Since: 0.1
Classes that have too many fields could be redesigned to have fewer fields, possibly through some nested object grouping of some of the information. For example, a class with city/state/zip fields could instead have one Address field.
Example
class Person {
protected $one;
private $two;
private $three;
[... many more fields ...]
}
Source https://phpmd.org/rules/codesize.html#toomanyfields
The class Poll has 16 fields. Consider redesigning Poll to keep the number of fields under 15. Open
class Poll extends \XoopsObject
{
private int $poll_id;
private string $question;
private string $description;
- Read upRead up
- Exclude checks
TooManyFields
Since: 0.1
Classes that have too many fields could be redesigned to have fewer fields, possibly through some nested object grouping of some of the information. For example, a class with city/state/zip fields could instead have one Address field.
Example
class Person {
protected $one;
private $two;
private $three;
[... many more fields ...]
}
Source https://phpmd.org/rules/codesize.html#toomanyfields
Method editBlock
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function editBlock(int $bid): void
{
// require_once \dirname(__DIR__,2) . '/admin/admin_header.php';
// \xoops_cp_header();
\xoops_loadLanguage('admin', 'system');
Method assignForm
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function assignForm(\XoopsTpl $tpl): void
{
$myts = \MyTextSanitizer::getInstance();
$optionObjs = $this->optionHandler->getAllByPollId($this->pollObj->getVar('poll_id'));
Method getPostBody
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function &getPostBody()
{
global $xoopsConfig, $xoopsUser, $myts;
/** @var Xoopspoll\Helper $helper */
$helper = Xoopspoll\Helper::getInstance();
Method vote
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function vote(int $optionId, string $ip, int $time): bool
{
if (!empty($optionId) && $this->isAllowedToVote()) {
$voteTime = empty($time) ? \time() : (int)$time;
$uid = ($GLOBALS['xoopsUser'] instanceof \XoopsUser) ? $GLOBALS['xoopsUser']->uid() : 0;
Function render
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function render(?array $block = null): void
{
\xoops_load('XoopsFormLoader');
\xoops_loadLanguage('common', $this->moduleDirNameUpper);
- 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 displayAttachment
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function displayAttachment($asSource = false)
{
global $xoopsModule;
/** @var Xoopspoll\Helper $helper */
$helper = Xoopspoll\Helper::getInstance();
- 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 getPostBody
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function &getPostBody()
{
global $myts;
$GLOBALS['xoopsModuleConfig'] = newbb_load_config(); // irmtfan load all newbb configs - newbb config in blocks activated in some modules like profile
// mod_loadFunctions('user', 'newbb');
Method orderBlock
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function orderBlock(
array $bid,
array $oldtitle,
array $oldside,
array $oldweight,
Method __construct
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function __construct($id = null)
{
parent::__construct();
// $timestamp = xoops_getUserTimestamp(time());
$currentTimestamp = \time();
Method hasVoted
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function hasVoted(?int $pid, string $ip, int $uid = 0): bool
{
$uid = (int)$uid;
$pid = (int)$pid;
$voted = true;
Function _getDateDatepicker
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
$.datepicker._getDateDatepicker = function (target, noDefault) {
var inst = this._getInst(target);
if (!inst) {
return;
}
Method isResultVisible
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function isResultVisible()
{
$visibleMsg = '';
\xoops_loadLanguage('main', 'xoopspoll');
switch ($this->getVar('visibility')) {
Method delete
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function delete($post, $isDeleteOne = true, $force = false)
{
$retVal = false;
if (($post instanceof Post) && ($post->getVar('post_id') > 0)) {
if ($isDeleteOne) {
Method processOrderBlockAction
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function processOrderBlockAction(BlockData $blockData)
{
$blockData->bid = Request::getArray('bid', []);
$blockData->oldtitle = Request::getArray('oldtitle', [], 'POST');
$blockData->oldside = Request::getArray('oldside', [], 'POST');
Function mailResults
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function mailResults(mixed $pollObj = null): array
{
$criteria = new \CriteriaCompo();
$criteria->add(new \Criteria('end_time', \time(), '<')); // expired polls
$criteria->add(new \Criteria('mail_status', Constants::POLL_NOT_MAILED, '=')); // email not previously sent
- 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 rrmdir
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public static function rrmdir(string $src): bool
{
// Only continue if user is a 'global' Admin
if (!($GLOBALS['xoopsUser'] instanceof \XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) {
return false;
- 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 hasVoted
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function hasVoted(?int $pid, string $ip, int $uid = 0): bool
{
$uid = (int)$uid;
$pid = (int)$pid;
$voted = true;
- 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 assignResults
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function assignResults(\XoopsTpl $tpl): void
{
$myts = \MyTextSanitizer::getInstance();
$xuEndTimestamp = \xoops_getUserTimestamp($this->pollObj->getVar('end_time'));
$xuEndFormatted = \ucfirst(\date(_MEDIUMDATESTRING, (int)$xuEndTimestamp));
- 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"