Showing 3,032 of 3,032 total issues
Identical blocks of code found in 2 locations. Consider refactoring. Open
switch ((int)$helper->getConfig('ratingbars')) {
case Constants::RATING_NONE:
default:
\redirect_header('index.php', 3, _MA_PUBLISHER_RATING_VOTE_BAD);
case Constants::RATING_LIKES:
- 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 214.
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
Identical blocks of code found in 2 locations. Consider refactoring. Open
switch ($votingType) {
case Constants::RATING_NONE:
default:
\redirect_header('index.php', 3, _MA_PUBLISHER_RATING_VOTE_BAD);
// no break
- 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 214.
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 search
has 162 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function search($icons): void
{
$helper = Helper::getInstance();
/** @var MimetypeHandler $mimetypeHandler */
$mimetypeHandler = $helper->getHandler('Mimetype');
Method createElements
has 162 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function createElements(): void
{
// require_once \dirname(__DIR__, 2) . '/include/common.php';
// Category
$criteria = new \Criteria(null);
File item.php
has 432 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php declare(strict_types=1);
/*
You may not change or alter any portion of this comment or credits
of supporting developers from this source code or any supporting source code
which is considered copyrighted (c) material of the original comment or credit authors.
Utility
has 46 functions (exceeds 20 allowed). Consider refactoring. Open
class Utility extends Common\SysUtility
{
//--------------- Custom module methods -----------------------------
/**
* Function responsible for checking if a directory exists, we can also write in and create an index.html file
Method getItemRating5
has 152 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getItemRating5($itemObj = null, $source = null): array
{
$itemId = $itemObj->itemid();
$source = $source ?? 0;
$xoopsUser = $GLOBALS['xoopsUser'];
File jquery.popeye-2.1.js
has 409 lines of code (exceeds 250 allowed). Consider refactoring. Open
/*
* jQuery Popeye 2.1 - http://dev.herr-schuessler.de/jquery/popeye/
*
* converts a HTML image list in image gallery with inline enlargement
*
Function __construct
has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring. Open
public function __construct()
{
global $allowedSites;
$this->startTime = microtime(true);
date_default_timezone_set('UTC');
- 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 getItemRating
has 138 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getItemRating($itemId = null, $source = null): array
{
$itemId = $itemId ?? 0;
$source = $source ?? 0;
$xoopsUser = $GLOBALS['xoopsUser'];
Method publisher_items_spot_show
has 137 lines of code (exceeds 25 allowed). Consider refactoring. Open
function publisher_items_spot_show($options)
{
// global $xoTheme;
$helper = Helper::getInstance();
/** @var CategoryHandler $categoryHandler */
Method publisher_latest_news_edit
has 133 lines of code (exceeds 25 allowed). Consider refactoring. Open
function publisher_latest_news_edit($options)
{
$tabletag1 = '<tr><td style="padding:3px;" width="37%">';
$tabletag2 = '</td><td style="padding:3px;">';
$tabletag3 = '<tr><td style="padding-top:20px;border-bottom:1px solid #000;" colspan="2">';
Function getElementsBySelector
has 131 lines of code (exceeds 25 allowed). Consider refactoring. Open
document.getElementsBySelector = function (selector) {
// Attempt to fail gracefully in lesser browsers
if (!document.getElementsByTagName) {
return new Array();
}
Method getItemRating
has 128 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getItemRating($itemId = 0, $source = 0)
{
$helper = \XoopsModules\Publisher\Helper::getInstance();
$itemRating = [];
File latest_news.php
has 375 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php declare(strict_types=1);
/*
You may not change or alter any portion of this comment or credits
of supporting developers from this source code or any supporting source code
which is considered copyrighted (c) material of the original comment or credit authors.
Method manage
has 124 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function manage($icons): void
{
$helper = Helper::getInstance();
$utility = new Utility();
/** @var MimetypeHandler $mimetypeHandler */
Function getItemRating5
has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring. Open
public function getItemRating5($itemObj = null, $source = null): array
{
$itemId = $itemObj->itemid();
$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
Method publisher_editItem
has 122 lines of code (exceeds 25 allowed). Consider refactoring. Open
function publisher_editItem($showmenu = false, $itemId = 0, $clone = false): void
{
$helper = Helper::getInstance();
global $publisherCurrentPage;
Method publisher_items_new_show
has 122 lines of code (exceeds 25 allowed). Consider refactoring. Open
function publisher_items_new_show($options)
{
$helper = Helper::getInstance();
/** @var ItemHandler $itemHandler */
$itemHandler = $helper->getHandler('Item');
Method edit
has 121 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function edit(): void
{
$helper = Helper::getInstance();
/** @var MimetypeHandler $mimetypeHandler */
$mimetypeHandler = $helper->getHandler('Mimetype');