Showing 3,032 of 3,032 total issues
File MimetypesUtility.php
has 642 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php declare(strict_types=1);
namespace XoopsModules\Publisher;
/*
Similar blocks of code found in 2 locations. Consider refactoring. Open
if ($totalitems > 0) {
for ($i = 0; $i < $totalItemsOnPage; ++$i) {
$categoryObj = $itemsObj[$i]->getCategory();
$modify = "<a href='item.php?op=mod&itemid=" . $itemsObj[$i]->itemid() . "'>" . $icons['edit'] . '</a>';
- 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 312.
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 ($totalitems > 0) {
for ($i = 0; $i < $totalItemsOnPage; ++$i) {
$categoryObj = $itemsObj[$i]->getCategory();
$modify = "<a href='item.php?op=mod&itemid=" . $itemsObj[$i]->itemid() . "'>" . $icons['edit'] . '</a>';
- 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 312.
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
Function publisher_latest_news_show
has a Cognitive Complexity of 70 (exceeds 5 allowed). Consider refactoring. Open
function publisher_latest_news_show($options)
{
$block = [];
$configurator = new Configurator();
- 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 getElementsBySelector
has a Cognitive Complexity of 67 (exceeds 5 allowed). Consider refactoring. Open
document.getElementsBySelector = function (selector) {
// Attempt to fail gracefully in lesser browsers
if (!document.getElementsByTagName) {
return new Array();
}
- 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
File Blocksadmin.php
has 590 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php declare(strict_types=1);
namespace XoopsModules\Publisher\Common;
/**
Method processImageAndWriteToCache
has 248 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function processImageAndWriteToCache($localImage)
{
$sData = getimagesize($localImage);
$origType = $sData[2];
$mimeType = $sData['mime'];
Function publisher_items_new_show
has a Cognitive Complexity of 63 (exceeds 5 allowed). Consider refactoring. Open
function publisher_items_new_show($options)
{
$helper = Helper::getInstance();
/** @var ItemHandler $itemHandler */
$itemHandler = $helper->getHandler('Item');
- 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 publisher_items_spot_show
has a Cognitive Complexity of 59 (exceeds 5 allowed). Consider refactoring. Open
function publisher_items_spot_show($options)
{
// global $xoTheme;
$helper = Helper::getInstance();
/** @var CategoryHandler $categoryHandler */
- 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 listBlocks
has 219 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function listBlocks(): void
{
global $xoopsModule, $pathIcon16;
require_once XOOPS_ROOT_PATH . '/class/xoopslists.php';
// xoops_loadLanguage('admin', 'system');
Function xoops_module_update_publisher
has a Cognitive Complexity of 56 (exceeds 5 allowed). Consider refactoring. Open
function xoops_module_update_publisher(\XoopsModule $module, ?string $previousVersion = null)
{
// global $GLOBALS['xoopsDB'];
$moduleDirName = \basename(\dirname(__DIR__));
// $moduleDirNameUpper = \mb_strtoupper($moduleDirName);
- 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 createSchemaFromSqlfile
has a Cognitive Complexity of 53 (exceeds 5 allowed). Consider refactoring. Open
public function createSchemaFromSqlfile(): bool
{
if (!\is_file($this->fileSql)) {
\xoops_error('Error: Sql file not found!');
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 truncateHtml
has a Cognitive Complexity of 53 (exceeds 5 allowed). Consider refactoring. Open
public static function truncateHtml(
string $text,
?int $length = 100,
string $ending = '...',
bool $exact = 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
File ItemForm.php
has 498 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php declare(strict_types=1);
namespace XoopsModules\Publisher\Form;
/*
Method publisher_latest_news_show
has 195 lines of code (exceeds 25 allowed). Consider refactoring. Open
function publisher_latest_news_show($options)
{
$block = [];
$configurator = new Configurator();
Function getItemRating
has a Cognitive Complexity of 49 (exceeds 5 allowed). Consider refactoring. Open
public function getItemRating($itemId = 0, $source = 0)
{
$helper = \XoopsModules\Publisher\Helper::getInstance();
$itemRating = [];
- 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
File ItemHandler.php
has 479 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php declare(strict_types=1);
namespace XoopsModules\Publisher;
/*
File modinfo.php
has 477 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php declare(strict_types=1);
define('_MI_PUBLISHER_ADMENU1', 'Summary');
define('_MI_PUBLISHER_ADMENU2', 'Categories');
define('_MI_PUBLISHER_ADMENU3', 'Articles');
Function getItemRating
has a Cognitive Complexity of 48 (exceeds 5 allowed). Consider refactoring. Open
public function getItemRating($itemId = null, $source = null): array
{
$itemId = $itemId ?? 0;
$source = $source ?? 0;
$xoopsUser = $GLOBALS['xoopsUser'];
- 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
Item
has 49 functions (exceeds 20 allowed). Consider refactoring. Open
class Item extends \XoopsObject
{
public const PAGEWRAP = '[pagewrap=';
public const BODYTAG = '<body>';
/**