Consider simplifying this complex logical expression. Open
if (('updateWidgetConfig' === $mode && $request->has('widgetid') && $widget->get('active'))
|| (('remove' === $mode || 'removeWidgetFromList' === $mode) && !$widget->isDefault() && \App\Privilege::isPermitted($moduleName))
|| (('positions' === $mode || 'clear' === $mode) && \App\Privilege::isPermitted($moduleName))
|| 'add' === $mode) {
return true;
Function positions
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public function positions(App\Request $request): void
{
$currentUserId = App\User::getCurrentUserId();
if ($positionsMap = $request->getMultiDimensionArray('position', [['row' => 'Integer', 'col' => 'Integer']])) {
foreach ($positionsMap as $id => $position) {
- 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 add
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function add(App\Request $request)
{
$moduleName = $request->getByType('sourceModule', \App\Purifier::ALNUM);
$data = $request->getMultiDimensionArray('form', [
'data' => 'Text',
Function checkPermission
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function checkPermission(App\Request $request)
{
$moduleName = $request->getModule();
$mode = $request->getMode();
if ($request->has('widgetid')) {
- 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 checkPermission() has a Cyclomatic Complexity of 14. The configured cyclomatic complexity threshold is 10. Open
public function checkPermission(App\Request $request)
{
$moduleName = $request->getModule();
$mode = $request->getMode();
if ($request->has('widgetid')) {
- 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
Missing class import via use statement (line '55', column '13'). Open
throw new \App\Exceptions\NoPermitted('LBL_PERMISSION_DENIED');
- 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
Missing class import via use statement (line '128', column '19'). Open
$response = new Vtiger_Response();
- 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
Missing class import via use statement (line '141', column '19'). Open
$response = new Vtiger_Response();
- 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
Missing class import via use statement (line '125', column '34'). Open
$widgetsManagementModel = new Settings_WidgetsManagement_Module_Model();
- 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
Missing class import via use statement (line '163', column '19'). Open
$response = new Vtiger_Response();
- 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
Missing class import via use statement (line '66', column '19'). Open
$response = new Vtiger_Response();
- 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
Missing class import via use statement (line '122', column '14'). Open
throw new \App\Exceptions\NoPermitted('LBL_PERMISSION_DENIED');
- 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
Missing class import via use statement (line '199', column '19'). Open
$response = new Vtiger_Response();
- 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 'Vtiger_Widget_Model' in method 'removeWidgetFromList'. Open
Vtiger_Widget_Model::removeWidgetFromList($request->getInteger('widgetid'));
- 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 assigning values to variables in if clauses and the like (line '188', column '7'). Open
public function positions(App\Request $request): void
{
$currentUserId = App\User::getCurrentUserId();
if ($positionsMap = $request->getMultiDimensionArray('position', [['row' => 'Integer', 'col' => 'Integer']])) {
foreach ($positionsMap as $id => $position) {
- Read upRead up
- Exclude checks
IfStatementAssignment
Since: 2.7.0
Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.
Example
class Foo
{
public function bar($flag)
{
if ($foo = 'bar') { // possible typo
// ...
}
if ($baz = 0) { // always false
// ...
}
}
}
Source http://phpmd.org/rules/cleancode.html#ifstatementassignment
Avoid using static access to class 'App\User' in method 'positions'. Open
$currentUserId = App\User::getCurrentUserId();
- 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 'Vtiger_Widget_Model' in method 'checkPermission'. Open
$widget = Vtiger_Widget_Model::getInstance($request->getInteger('linkid'), \App\User::getCurrentUserId());
- 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 'Vtiger_Widget_Model' in method 'remove'. Open
$widget = Vtiger_Widget_Model::getInstanceWithWidgetId($request->getInteger('widgetid'), \App\User::getCurrentUserId());
- 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 'Vtiger_Widget_Model' in method 'remove'. Open
$widget = Vtiger_Widget_Model::getInstance($linkId, \App\User::getCurrentUserId());
- 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 '\App\User' in method 'remove'. Open
$widget = Vtiger_Widget_Model::getInstance($linkId, \App\User::getCurrentUserId());
- 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
The method add uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$data['linkid'] = $request->getInteger('linkid');
$widgetsManagementModel = new Settings_WidgetsManagement_Module_Model();
$result = $widgetsManagementModel->addWidget($data, $moduleName, $request->getBoolean('addToUser'));
}
- 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 '\App\User' in method 'remove'. Open
$widget = Vtiger_Widget_Model::getInstanceWithWidgetId($request->getInteger('widgetid'), \App\User::getCurrentUserId());
- 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 'Vtiger_Widget_Model' in method 'updateWidgetConfig'. Open
$widget = Vtiger_Widget_Model::getInstanceWithWidgetId($widgetId, \App\User::getCurrentUserId());
- 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 '\App\Privilege' in method 'checkPermission'. Open
|| (('positions' === $mode || 'clear' === $mode) && \App\Privilege::isPermitted($moduleName))
- 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
The method remove uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$widget = Vtiger_Widget_Model::getInstance($linkId, \App\User::getCurrentUserId());
}
- 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 '\App\Language' in method 'remove'. Open
'title' => \App\Language::translate($widget->getTitle(), $request->getModule()),
- 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 '\App\User' in method 'updateWidgetConfig'. Open
$widget = Vtiger_Widget_Model::getInstanceWithWidgetId($widgetId, \App\User::getCurrentUserId());
- 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 'Vtiger_Widget_Model' in method 'checkPermission'. Open
$widget = Vtiger_Widget_Model::getInstanceWithWidgetId($request->getInteger('widgetid'), \App\User::getCurrentUserId());
- 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 'Vtiger_Widget_Model' in method 'clear'. Open
Vtiger_Widget_Model::clearDeviceConf(Vtiger_Widget_Model::getDashboardId($request));
- 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 '\App\Privilege' in method 'checkPermission'. Open
|| (('remove' === $mode || 'removeWidgetFromList' === $mode) && !$widget->isDefault() && \App\Privilege::isPermitted($moduleName))
- 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 'Vtiger_Widget_Model' in method 'positions'. Open
Vtiger_Widget_Model::updateWidgetSize($size, null, (int) $widgetId, $currentUserId);
- 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 'Vtiger_Widget_Model' in method 'clear'. Open
Vtiger_Widget_Model::clearDeviceConf(Vtiger_Widget_Model::getDashboardId($request));
- 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 '\App\User' in method 'checkPermission'. Open
$widget = Vtiger_Widget_Model::getInstanceWithWidgetId($request->getInteger('widgetid'), \App\User::getCurrentUserId());
- 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 'App\User' in method 'updateWidgetConfig'. Open
['userid' => App\User::getCurrentUserId(), 'id' => $widgetId])
- 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
The method positions uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
Vtiger_Widget_Model::updateWidgetSize($size, (int) $linkId, null, $currentUserId);
}
- 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 'Vtiger_Widget_Model' in method 'positions'. Open
Vtiger_Widget_Model::updateWidgetPosition($position, null, (int) $widgetId, $currentUserId);
- 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 '\App\Language' in method 'add'. Open
$result = ['success' => false, 'message' => \App\Language::translate('LBL_INVALID_DATA', $moduleName)];
- 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 '\vtlib\Link' in method 'add'. Open
} elseif (!Vtiger_Widget_Model::getInstanceFromValues(array_merge($data, \vtlib\Link::getLinkData($request->getInteger('linkid'))))->isCreatable()) {
- 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 'Vtiger_Loader' in method 'updateWidgetConfig'. Open
$className = Vtiger_Loader::getComponentClassName('Dashboard', $widget->get('linklabel'), $moduleName);
- 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 assigning values to variables in if clauses and the like (line '178', column '7'). Open
public function positions(App\Request $request): void
{
$currentUserId = App\User::getCurrentUserId();
if ($positionsMap = $request->getMultiDimensionArray('position', [['row' => 'Integer', 'col' => 'Integer']])) {
foreach ($positionsMap as $id => $position) {
- Read upRead up
- Exclude checks
IfStatementAssignment
Since: 2.7.0
Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.
Example
class Foo
{
public function bar($flag)
{
if ($foo = 'bar') { // possible typo
// ...
}
if ($baz = 0) { // always false
// ...
}
}
}
Source http://phpmd.org/rules/cleancode.html#ifstatementassignment
Avoid using static access to class '\App\User' in method 'checkPermission'. Open
$widget = Vtiger_Widget_Model::getInstance($request->getInteger('linkid'), \App\User::getCurrentUserId());
- 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
The method positions uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
Vtiger_Widget_Model::updateWidgetPosition($position, (int) $linkId, null, $currentUserId);
}
- 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 'Vtiger_Widget_Model' in method 'positions'. Open
Vtiger_Widget_Model::updateWidgetPosition($position, (int) $linkId, null, $currentUserId);
- 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 'Vtiger_Widget_Model' in method 'positions'. Open
Vtiger_Widget_Model::updateWidgetSize($size, (int) $linkId, null, $currentUserId);
- 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
Define a constant instead of duplicating this literal "Standard" 6 times. Open
'Standard',
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "Integer" 14 times. Open
'blockid' => 'Integer',
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "widgetid" 7 times. Open
if ($request->has('widgetid')) {
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "linkid" 7 times. Open
$widget = Vtiger_Widget_Model::getInstance($request->getInteger('linkid'), \App\User::getCurrentUserId());
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Call to method getCurrentUserId
from undeclared class \App\User
(Did you mean class \Tests\App\User) Open
$widget = Vtiger_Widget_Model::getInstance($linkId, \App\User::getCurrentUserId());
- Exclude checks
Call to method removeWidgetFromList
from undeclared class \Vtiger_Widget_Model
Open
Vtiger_Widget_Model::removeWidgetFromList($request->getInteger('widgetid'));
- Exclude checks
Call to method getInstanceWithWidgetId
from undeclared class \Vtiger_Widget_Model
Open
$widget = Vtiger_Widget_Model::getInstanceWithWidgetId($widgetId, \App\User::getCurrentUserId());
- Exclude checks
Call to method getInstance
from undeclared class \Vtiger_Widget_Model
Open
$widget = Vtiger_Widget_Model::getInstance($linkId, \App\User::getCurrentUserId());
- Exclude checks
Call to method getInstanceFromValues
from undeclared class \Vtiger_Widget_Model
Open
} elseif (!Vtiger_Widget_Model::getInstanceFromValues(array_merge($data, \vtlib\Link::getLinkData($request->getInteger('linkid'))))->isCreatable()) {
- Exclude checks
Call to method getInstanceWithWidgetId
from undeclared class \Vtiger_Widget_Model
Open
$widget = Vtiger_Widget_Model::getInstanceWithWidgetId($request->getInteger('widgetid'), \App\User::getCurrentUserId());
- Exclude checks
Call to method getCurrentUserId
from undeclared class \App\User
(Did you mean class \Tests\App\User) Open
$widget = Vtiger_Widget_Model::getInstanceWithWidgetId($request->getInteger('widgetid'), \App\User::getCurrentUserId());
- Exclude checks
Call to method getInstanceWithWidgetId
from undeclared class \Vtiger_Widget_Model
Open
$widget = Vtiger_Widget_Model::getInstanceWithWidgetId($request->getInteger('widgetid'), \App\User::getCurrentUserId());
- Exclude checks
Call to method getCurrentUserId
from undeclared class \App\User
(Did you mean class \Tests\App\User) Open
$widget = Vtiger_Widget_Model::getInstance($request->getInteger('linkid'), \App\User::getCurrentUserId());
- Exclude checks
Call to method get
on non-class type null
Open
if (('updateWidgetConfig' === $mode && $request->has('widgetid') && $widget->get('active'))
- Exclude checks
Call to method getDashboardId
from undeclared class \Vtiger_Widget_Model
Open
Vtiger_Widget_Model::clearDeviceConf(Vtiger_Widget_Model::getDashboardId($request));
- Exclude checks
Call to method updateWidgetPosition
from undeclared class \Vtiger_Widget_Model
Open
Vtiger_Widget_Model::updateWidgetPosition($position, null, (int) $widgetId, $currentUserId);
- Exclude checks
Call to method getCurrentUserId
from undeclared class \App\User
(Did you mean class \Tests\App\User) Open
$currentUserId = App\User::getCurrentUserId();
- Exclude checks
Call to method updateWidgetSize
from undeclared class \Vtiger_Widget_Model
Open
Vtiger_Widget_Model::updateWidgetSize($size, null, (int) $widgetId, $currentUserId);
- Exclude checks
Call to method updateWidgetSize
from undeclared class \Vtiger_Widget_Model
Open
Vtiger_Widget_Model::updateWidgetSize($size, (int) $linkId, null, $currentUserId);
- Exclude checks
Call to method updateWidgetPosition
from undeclared class \Vtiger_Widget_Model
Open
Vtiger_Widget_Model::updateWidgetPosition($position, (int) $linkId, null, $currentUserId);
- Exclude checks
Call to undeclared method \App\Db::createCommand
Open
$result = (bool) \App\Db::getInstance()->createCommand()->update('vtiger_module_dashboard_widgets', ['data' => $widget->get('data')],
- Exclude checks
Call to method getInstance
from undeclared class \Vtiger_Widget_Model
Open
$widget = Vtiger_Widget_Model::getInstance($request->getInteger('linkid'), \App\User::getCurrentUserId());
- Exclude checks
Call to method isDefault
on non-class type null
Open
|| (('remove' === $mode || 'removeWidgetFromList' === $mode) && !$widget->isDefault() && \App\Privilege::isPermitted($moduleName))
- Exclude checks
Call to method getCurrentUserId
from undeclared class \App\User
(Did you mean class \Tests\App\User) Open
$widget = Vtiger_Widget_Model::getInstanceWithWidgetId($request->getInteger('widgetid'), \App\User::getCurrentUserId());
- Exclude checks
Call to method getCurrentUserId
from undeclared class \App\User
(Did you mean class \Tests\App\User) Open
$widget = Vtiger_Widget_Model::getInstanceWithWidgetId($widgetId, \App\User::getCurrentUserId());
- Exclude checks
Call to method getCurrentUserId
from undeclared class \App\User
(Did you mean class \Tests\App\User) Open
['userid' => App\User::getCurrentUserId(), 'id' => $widgetId])
- Exclude checks
Call to method clearDeviceConf
from undeclared class \Vtiger_Widget_Model
Open
Vtiger_Widget_Model::clearDeviceConf(Vtiger_Widget_Model::getDashboardId($request));
- Exclude checks
Similar blocks of code found in 2 locations. Consider refactoring. Open
if ($positionsMap = $request->getMultiDimensionArray('position', [['row' => 'Integer', 'col' => 'Integer']])) {
foreach ($positionsMap as $id => $position) {
[$linkId, $widgetId] = array_pad(explode('-', $id), 2, false);
if ($widgetId) {
Vtiger_Widget_Model::updateWidgetPosition($position, null, (int) $widgetId, $currentUserId);
- 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 137.
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 2 locations. Consider refactoring. Open
if ($sizesMap = $request->getMultiDimensionArray('size', [['width' => 'Integer', 'height' => 'Integer']])) {
foreach ($sizesMap as $id => $size) {
[$linkId, $widgetId] = array_pad(explode('-', $id), 2, false);
if ($widgetId) {
Vtiger_Widget_Model::updateWidgetSize($size, null, (int) $widgetId, $currentUserId);
- 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 137.
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
Avoid excessively long variable names like $widgetsManagementModel. Keep variable name length under 20. Open
$widgetsManagementModel = new Settings_WidgetsManagement_Module_Model();
- Read upRead up
- Exclude checks
LongVariable
Since: 0.2
Detects when a field, formal or local variable is declared with a long name.
Example
class Something {
protected $reallyLongIntName = -3; // VIOLATION - Field
public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
$otherReallyLongName = -5; // VIOLATION - Local
for ($interestingIntIndex = 0; // VIOLATION - For
$interestingIntIndex < 10;
$interestingIntIndex++ ) {
}
}
}
Source https://phpmd.org/rules/naming.html#longvariable
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class Vtiger_Widget_Action extends \App\Controller\Action
- Exclude checks
The class Vtiger_Widget_Action is not named in CamelCase. Open
class Vtiger_Widget_Action extends \App\Controller\Action
{
use \App\Controller\ExposeMethod;
/**
- 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
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if ($widgetId) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @return void
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Vtiger_Widget_Model::updateWidgetSize($size, (int) $linkId, null, $currentUserId);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
[$linkId, $widgetId] = array_pad(explode('-', $id), 2, false);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Vtiger_Widget_Model::updateWidgetSize($size, null, (int) $widgetId, $currentUserId);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
foreach ($sizesMap as $id => $size) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* Clear configuration of widgets for this device.
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Vtiger_Widget_Model::clearDeviceConf(Vtiger_Widget_Model::getDashboardId($request));
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @param App\Request $request
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
foreach ($positionsMap as $id => $position) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
[$linkId, $widgetId] = array_pad(explode('-', $id), 2, false);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$response->emit();
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if ($sizesMap = $request->getMultiDimensionArray('size', [['width' => 'Integer', 'height' => 'Integer']])) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if ($widgetId) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
*
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Vtiger_Widget_Model::updateWidgetPosition($position, null, (int) $widgetId, $currentUserId);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
header("location: index.php?module={$request->getModule()}&view=DashBoard");
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if ($positionsMap = $request->getMultiDimensionArray('position', [['row' => 'Integer', 'col' => 'Integer']])) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
*
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
public function clear(App\Request $request): void
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
{
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Vtiger_Widget_Model::updateWidgetPosition($position, (int) $linkId, null, $currentUserId);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$response = new Vtiger_Response();
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$response->setResult(true);
- Exclude checks
Only one argument is allowed per line in a multi-line function call Open
$result = (bool) \App\Db::getInstance()->createCommand()->update('vtiger_module_dashboard_widgets', ['data' => $widget->get('data')],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
|| (('remove' === $mode || 'removeWidgetFromList' === $mode) && !$widget->isDefault() && \App\Privilege::isPermitted($moduleName))
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$linkId = $request->getInteger('linkid');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
|| (('positions' === $mode || 'clear' === $mode) && \App\Privilege::isPermitted($moduleName))
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function remove(App\Request $request)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @throws \App\Exceptions\NoPermitted
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$moduleName = $request->getModule();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Constructor.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function __construct()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->exposeMethod('removeWidgetFromList');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function checkPermission(App\Request $request)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (('updateWidgetConfig' === $mode && $request->has('widgetid') && $widget->get('active'))
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return true;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->exposeMethod('remove');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param \App\Request $request
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($request->has('widgetid')) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$widget = Vtiger_Widget_Model::getInstanceWithWidgetId($request->getInteger('widgetid'), \App\User::getCurrentUserId());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Remove widget.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->exposeMethod('add');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->exposeMethod('updateWidgetConfig');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$mode = $request->getMode();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} elseif ('add' !== $mode) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param \App\Request $request
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$widget = Vtiger_Widget_Model::getInstanceWithWidgetId($request->getInteger('widgetid'), \App\User::getCurrentUserId());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$response->emit();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'skip_year' => 'Integer',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'date_fields' => 'Integer',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$result = ['success' => false, 'message' => \App\Language::translate('LBL_INVALID_DATA', $moduleName)];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} elseif (!Vtiger_Widget_Model::getInstanceFromValues(array_merge($data, \vtlib\Link::getLinkData($request->getInteger('linkid'))))->isCreatable()) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$data['linkid'] = $request->getInteger('linkid');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param App\Request $request
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
use \App\Controller\ExposeMethod;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
parent::__construct();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
|| 'add' === $mode) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$widget->remove('hide');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'url' => $widget->getUrl(),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Function to add widget.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'filterid' => 'Text',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'Standard',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'limit' => 'Integer',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$response = new Vtiger_Response();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'owners_all' => [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Function to check permission.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'default_owner' => 'Standard',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param \App\Request $request
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Save updates widget config.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function updateWidgetConfig(App\Request $request)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->exposeMethod('clear');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'title' => 'Text',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'width' => 'Integer',
- Exclude checks
Line exceeds 120 characters; contains 157 characters Open
} elseif (!Vtiger_Widget_Model::getInstanceFromValues(array_merge($data, \vtlib\Link::getLinkData($request->getInteger('linkid'))))->isCreatable()) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Remove widget from list.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param \App\Request $request
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function positions(App\Request $request): void
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->exposeMethod('positions');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Line exceeds 120 characters; contains 132 characters Open
$widget = Vtiger_Widget_Model::getInstanceWithWidgetId($request->getInteger('widgetid'), \App\User::getCurrentUserId());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
throw new \App\Exceptions\NoPermitted('LBL_PERMISSION_DENIED');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function add(App\Request $request)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'data' => 'Text',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$widget = Vtiger_Widget_Model::getInstanceWithWidgetId($widgetId, \App\User::getCurrentUserId());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$data = $request->getArray('widgetData', \App\Purifier::TEXT);
- Exclude checks
Line exceeds 120 characters; contains 141 characters Open
$result = (bool) \App\Db::getInstance()->createCommand()->update('vtiger_module_dashboard_widgets', ['data' => $widget->get('data')],
- Exclude checks
Line exceeds 120 characters; contains 132 characters Open
$widget = Vtiger_Widget_Model::getInstanceWithWidgetId($request->getInteger('widgetid'), \App\User::getCurrentUserId());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'title' => \App\Language::translate($widget->getTitle(), $request->getModule()),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'label' => 'Text',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!\is_array($data) || !$data) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Vtiger_Widget_Model::removeWidgetFromList($request->getInteger('widgetid'));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$response->setResult($result);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$widget = Vtiger_Widget_Model::getInstance($linkId, \App\User::getCurrentUserId());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'dashboardId' => 'Integer',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$moduleName = $request->getByType('sourceModule', \App\Purifier::ALNUM);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'Standard',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'sortOrder' => 'Text',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function removeWidgetFromList(App\Request $request)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$response->emit();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'blockid' => 'Integer',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'linkid' => 'Integer',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$result = $widgetsManagementModel->addWidget($data, $moduleName, $request->getBoolean('addToUser'));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($positionsMap = $request->getMultiDimensionArray('position', [['row' => 'Integer', 'col' => 'Integer']])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$widget = Vtiger_Widget_Model::getInstance($request->getInteger('linkid'), \App\User::getCurrentUserId());
- Exclude checks
Line exceeds 120 characters; contains 142 characters Open
|| (('remove' === $mode || 'removeWidgetFromList' === $mode) && !$widget->isDefault() && \App\Privilege::isPermitted($moduleName))
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'default_date' => 'Standard',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$response->setResult($result);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$response->setResult(true);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$response = new Vtiger_Response();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'name' => $widget->getName(),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param \App\Request $request
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$data = $request->getMultiDimensionArray('form', [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'isdefault' => 'Integer',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'Standard',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'cache' => 'Integer',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$widgetsManagementModel = new Settings_WidgetsManagement_Module_Model();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return void
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$currentUserId = App\User::getCurrentUserId();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'name' => 'Text',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
throw new \App\Exceptions\NoPermitted('LBL_PERMISSION_DENIED');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$widgetId = $request->getInteger('widgetid');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$className = Vtiger_Loader::getComponentClassName('Dashboard', $widget->get('linklabel'), $moduleName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$instance = new $className();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$response = new Vtiger_Response();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($request->has('widgetid')) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'height' => 'Integer',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'Standard',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'deleteFromList' => $widget->isDeletable(),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$response->emit();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$response->emit();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$moduleName = $request->getModule();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$result = (bool) \App\Db::getInstance()->createCommand()->update('vtiger_module_dashboard_widgets', ['data' => $widget->get('data')],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
['userid' => App\User::getCurrentUserId(), 'id' => $widgetId])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Save positions.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$response->setResult(['linkid' => $linkId,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'id' => $widget->get('id'),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$response = new Vtiger_Response();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$instance->setWidgetData($widget, $data);
- Exclude checks
Class name "Vtiger_Widget_Action" is not in camel caps format Open
class Vtiger_Widget_Action extends \App\Controller\Action
- Exclude checks
Closing parenthesis of a multi-line function call must be on a line by itself Open
['userid' => App\User::getCurrentUserId(), 'id' => $widgetId])
- Exclude checks
Opening parenthesis of a multi-line function call must be the last content on the line Open
$result = (bool) \App\Db::getInstance()->createCommand()->update('vtiger_module_dashboard_widgets', ['data' => $widget->get('data')],
- Exclude checks