getCss accesses the super-global variable $GLOBALS. Open
public static function getCss($style = 'default')
{
global $xoops;
if (is_readable($xoops->path('modules/' . $GLOBALS['artdirname'] . '/assets/css/style_' . mb_strtolower($style) . '.css'))) {
- Read upRead up
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}
Source
getTemplate accesses the super-global variable $GLOBALS. Open
public static function getTemplate($page = 'index', $style = null)
{
global $xoops;
$template_dir = $xoops->path("modules/{$GLOBALS['artdirname']}/templates/");
- Read upRead up
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}
Source
getCss accesses the super-global variable $GLOBALS. Open
public static function getCss($style = 'default')
{
global $xoops;
if (is_readable($xoops->path('modules/' . $GLOBALS['artdirname'] . '/assets/css/style_' . mb_strtolower($style) . '.css'))) {
- Read upRead up
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}
Source
getTemplate accesses the super-global variable $GLOBALS. Open
public static function getTemplate($page = 'index', $style = null)
{
global $xoops;
$template_dir = $xoops->path("modules/{$GLOBALS['artdirname']}/templates/");
- Read upRead up
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}
Source
getTplPageList accesses the super-global variable $GLOBALS. Open
public static function &getTplPageList($page = '', $refresh = true)
{
$list = null;
$cache_file = empty($page) ? 'template-list' : 'template-page';
- Read upRead up
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}
Source
getTemplate accesses the super-global variable $GLOBALS. Open
public static function getTemplate($page = 'index', $style = null)
{
global $xoops;
$template_dir = $xoops->path("modules/{$GLOBALS['artdirname']}/templates/");
- Read upRead up
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}
Source
getCss accesses the super-global variable $GLOBALS. Open
public static function getCss($style = 'default')
{
global $xoops;
if (is_readable($xoops->path('modules/' . $GLOBALS['artdirname'] . '/assets/css/style_' . mb_strtolower($style) . '.css'))) {
- Read upRead up
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}
Source
template_lookup accesses the super-global variable $GLOBALS. Open
public static function &template_lookup($index_by_page = false)
{
require_once XOOPS_ROOT_PATH . '/class/xoopslists.php';
$files = \XoopsLists::getHtmlListAsArray(XOOPS_ROOT_PATH . '/modules/' . $GLOBALS['artdirname'] . '/templates/');
- Read upRead up
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}
Source
template_lookup accesses the super-global variable $GLOBALS. Open
public static function &template_lookup($index_by_page = false)
{
require_once XOOPS_ROOT_PATH . '/class/xoopslists.php';
$files = \XoopsLists::getHtmlListAsArray(XOOPS_ROOT_PATH . '/modules/' . $GLOBALS['artdirname'] . '/templates/');
- Read upRead up
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}
Source
template_lookup accesses the super-global variable $GLOBALS. Open
public static function &template_lookup($index_by_page = false)
{
require_once XOOPS_ROOT_PATH . '/class/xoopslists.php';
$files = \XoopsLists::getHtmlListAsArray(XOOPS_ROOT_PATH . '/modules/' . $GLOBALS['artdirname'] . '/templates/');
- Read upRead up
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}
Source
Function template_lookup
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public static function &template_lookup($index_by_page = false)
{
require_once XOOPS_ROOT_PATH . '/class/xoopslists.php';
$files = \XoopsLists::getHtmlListAsArray(XOOPS_ROOT_PATH . '/modules/' . $GLOBALS['artdirname'] . '/templates/');
- 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
The method getTplPageList has a boolean flag argument $refresh, which is a certain sign of a Single Responsibility Principle violation. Open
public static function &getTplPageList($page = '', $refresh = true)
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
Remove error control operator '@' on line 175. Open
public static function &getTplPageList($page = '', $refresh = true)
{
$list = null;
$cache_file = empty($page) ? 'template-list' : 'template-page';
- Read upRead up
- Exclude checks
ErrorControlOperator
Error suppression should be avoided if possible as it doesn't just suppress the error, that you are trying to stop, but will also suppress errors that you didn't predict would ever occur. Consider changing error_reporting() level and/or setting up your own error handler.
Example
function foo($filePath) {
$file = @fopen($filPath); // hides exceptions
$key = @$array[$notExistingKey]; // assigns null to $key
}
Source http://phpmd.org/rules/cleancode.html#errorcontroloperator
The method aboutmkdirs has a boolean flag argument $recursive, which is a certain sign of a Single Responsibility Principle violation. Open
public static function aboutmkdirs($dir, $mode = 0777, $recursive = true)
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
The method getTemplateList has a boolean flag argument $refresh, which is a certain sign of a Single Responsibility Principle violation. Open
public static function getTemplateList($page = 'index', $refresh = false)
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
The method template_lookup has a boolean flag argument $index_by_page, which is a certain sign of a Single Responsibility Principle violation. Open
public static function &template_lookup($index_by_page = false)
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
The method template_lookup uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$list[$matches[1]][$matches[3]] = $name;
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Avoid using static access to class '\XoopsCache' in method 'template_lookup'. Open
\XoopsCache::write($key, $list);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\XoopsCache' in method 'getTplPageList'. Open
$list = \XoopsCache::read($key);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\XoopsLists' in method 'template_lookup'. Open
$files = \XoopsLists::getHtmlListAsArray(XOOPS_ROOT_PATH . '/modules/' . $GLOBALS['artdirname'] . '/templates/');
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid unused local variables such as '$file'. Open
foreach ($files as $file => $name) {
- Read upRead up
- Exclude checks
UnusedLocalVariable
Since: 0.2
Detects when a local variable is declared and/or assigned, but not used.
Example
class Foo {
public function doSomething()
{
$i = 5; // Unused
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable
A file should declare new symbols (classes, functions, constants, etc.) and cause no other side effects, or it should execute logic with side effects, but should not do both. The first symbol is defined on line 34 and the first side effect is on line 33. Open
<?php
- Exclude checks
The parameter $index_by_page is not named in camelCase. Open
public static function &template_lookup($index_by_page = false)
{
require_once XOOPS_ROOT_PATH . '/class/xoopslists.php';
$files = \XoopsLists::getHtmlListAsArray(XOOPS_ROOT_PATH . '/modules/' . $GLOBALS['artdirname'] . '/templates/');
- Read upRead up
- Exclude checks
CamelCaseParameterName
Since: 0.2
It is considered best practice to use the camelCase notation to name parameters.
Example
class ClassName {
public function doSomething($user_name) {
}
}
Source
Method name "Utility::template_lookup" is not in camel caps format Open
public static function &template_lookup($index_by_page = false)
- Exclude checks
The closing brace for the class must go on the next line after the body Open
}
- Exclude checks
Line exceeds 120 characters; contains 132 characters Open
* The hardcoded path is not desirable for theme switch, however, we have to keabout it before getting a good solution for cache
- Exclude checks
Line exceeds 120 characters; contains 133 characters Open
if (is_readable($xoops->path('modules/' . $GLOBALS['artdirname'] . '/assets/css/style_' . mb_strtolower($style) . '.css'))) {
- Exclude checks
Line exceeds 120 characters; contains 121 characters Open
$files = \XoopsLists::getHtmlListAsArray(XOOPS_ROOT_PATH . '/modules/' . $GLOBALS['artdirname'] . '/templates/');
- Exclude checks
Line exceeds 120 characters; contains 131 characters Open
return $xoops->path('modules/' . $GLOBALS['artdirname'] . '/assets/css/style_' . mb_strtolower($style) . '.css', true);
- Exclude checks
The variable $file_name is not named in camelCase. Open
public static function getTemplate($page = 'index', $style = null)
{
global $xoops;
$template_dir = $xoops->path("modules/{$GLOBALS['artdirname']}/templates/");
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $template_dir is not named in camelCase. Open
public static function getTemplate($page = 'index', $style = null)
{
global $xoops;
$template_dir = $xoops->path("modules/{$GLOBALS['artdirname']}/templates/");
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $file_name is not named in camelCase. Open
public static function getTemplate($page = 'index', $style = null)
{
global $xoops;
$template_dir = $xoops->path("modules/{$GLOBALS['artdirname']}/templates/");
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $file_name is not named in camelCase. Open
public static function getTemplate($page = 'index', $style = null)
{
global $xoops;
$template_dir = $xoops->path("modules/{$GLOBALS['artdirname']}/templates/");
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $template_dir is not named in camelCase. Open
public static function getTemplate($page = 'index', $style = null)
{
global $xoops;
$template_dir = $xoops->path("modules/{$GLOBALS['artdirname']}/templates/");
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $file_name is not named in camelCase. Open
public static function getTemplate($page = 'index', $style = null)
{
global $xoops;
$template_dir = $xoops->path("modules/{$GLOBALS['artdirname']}/templates/");
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $file_name is not named in camelCase. Open
public static function getTemplate($page = 'index', $style = null)
{
global $xoops;
$template_dir = $xoops->path("modules/{$GLOBALS['artdirname']}/templates/");
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $file_name is not named in camelCase. Open
public static function getTemplate($page = 'index', $style = null)
{
global $xoops;
$template_dir = $xoops->path("modules/{$GLOBALS['artdirname']}/templates/");
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $xoops_module_header is not named in camelCase. Open
public static function getModuleHeader($style = 'default')
{
$xoops_module_header = '<link rel="stylesheet" type="text/css" href="' . self::getCss($style) . '">';
return $xoops_module_header;
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $template_dir is not named in camelCase. Open
public static function getTemplate($page = 'index', $style = null)
{
global $xoops;
$template_dir = $xoops->path("modules/{$GLOBALS['artdirname']}/templates/");
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $xoops_module_header is not named in camelCase. Open
public static function getModuleHeader($style = 'default')
{
$xoops_module_header = '<link rel="stylesheet" type="text/css" href="' . self::getCss($style) . '">';
return $xoops_module_header;
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $cache_file is not named in camelCase. Open
public static function &template_lookup($index_by_page = false)
{
require_once XOOPS_ROOT_PATH . '/class/xoopslists.php';
$files = \XoopsLists::getHtmlListAsArray(XOOPS_ROOT_PATH . '/modules/' . $GLOBALS['artdirname'] . '/templates/');
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $index_by_page is not named in camelCase. Open
public static function &template_lookup($index_by_page = false)
{
require_once XOOPS_ROOT_PATH . '/class/xoopslists.php';
$files = \XoopsLists::getHtmlListAsArray(XOOPS_ROOT_PATH . '/modules/' . $GLOBALS['artdirname'] . '/templates/');
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $cache_file is not named in camelCase. Open
public static function &getTplPageList($page = '', $refresh = true)
{
$list = null;
$cache_file = empty($page) ? 'template-list' : 'template-page';
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $cache_file is not named in camelCase. Open
public static function &getTplPageList($page = '', $refresh = true)
{
$list = null;
$cache_file = empty($page) ? 'template-list' : 'template-page';
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $index_by_page is not named in camelCase. Open
public static function &template_lookup($index_by_page = false)
{
require_once XOOPS_ROOT_PATH . '/class/xoopslists.php';
$files = \XoopsLists::getHtmlListAsArray(XOOPS_ROOT_PATH . '/modules/' . $GLOBALS['artdirname'] . '/templates/');
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $cache_file is not named in camelCase. Open
public static function &template_lookup($index_by_page = false)
{
require_once XOOPS_ROOT_PATH . '/class/xoopslists.php';
$files = \XoopsLists::getHtmlListAsArray(XOOPS_ROOT_PATH . '/modules/' . $GLOBALS['artdirname'] . '/templates/');
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The method template_lookup is not named in camelCase. Open
public static function &template_lookup($index_by_page = false)
{
require_once XOOPS_ROOT_PATH . '/class/xoopslists.php';
$files = \XoopsLists::getHtmlListAsArray(XOOPS_ROOT_PATH . '/modules/' . $GLOBALS['artdirname'] . '/templates/');
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}