File Utility.php
has 1387 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace XoopsModules\Wflinks;
/*
Method getCountryName
has 260 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function getCountryName($countryn)
{
$country_array = [
'' => 'Unknown',
'-' => 'Unknown',
Utility
has 42 functions (exceeds 20 allowed). Consider refactoring. Open
class Utility extends Common\SysUtility
{
//--------------- Custom module methods -----------------------------
/**
* getHandler()
Function displayIcons
has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring. Open
public static function displayIcons($time, $status = 0, $counter = 0)
{
global $xoopsModule;
/** @var Wflinks\Helper $helper */
$helper = Wflinks\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
Function getWysiwygForm
has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring. Open
public static function getWysiwygForm($caption, $name, $value)
{
global $xoopsUser, $xoopsModule;
/** @var Wflinks\Helper $helper */
$helper = Wflinks\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
Function getSubstring
has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring. Open
public static function getSubstring($str, $start, $length, $trimmarker = '...')
{
$configHandler = \xoops_getHandler('config');
$im_multilanguageConfig = $configHandler->getConfigsByCat(IM_CONF_MULILANGUAGE);
- 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 getWysiwygForm
has 108 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function getWysiwygForm($caption, $name, $value)
{
global $xoopsUser, $xoopsModule;
/** @var Wflinks\Helper $helper */
$helper = Wflinks\Helper::getInstance();
Method getTotalItems
has 67 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function getTotalItems($sel_id = 0, $get_child = 0, $return_sql = 0)
{
global $xoopsDB, $mytree, $_check_array;
if ($sel_id > 0) {
Function getTotalItems
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
public static function getTotalItems($sel_id = 0, $get_child = 0, $return_sql = 0)
{
global $xoopsDB, $mytree, $_check_array;
if ($sel_id > 0) {
- 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 getLetters
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function getLetters()
{
global $xoopsModule;
$letterchoice = '<div>' . _MD_WFL_BROWSETOTOPIC . '</div>';
Method getSubstring
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function getSubstring($str, $start, $length, $trimmarker = '...')
{
$configHandler = \xoops_getHandler('config');
$im_multilanguageConfig = $configHandler->getConfigsByCat(IM_CONF_MULILANGUAGE);
Function getBannerFromIdClient
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
public static function getBannerFromIdClient($client_id)
{
###### Hack by www.stefanosilvestrini.com ######
global $xoopsConfig;
$db = \XoopsDatabaseFactory::getDatabaseConnection();
- 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 getBannerFromIdBanner
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
public static function getBannerFromIdBanner($banner_id)
{
###### Hack by www.stefanosilvestrini.com ######
global $xoopsConfig;
$db = \XoopsDatabaseFactory::getDatabaseConnection();
- 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 getBannerFromIdClient
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function getBannerFromIdClient($client_id)
{
###### Hack by www.stefanosilvestrini.com ######
global $xoopsConfig;
$db = \XoopsDatabaseFactory::getDatabaseConnection();
Method getBannerFromIdBanner
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function getBannerFromIdBanner($banner_id)
{
###### Hack by www.stefanosilvestrini.com ######
global $xoopsConfig;
$db = \XoopsDatabaseFactory::getDatabaseConnection();
Method googleCh
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function googleCh($url, $length = null, $init = 0xE6359A60)
{
if (null === $length) {
$length = \count($url);
}
Method convertHtml2text
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function convertHtml2text($document)
{
$search = [
"'<script[^>]*?>.*?</script>'si", // Strip out javascript
"'<img.*?>'si", // Strip out img tags
Method getLinkListBody
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function getLinkListBody($published)
{
global $myts, $imageArray, $xoopsModule;
/** @var Wflinks\Helper $helper */
$helper = Wflinks\Helper::getInstance();
Method displayIcons
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function displayIcons($time, $status = 0, $counter = 0)
{
global $xoopsModule;
/** @var Wflinks\Helper $helper */
$helper = Wflinks\Helper::getInstance();
Method convertOrderByOut
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function convertOrderByOut($orderby)
{
if ('title ASC' === $orderby) {
$orderby = 'titleA';
}
Consider simplifying this complex logical expression. Open
if (0 == $published['offline']
&& ($published['published'] && $published['published'] < \time())
&& (($published['expired'] && $published['expired'] > \time()) || 0 == $published['expired'])) {
$published_status = $imageArray['online'];
} elseif (0 == $published['offline'] && ($published['expired'] && $published['expired'] < \time())) {
Method convertOrderByIn
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function convertOrderByIn($orderby)
{
switch (\trim($orderby)) {
case 'titleA':
$orderby = 'title ASC';
Function convertOrderByOut
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public static function convertOrderByOut($orderby)
{
if ('title ASC' === $orderby) {
$orderby = 'titleA';
}
- 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 convertOrderByIn
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public static function convertOrderByIn($orderby)
{
switch (\trim($orderby)) {
case 'titleA':
$orderby = 'title ASC';
- 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 convertOrderByTrans
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function convertOrderByTrans($orderby)
{
if ('hits ASC' === $orderby) {
$orderbyTrans = _MD_WFL_POPULARITYLTOM;
}
Method uploadFiles
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function uploadFiles(
$FILES,
$uploaddir = 'uploads',
$allowed_mimetypes = '',
$redirecturl = 'index.php',
Method mix
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function mix($a, $b, $c)
{
$a -= $b;
$a -= $c;
$a ^= static::fillZeroes($c, 13);
Function uploadFiles
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public static function uploadFiles(
$FILES,
$uploaddir = 'uploads',
$allowed_mimetypes = '',
$redirecturl = 'index.php',
- 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 convertOrderByTrans
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public static function convertOrderByTrans($orderby)
{
if ('hits ASC' === $orderby) {
$orderbyTrans = _MD_WFL_POPULARITYLTOM;
}
- 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 uploadFiles
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
$FILES,
$uploaddir = 'uploads',
$allowed_mimetypes = '',
$redirecturl = 'index.php',
$num = 0,
Function pagerank
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public static function pagerank($url)
{
$pagerank = '';
$ch = '6' . static::googleCh(static::strord('info:' . $url));
$fp = \fsockopen('www.google.com', 80, $errno, $errstr, 30);
- 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 getHandler
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public static function getHandler($name, $optional = false)
{
global $handlers, $xoopsModule;
$name = mb_strtolower(\trim($name));
- 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 getForum
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public static function getForum($forumid)
{
global $xoopsDB, $xoopsConfig;
echo "<select name='forumid'>";
- 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 isNewImage
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public static function isNewImage($published)
{
global $xoopsModule, $xoopsDB;
$oneday = (\time() - (86400 * 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
Function getLinkListBody
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public static function getLinkListBody($published)
{
global $myts, $imageArray, $xoopsModule;
/** @var Wflinks\Helper $helper */
$helper = Wflinks\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
Identical blocks of code found in 2 locations. Consider refactoring. Open
if ($htmlbanner) {
$bannerobject = $htmlcode;
} else {
$bannerobject = '<div align="center"><a href="' . XOOPS_URL . '/banners.php?op=click&bid=' . $bid . '" target="_blank">';
if (false !== mb_stripos($imageurl, '.swf')) {
- 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 139.
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
if ($htmlbanner) {
$bannerobject = $htmlcode;
} else {
$bannerobject = '<div align="center"><a href="' . XOOPS_URL . '/banners.php?op=click&bid=' . $bid . '" target="_blank">';
if (false !== mb_stripos($imageurl, '.swf')) {
- 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 139.
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
if ($imptotal == $impmade) {
$newid = $db->genId($db->prefix('bannerfinish') . '_bid_seq');
$sql = \sprintf('INSERT INTO `%s` (bid, cid, impressions, clicks, datestart, dateend) VALUES (%u, %u, %u, %u, %u, %u)', $db->prefix('bannerfinish'), $newid, $cid, $impmade, $clicks, $date, \time());
$db->queryF($sql);
$db->queryF(\sprintf('DELETE FROM `%s` WHERE bid = %u', $db->prefix('banner'), $bid));
- 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 114.
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
if ($imptotal == $impmade) {
$newid = $db->genId($db->prefix('bannerfinish') . '_bid_seq');
$sql = \sprintf('INSERT INTO `%s` (bid, cid, impressions, clicks, datestart, dateend) VALUES (%u, %u, %u, %u, %u, %u)', $db->prefix('bannerfinish'), $newid, $cid, $impmade, $clicks, $date, \time());
$db->queryF($sql);
$db->queryF(\sprintf('DELETE FROM `%s` WHERE bid = %u', $db->prefix('banner'), $bid));
- 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 114.
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