Showing 2,846 of 2,846 total issues
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;
Similar blocks of code found in 2 locations. Consider refactoring. Open
$reg_values = "closeText: '"
. \_AM_XOOPSPOLL_DTP_CLOSETEXT
. "',"
. "prevText: '"
. \_AM_XOOPSPOLL_DTP_PREVTEXT
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
$reg_values .= "timeOnlyTitle: '"
. \_AM_XOOPSPOLL_DTP_TIMEONLYTITLE
. "',"
. "timeText: '"
. \_AM_XOOPSPOLL_DTP_TIMETEXT
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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')) {
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 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 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"
Further reading
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 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 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
Method getServerStats
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function getServerStats(): string
{
//mb $wfdownloads = WfdownloadsWfdownloads::getInstance();
$moduleDirName = \basename(\dirname(__DIR__, 2));
$moduleDirNameUpper = \mb_strtoupper($moduleDirName);
Function _setDateDatepicker
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
$.datepicker._setDateDatepicker = function (target, _date) {
var inst = this._getInst(target);
var date = _date;
if (!inst) {
return;
Method loadTableFromArrayWithReplace
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
function loadTableFromArrayWithReplace(string $table, array $data, string $search, $replace): int
{
/** @var \XoopsMySQLDatabase $db */
$db = \XoopsDatabaseFactory::getDatabaseConnection();
Similar blocks of code found in 2 locations. Consider refactoring. Open
if (!tp_inst.support.timezone && tp_inst._defaults.timezone === null) {
tp_inst.timezone = tp_date.getTimezoneOffset() * -1;
}
- Read upRead up
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 59.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
if (!tp_inst.support.timezone && tp_inst._defaults.timezone === null) {
tp_inst.timezone = date.getTimezoneOffset() * -1;
}
- Read upRead up
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 59.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Avoid using undefined variables such as '$timeArray' which will lead to PHP notices. Open
unset($optionsObjArray, $pollOptionsArray, $pollObj, $pollVars, $timeArray);
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Avoid using undefined variables such as '$viewtopic_users' which will lead to PHP notices. Open
&& (!$uid || !isset($viewtopic_users[$uid]))) {
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}