Function getModule
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function getModule($module = null)
{
if (!$module) {
foreach (debug_backtrace() as $item) {
if (!empty($item['class'])) {
- 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
Missing class import via use statement (line '37', column '58'). Open
strip_tags(Ajde_Exception_Handler::trace(new Ajde_Exception(),
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Avoid using static access to class 'Ajde_Component_String' in method 'getModule'. Open
$module = current(explode('_', Ajde_Component_String::toSnakeCase($item['class'])));
- 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 'Ajde_Log' in method 'log'. Open
Ajde_Log::_(
'Language key ['.$module.'.'.$ident.'] not found for language ['.Ajde_Lang::getInstance()->getLang().']',
Ajde_Log::CHANNEL_INFO,
Ajde_Log::LEVEL_DEBUG,
'',
- 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 'Ajde_Exception_Handler' in method 'log'. Open
strip_tags(Ajde_Exception_Handler::trace(new Ajde_Exception(),
Ajde_Exception_Handler::EXCEPTION_TRACE_ONLY)));
- 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 short method names like Ajde_Lang_Adapter_Abstract::_(). The configured minimum method name length is 3. Open
public static function _($ident, $module = null)
{
return self::getInstance()->get($ident, $module);
}
- Read upRead up
- Exclude checks
ShortMethodName
Since: 0.2
Detects when very short method names are used.
Example
class ShortMethod {
public function a( $index ) { // Violation
}
}
Source https://phpmd.org/rules/naming.html#shortmethodname
The class Ajde_Lang_Adapter_Abstract is not named in CamelCase. Open
abstract class Ajde_Lang_Adapter_Abstract
{
public static function _($ident, $module = null)
{
return self::getInstance()->get($ident, $module);
- Read upRead up
- Exclude checks
CamelCaseClassName
Since: 0.2
It is considered best practice to use the CamelCase notation to name classes.
Example
class class_name {
}
Source
The method _ is not named in camelCase. Open
public static function _($ident, $module = null)
{
return self::getInstance()->get($ident, $module);
}
- 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() {
}
}