editblock accesses the super-global variable $_POST. Open
function editblock($bid = 0, $clone = FALSE) {
global $icms_block_handler, $icmsAdminTpl;
$blockObj = $icms_block_handler->get($bid);
- 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
editblock accesses the super-global variable $_POST. Open
function editblock($bid = 0, $clone = FALSE) {
global $icms_block_handler, $icmsAdminTpl;
$blockObj = $icms_block_handler->get($bid);
- 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
editblock accesses the super-global variable $_POST. Open
function editblock($bid = 0, $clone = FALSE) {
global $icms_block_handler, $icmsAdminTpl;
$blockObj = $icms_block_handler->get($bid);
- 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 editblock
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
function editblock($bid = 0, $clone = FALSE) {
global $icms_block_handler, $icmsAdminTpl;
$blockObj = $icms_block_handler->get($bid);
- 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 editblock
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
function editblock($bid = 0, $clone = FALSE) {
global $icms_block_handler, $icmsAdminTpl;
$blockObj = $icms_block_handler->get($bid);
The function editblock() has a Cyclomatic Complexity of 12. The configured cyclomatic complexity threshold is 10. Open
function editblock($bid = 0, $clone = FALSE) {
global $icms_block_handler, $icmsAdminTpl;
$blockObj = $icms_block_handler->get($bid);
- Read upRead up
- Exclude checks
CyclomaticComplexity
Since: 0.1
Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.
Example
// Cyclomatic Complexity = 11
class Foo {
1 public function example() {
2 if ($a == $b) {
3 if ($a1 == $b1) {
fiddle();
4 } elseif ($a2 == $b2) {
fiddle();
} else {
fiddle();
}
5 } elseif ($c == $d) {
6 while ($c == $d) {
fiddle();
}
7 } elseif ($e == $f) {
8 for ($n = 0; $n < $h; $n++) {
fiddle();
}
} else {
switch ($z) {
9 case 1:
fiddle();
break;
10 case 2:
fiddle();
break;
11 case 3:
fiddle();
break;
default:
fiddle();
break;
}
}
}
}
Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity
The method editblock has a boolean flag argument $clone, which is a certain sign of a Single Responsibility Principle violation. Open
function editblock($bid = 0, $clone = 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
Missing class import via use statement (line '60', column '21'). Open
$controller = new icms_ipf_Controller($icms_block_handler);
- 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
The method editblock uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
if ($clone) {
if ($blockObj->getVar('block_type') != 'C') {
$blockObj->setVar('block_type', 'K');
$blockObj->hideFieldFromForm('content');
- 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
The method editblock uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$blockObj->setControl("content", "dhtmltextarea");
}
- 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
The method editblock uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$blockObj->setVar('block_type', 'C');
}
- 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
Reference to static property user
from undeclared class \icms
Open
if (!is_object(icms::$user) || !is_object($icmsModule) || !icms::$user->isAdmin($icmsModule->getVar('mid'))) {
- Exclude checks
Call to method __construct
from undeclared class \icms_ipf_view_Table
Open
$objectTable = new icms_ipf_view_Table($icms_block_handler);
- Exclude checks
Call to method __construct
from undeclared class \icms_ipf_view_Column
Open
$objectTable->addColumn(new icms_ipf_view_Column('name'));
- Exclude checks
Call to method addColumn
from undeclared class \icms_ipf_view_Table
Open
$objectTable->addColumn(new icms_ipf_view_Column('name'));
- Exclude checks
Call to method __construct
from undeclared class \icms_ipf_view_Column
Open
$objectTable->addColumn(new icms_ipf_view_Column('title', _GLOBAL_LEFT, FALSE, 'getAdminViewItemLink'));
- Exclude checks
Call to method __construct
from undeclared class \icms_ipf_Controller
Open
$controller = new icms_ipf_Controller($icms_block_handler);
- Exclude checks
Suspicious array access to nullable ?array
Open
$obj->setVar('weight', (int) $_POST['block_weight'][$k]);
- Exclude checks
Reference to undeclared constant \_SUBMIT
Open
$objectTable->addActionButton('change_blocks', FALSE, _SUBMIT);
- Exclude checks
Suspicious array access to nullable ?array
Open
foreach ($_POST['SystemBlocksadmin_objects'] as $k => $v) {
- Exclude checks
Variable $icmsModule
is undeclared Open
if (!is_object(icms::$user) || !is_object($icmsModule) || !icms::$user->isAdmin($icmsModule->getVar('mid'))) {
- Exclude checks
Suspicious array access to nullable ?array
Open
if ($obj->getVar('weight', 'e') != $_POST['block_weight'][$k]) {
- Exclude checks
Call to method __construct
from undeclared class \icms_ipf_view_Column
Open
$objectTable->addColumn(new icms_ipf_view_Column('visible', 'center'));
- Exclude checks
Call to method __construct
from undeclared class \icms_ipf_view_Column
Open
$objectTable->addColumn(new icms_ipf_view_Column('mid'));
- Exclude checks
Call to method addCustomAction
from undeclared class \icms_ipf_view_Table
Open
$objectTable->addCustomAction('getDownActionLink');
- Exclude checks
Call to method addCustomAction
from undeclared class \icms_ipf_view_Table
Open
$objectTable->addCustomAction('getCloneActionLink');
- Exclude checks
Call to method storeFromDefaultForm
from undeclared class \icms_ipf_Controller
Open
$controller->storeFromDefaultForm(_AM_SYSTEM_BLOCKSADMIN_CREATED, _AM_SYSTEM_BLOCKSADMIN_MODIFIED);
- Exclude checks
Call to method __construct
from undeclared class \icms_ipf_Controller
Open
$controller = new icms_ipf_Controller($icms_block_handler);
- Exclude checks
Call to method addQuickSearch
from undeclared class \icms_ipf_view_Table
Open
$objectTable->addQuickSearch(array(
- Exclude checks
Call to method fetch
from undeclared class \icms_ipf_view_Table
Open
$icmsAdminTpl->assign('icms_block_table', $objectTable->fetch());
- Exclude checks
Call to method postDataToObject
from undeclared class \icms_ipf_Controller
Open
$controller->postDataToObject($blockObj);
- Exclude checks
Call to method addColumn
from undeclared class \icms_ipf_view_Table
Open
$objectTable->addColumn(new icms_ipf_view_Column('visible', 'center'));
- Exclude checks
Call to method __construct
from undeclared class \icms_ipf_view_Column
Open
$objectTable->addColumn(new icms_ipf_view_Column('side', 'center', FALSE, 'getSideControl'));
- Exclude checks
Call to method addIntroButton
from undeclared class \icms_ipf_view_Table
Open
$objectTable->addIntroButton('addpost', 'admin.php?fct=blocksadmin&op=mod', _AM_SYSTEM_BLOCKSADMIN_CREATE);
- Exclude checks
Call to method addColumn
from undeclared class \icms_ipf_view_Table
Open
$objectTable->addColumn(new icms_ipf_view_Column('title', _GLOBAL_LEFT, FALSE, 'getAdminViewItemLink'));
- Exclude checks
Call to method addColumn
from undeclared class \icms_ipf_view_Table
Open
$objectTable->addColumn(new icms_ipf_view_Column('side', 'center', FALSE, 'getSideControl'));
- Exclude checks
Suspicious array access to nullable ?array
Open
if ($obj->getVar('side', 'e') != $_POST['block_side'][$k]) {
- Exclude checks
Call to method addColumn
from undeclared class \icms_ipf_view_Table
Open
$objectTable->addColumn(new icms_ipf_view_Column('mid'));
- Exclude checks
Call to method addFilter
from undeclared class \icms_ipf_view_Table
Open
$objectTable->addFilter('side', 'getBlockPositionArray');
- Exclude checks
Call to method addColumn
from undeclared class \icms_ipf_view_Table
Open
$objectTable->addColumn(new icms_ipf_view_Column('weight', 'center', FALSE, 'getWeightControl'));
- Exclude checks
Call to method addCustomAction
from undeclared class \icms_ipf_view_Table
Open
$objectTable->addCustomAction('getUpActionLink');
- Exclude checks
Call to method addActionButton
from undeclared class \icms_ipf_view_Table
Open
$objectTable->addActionButton('change_blocks', FALSE, _SUBMIT);
- Exclude checks
Variable $icmsAdminTpl
is undeclared Open
$icmsAdminTpl->assign('icms_block_table', $objectTable->fetch());
- Exclude checks
Variable $icmsAdminTpl
is undeclared Open
$icmsAdminTpl->display('db:system_adm_blocksadmin.html');
- Exclude checks
Call to method __construct
from undeclared class \icms_ipf_Controller
Open
$controller = new icms_ipf_Controller($icms_block_handler);
- Exclude checks
Call to method handleObjectDeletion
from undeclared class \icms_ipf_Controller
Open
$controller->handleObjectDeletion();
- Exclude checks
Call to method addFilter
from undeclared class \icms_ipf_view_Table
Open
$objectTable->addFilter('mid', 'getModulesArray');
- Exclude checks
Call to method addCustomAction
from undeclared class \icms_ipf_view_Table
Open
$objectTable->addCustomAction('getBlankLink');
- Exclude checks
Suspicious array access to nullable ?array
Open
$obj->setVar('side', (int) $_POST['block_side'][$k]);
- Exclude checks
Call to method __construct
from undeclared class \icms_ipf_view_Column
Open
$objectTable->addColumn(new icms_ipf_view_Column('weight', 'center', FALSE, 'getWeightControl'));
- Exclude checks
Call to method addFilter
from undeclared class \icms_ipf_view_Table
Open
$objectTable->addFilter('visible', 'getVisibleStatusArray');
- Exclude checks
Similar blocks of code found in 3 locations. Consider refactoring. Open
case "down" :
$icms_block_handler->downWeight($clean_bid);
$rtn = '/modules/system/admin.php?fct=blocksadmin';
if (isset($_GET['sortsel'])) {
$rtn .= '&sortsel=' . $sortsel . '&ordersel=' . $ordersel . '&limitsel=' . $limitsel . '&startbid=' . $startbid;
- 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 126.
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 3 locations. Consider refactoring. Open
case "up" :
$icms_block_handler->upWeight($clean_bid);
$rtn = '/modules/system/admin.php?fct=blocksadmin';
if (isset($_GET['sortsel'])) {
$rtn .= '&sortsel=' . $sortsel . '&ordersel=' . $ordersel . '&limitsel=' . $limitsel . '&startbid=' . $startbid;
- 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 126.
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 3 locations. Consider refactoring. Open
case 'visible' :
$icms_block_handler->changeVisible($clean_bid);
$rtn = '/modules/system/admin.php?fct=blocksadmin';
if (isset($_GET['sortsel'])) {
$rtn .= '&sortsel=' . $sortsel . '&ordersel=' . $ordersel . '&limitsel=' . $limitsel . '&startbid=' . $startbid;
- 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 126.
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
TRUE, FALSE and NULL must be lowercase; expected "false" but found "FALSE" Open
$objectTable->addColumn(new icms_ipf_view_Column('title', _GLOBAL_LEFT, FALSE, 'getAdminViewItemLink'));
- Exclude checks
TRUE, FALSE and NULL must be lowercase; expected "false" but found "FALSE" Open
function editblock($bid = 0, $clone = FALSE) {
- Exclude checks
TRUE, FALSE and NULL must be lowercase; expected "true" but found "TRUE" Open
if (in_array($clean_op, $valid_op, TRUE)) {
- Exclude checks
There must be no space before the colon in a CASE statement Open
case "up" :
- Exclude checks
TRUE, FALSE and NULL must be lowercase; expected "true" but found "TRUE" Open
$changed = TRUE;
- Exclude checks
There must be no space before the colon in a DEFAULT statement Open
default :
- Exclude checks
There must be no space before the colon in a CASE statement Open
case "down" :
- Exclude checks
There must be no space before the colon in a CASE statement Open
case "addblock" :
- Exclude checks
TRUE, FALSE and NULL must be lowercase; expected "false" but found "FALSE" Open
$objectTable->addColumn(new icms_ipf_view_Column('weight', 'center', FALSE, 'getWeightControl'));
- Exclude checks
TRUE, FALSE and NULL must be lowercase; expected "false" but found "FALSE" Open
$objectTable->addColumn(new icms_ipf_view_Column('side', 'center', FALSE, 'getSideControl'));
- Exclude checks
There must be no space before the colon in a CASE statement Open
case "clone" :
- Exclude checks
There must be no space before the colon in a CASE statement Open
case "mod" :
- Exclude checks
There must be no space before the colon in a CASE statement Open
case "del" :
- Exclude checks
TRUE, FALSE and NULL must be lowercase; expected "false" but found "FALSE" Open
$objectTable->addActionButton('change_blocks', FALSE, _SUBMIT);
- Exclude checks
TRUE, FALSE and NULL must be lowercase; expected "false" but found "FALSE" Open
$changed = FALSE;
- Exclude checks
TRUE, FALSE and NULL must be lowercase; expected "true" but found "TRUE" Open
$changed = TRUE;
- Exclude checks
There must be no space before the colon in a CASE statement Open
case 'visible' :
- Exclude checks
TRUE, FALSE and NULL must be lowercase; expected "true" but found "TRUE" Open
editblock($clean_bid, TRUE);
- Exclude checks
There must be no space before the colon in a CASE statement Open
case "changedField" :
- Exclude checks
There must be no space before the colon in a CASE statement Open
case "change_blocks" :
- Exclude checks
Inline control structures are not allowed Open
if (isset($_GET['op']))
- Exclude checks
Inline control structures are not allowed Open
if (isset($_POST['op']))
- Exclude checks
Inline control structures are not allowed Open
if (!$blockObj->isNew() && $blockObj->getVar('edit_func') != '') $blockObj->showFieldOnForm('options');
- Exclude checks
Expected 1 space after SWITCH keyword; 0 found Open
switch($clean_op) {
- Exclude checks
The variable $icms_block_handler is not named in camelCase. Open
function editblock($bid = 0, $clone = FALSE) {
global $icms_block_handler, $icmsAdminTpl;
$blockObj = $icms_block_handler->get($bid);
- 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 $icms_block_handler is not named in camelCase. Open
function editblock($bid = 0, $clone = FALSE) {
global $icms_block_handler, $icmsAdminTpl;
$blockObj = $icms_block_handler->get($bid);
- 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 $icms_block_handler is not named in camelCase. Open
function editblock($bid = 0, $clone = FALSE) {
global $icms_block_handler, $icmsAdminTpl;
$blockObj = $icms_block_handler->get($bid);
- 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();
}
}