Function save
has a Cognitive Complexity of 53 (exceeds 5 allowed). Consider refactoring. Open
public function save(App\Request $request): void
{
$fieldId = $request->getInteger('fieldid');
if (empty($fieldId)) {
throw new \App\Exceptions\AppException('Empty field ID: ' . $fieldId);
- 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 save
has 92 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function save(App\Request $request): void
{
$fieldId = $request->getInteger('fieldid');
if (empty($fieldId)) {
throw new \App\Exceptions\AppException('Empty field ID: ' . $fieldId);
The class Settings_LayoutEditor_Field_Action has an overall complexity of 53 which is very high. The configured complexity threshold is 50. Open
class Settings_LayoutEditor_Field_Action extends Settings_Vtiger_Index_Action
{
/**
* Constructor.
*/
- Exclude checks
Function validate
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function validate(App\Request $request): void
{
$data = [];
$qualifiedModule = $request->getModule(false);
foreach (['fieldType', 'fieldLabel', 'fieldName', 'pickListValues'] as $name) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
The method save() has an NPath complexity of 4160. The configured NPath complexity threshold is 200. Open
public function save(App\Request $request): void
{
$fieldId = $request->getInteger('fieldid');
if (empty($fieldId)) {
throw new \App\Exceptions\AppException('Empty field ID: ' . $fieldId);
- Read upRead up
- Exclude checks
NPathComplexity
Since: 0.1
The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.
Example
class Foo {
function bar() {
// lots of complicated code
}
}
Source https://phpmd.org/rules/codesize.html#npathcomplexity
The method save() has a Cyclomatic Complexity of 30. The configured cyclomatic complexity threshold is 10. Open
public function save(App\Request $request): void
{
$fieldId = $request->getInteger('fieldid');
if (empty($fieldId)) {
throw new \App\Exceptions\AppException('Empty field ID: ' . $fieldId);
- 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
Refactor this function to reduce its Cognitive Complexity from 60 to the 15 allowed. Open
public function save(App\Request $request): void
- Read upRead up
- Exclude checks
Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.
See
Avoid using undefined variables such as '$data' which will lead to PHP notices. Open
$data['class'] = $request->getByType('header_class', \App\Purifier::STANDARD);
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Avoid using undefined variables such as '$data' which will lead to PHP notices. Open
} elseif ('value' === $data['type'] && $fieldInstance->isReferenceField() && ($relFields = $request->getArray('header_rel_fields', \App\Purifier::ALNUM))) {
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Avoid using undefined variables such as '$data' which will lead to PHP notices. Open
$data['type'] = $request->getByType('header_type', \App\Purifier::STANDARD);
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Avoid using undefined variables such as '$data' which will lead to PHP notices. Open
if ('highlights' === $data['type']) {
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Avoid using undefined variables such as '$data' which will lead to PHP notices. Open
$value = \App\Json::encode($data);
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Avoid using undefined variables such as '$data' which will lead to PHP notices. Open
$data['rel_fields'][] = $fieldName;
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
The class Settings_LayoutEditor_Field_Action has a coupling between objects value of 16. Consider to reduce the number of dependencies under 13. Open
class Settings_LayoutEditor_Field_Action extends Settings_Vtiger_Index_Action
{
/**
* Constructor.
*/
- Read upRead up
- Exclude checks
CouplingBetweenObjects
Since: 1.1.0
A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability
Example
class Foo {
/**
* @var \foo\bar\X
*/
private $x = null;
/**
* @var \foo\bar\Y
*/
private $y = null;
/**
* @var \foo\bar\Z
*/
private $z = null;
public function setFoo(\Foo $foo) {}
public function setBar(\Bar $bar) {}
public function setBaz(\Baz $baz) {}
/**
* @return \SplObjectStorage
* @throws \OutOfRangeException
* @throws \InvalidArgumentException
* @throws \ErrorException
*/
public function process(\Iterator $it) {}
// ...
}
Source https://phpmd.org/rules/design.html#couplingbetweenobjects
Missing class import via use statement (line '316', 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 '289', 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 '204', 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 '118', column '19'). Open
throw new \App\Exceptions\IllegalValue('ERR_NOT_ALLOWED_VALUE||' . 'header_type', 406);
- 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 '233', 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 '83', 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 '171', 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 '45', 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 '247', 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 '275', 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 '102', column '14'). Open
throw new \App\Exceptions\AppException('Empty field ID: ' . $fieldId);
- 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 '\App\Language' in method 'save'. Open
'label' => \App\Language::translate($fieldInstance->get('label'), $request->getByType('sourceModule', 2)), ]);
- 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 'Settings_LayoutEditor_Field_Model' in method 'delete'. Open
$fieldInstance = Settings_LayoutEditor_Field_Model::getInstance($request->getInteger('fieldid'));
- 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 delete uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
try {
$fieldInstance->delete();
$response->setResult(['success' => true]);
} catch (Exception $e) {
- 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_Field_Model' in method 'getPicklist'. Open
$fieldInstance = Vtiger_Field_Model::getInstance($fieldName, $moduleModel);
- 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 '123', column '86'). Open
public function save(App\Request $request): void
{
$fieldId = $request->getInteger('fieldid');
if (empty($fieldId)) {
throw new \App\Exceptions\AppException('Empty field ID: ' . $fieldId);
- 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\Json' in method 'save'. Open
$value = \App\Json::encode($data);
- 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\Json' in method 'save'. Open
$fieldInstance->set('fieldparams', $params ? \App\Json::encode($params) : '');
- 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 'delete'. Open
$response->setResult(['success' => false, 'message' => \App\Language::translate('LBL_NON_CUSTOM_FIELD_CANNOT_DELETE', 'Settings::LayoutEditor')]);
- 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\Fields\Picklist' in method 'checkPicklistExist'. Open
$response->setResult(\App\Fields\Picklist::isPicklistExist($request->getByType('fieldName', 'Alnum')));
- 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 save uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$value = '';
}
- 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 'Settings_LayoutEditor_Block_Model' in method 'move'. Open
Settings_LayoutEditor_Block_Model::updateFieldSequenceNumber($request->getMultiDimensionArray('updatedFields',
[
'block' => 'Integer',
'fieldid' => 'Integer',
'sequence' => 'Integer',
- 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 validate uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$value = $request->getByType($name, \App\Purifier::TEXT);
}
- 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 assigning values to variables in if clauses and the like (line '146', column '42'). Open
public function save(App\Request $request): void
{
$fieldId = $request->getInteger('fieldid');
if (empty($fieldId)) {
throw new \App\Exceptions\AppException('Empty field ID: ' . $fieldId);
- 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 'Vtiger_Module_Model' in method 'getPicklist'. Open
$moduleModel = Vtiger_Module_Model::getInstance($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_Module_Model' in method 'save'. Open
$relModuleModel = \Vtiger_Module_Model::getInstance(current($fieldInstance->getReferenceList()));
- 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 'Settings_LayoutEditor_Field_Model' in method 'unHide'. Open
Settings_LayoutEditor_Field_Model::makeFieldActive($fieldIds, $request->getInteger('blockId'));
- 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 'Settings_LayoutEditor_Field_Model' in method 'save'. Open
$fieldInstance = Settings_LayoutEditor_Field_Model::getInstance($fieldId);
- 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 'Settings_LayoutEditor_Field_Model' in method 'unHide'. Open
$fieldModel = Settings_LayoutEditor_Field_Model::getInstance($fieldId);
- 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 'Settings_Vtiger_Tracker_Model' in method '__construct'. Open
Settings_Vtiger_Tracker_Model::addBasic('save');
- 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 save uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$fieldInstance->set('defaultvalue', '');
}
- 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
Define a constant instead of duplicating this literal "success" 4 times. Open
'success' => true,
- 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 "label" 3 times. Open
case 'label':
- 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 "defaultvalue" 3 times. Open
if ($request->has('defaultvalue')) {
- 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" 4 times. Open
'block' => '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 "fieldid" 3 times. Open
$fieldId = $request->getInteger('fieldid');
- 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 "Alnum" 7 times. Open
$type = $request->getByType('fieldType', 'Alnum');
- 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 "blockid" 3 times. Open
$blockId = $request->getInteger('blockid');
- 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 "header_type" 3 times. Open
if (!\in_array($request->getByType('header_type', \App\Purifier::STANDARD), $uitypeModel->getHeaderTypes())) {
- 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 "sourceModule" 4 times. Open
$moduleName = $request->getByType('sourceModule', 'Alnum');
- 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 "anonymizationTarget" 3 times. Open
if ($request->has('anonymizationTarget')) {
- 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.
Argument 1 (value)
is int
but \Settings_LayoutEditor_Field_Model::getInstance()
takes string
defined at /code/modules/Settings/LayoutEditor/models/Field.php:359
Open
$fieldInstance = Settings_LayoutEditor_Field_Model::getInstance($request->getInteger('fieldid'));
- Exclude checks
Variable $data
was undeclared, but array fields are being added to it. Open
$data['type'] = $request->getByType('header_type', \App\Purifier::STANDARD);
- Exclude checks
Argument 1 (value)
is int
but \Settings_LayoutEditor_Field_Model::getInstance()
takes string
defined at /code/modules/Settings/LayoutEditor/models/Field.php:359
Open
$fieldInstance = Settings_LayoutEditor_Field_Model::getInstance($fieldId);
- Exclude checks
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class Settings_LayoutEditor_Field_Action extends Settings_Vtiger_Index_Action
- Exclude checks
The class Settings_LayoutEditor_Field_Action is not named in CamelCase. Open
class Settings_LayoutEditor_Field_Action extends Settings_Vtiger_Index_Action
{
/**
* Constructor.
*/
- 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 to indent lines; tabs are not allowed Open
parent::__construct();
- 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
$this->exposeMethod('checkPicklistExist');
- 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 add(App\Request $request): void
- 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
$this->exposeMethod('delete');
- 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('move');
- 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('getPicklist');
- 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
$this->exposeMethod('validate');
- 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('save');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->exposeMethod('unHide');
- 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
* Create field.
- 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
$this->exposeMethod('createSystemField');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Settings_Vtiger_Tracker_Model::addBasic('save');
- 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
throw new \App\Exceptions\AppException('Empty field ID: ' . $fieldId);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} elseif ('value' === $data['type'] && $fieldInstance->isReferenceField() && ($relFields = $request->getArray('header_rel_fields', \App\Purifier::ALNUM))) {
- 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
case 'quickcreate':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldVal = null;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($request->getBoolean('defaultvalue')) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} catch (Exception $e) {
- 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
$data[$name] = $value;
- 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
$params['mask'] = $request->getByType('fieldMask', 'Text');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'presence' => $request->getBoolean('presence') ? '1' : '0',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$type = $request->getByType('fieldType', 'Alnum');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$moduleModel = Settings_LayoutEditor_Module_Model::getInstance($request->getModule(false))->setSourceModule($moduleName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($request->has($name)) {
- 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
switch ($field) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
throw new \App\Exceptions\IllegalValue('ERR_NOT_ALLOWED_VALUE||' . 'header_type', 406);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$data['type'] = $request->getByType('header_type', \App\Purifier::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
}
- 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
* @param \App\Request $request
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ('pickListValues' === $name) {
- 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
* Save field.
- Exclude checks
Line exceeds 120 characters; contains 138 characters Open
if (!\in_array($request->getByType('header_type', \App\Purifier::STANDARD), $uitypeModel->getHeaderTypes())) {
- 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 ('highlights' === $data['type']) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$relModuleModel = \Vtiger_Module_Model::getInstance(current($fieldInstance->getReferenceList()));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($fieldInstance->get('quickcreate') !== $quickCreateValue && $quickCreateValue > 0) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$iconField = $fieldInstance->getFieldItemByName($field);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
unset($params['mask']);
- 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
'label' => \App\Language::translate($fieldInstance->get('label'), $request->getByType('sourceModule', 2)), ]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldInfo = $fieldModel->getFieldInfo();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'id' => $fieldModel->getId(),
- 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
foreach (['fieldType', 'fieldLabel', 'fieldName', 'pickListValues'] as $name) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$value = $request->getArray($name, \App\Purifier::TEXT);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @throws \App\Exceptions\AppException
- 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 (!\in_array($request->getByType('header_type', \App\Purifier::STANDARD), $uitypeModel->getHeaderTypes())) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($relFields as $fieldName) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$data['rel_fields'][] = $fieldName;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldInstance->set($field, $request->getInteger($field));
- 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
$response->setResult($responseData);
- Exclude checks
Line exceeds 120 characters; contains 129 characters Open
$moduleModel = Settings_LayoutEditor_Module_Model::getInstance($request->getModule(false))->setSourceModule($moduleName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function validate(App\Request $request): void
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$uitypeModel = $fieldInstance->getUITypeModel();
- 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 ($request->getBoolean($field)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldId = $request->getInteger('fieldid');
- Exclude checks
Line exceeds 120 characters; contains 184 characters Open
} elseif ('value' === $data['type'] && $fieldInstance->isReferenceField() && ($relFields = $request->getArray('header_rel_fields', \App\Purifier::ALNUM))) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
break;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
break;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$data['class'] = $request->getByType('header_class', \App\Purifier::STANDARD);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$quickCreateValue = $request->getInteger($field);
- 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
$responseData = array_merge([
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($request->has('fieldMask')) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldInstance->set('quicksequence', $fieldInstance->__getNextQuickCreateSequence());
- 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
$params = $fieldInstance->getFieldParams();
- 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
$fieldInstance->set('anonymizationTarget', $request->getArray('anonymizationTarget', \App\Purifier::INTEGER));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldInstance->set($field, $quickCreateValue);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$moduleModel = Settings_LayoutEditor_Module_Model::getInstance($qualifiedModule)->setSourceModule($request->getByType('sourceModule', \App\Purifier::ALNUM));
- 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([
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldInstance = Settings_LayoutEditor_Field_Model::getInstance($fieldId);
- 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
$fieldInstance->set($field, $value);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldUITypeModel = $iconField->getUITypeModel();
- 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
'mandatory' => $fieldInstance->isMandatory(),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$qualifiedModule = $request->getModule(false);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$response->setResult($moduleModel->validate($data, false));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
break;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$value = \App\Json::encode($data);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'icon':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (empty($params['mask'])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
try {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldModel = $moduleModel->addField($type, $blockId, $request->getAll());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$response->setError($e->getCode(), $e->getMessage());
- 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
$data = [];
- 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
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!$request->isEmpty($field) && ($value = $request->getByType($field, \App\Purifier::TEXT))) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
break;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldInstance->set('defaultvalue', '');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$blockId = $request->getInteger('blockid');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'customField' => $fieldModel->isCustomField(), ], $fieldInfo);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach (Settings_LayoutEditor_Module_Model::EDIT_FIELDS_FORM as $field) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldInstance->updateTypeofDataFromMandatory($request->getByType($field, \App\Purifier::STANDARD));
- Exclude checks
Line exceeds 120 characters; contains 124 characters Open
$fieldInstance->updateTypeofDataFromMandatory($request->getByType($field, \App\Purifier::STANDARD));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
break;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
default:
- 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->emit();
- 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 void
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($request->has($field)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'mandatory':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'label':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldInstance->set($field, $request->getByType($field, \App\Purifier::TEXT));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'blockid' => $blockId,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Validate field.
- 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 void
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$value = $request->getByType($name, \App\Purifier::TEXT);
- 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
case 'header_field':
- 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
$value = '';
- 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
$fieldInstance->set('fieldparams', $params ? \App\Json::encode($params) : '');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Line exceeds 120 characters; contains 122 characters Open
$fieldInstance->set('anonymizationTarget', $request->getArray('anonymizationTarget', \App\Purifier::INTEGER));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$moduleName = $request->getByType('sourceModule', 'Alnum');
- 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
Line exceeds 120 characters; contains 165 characters Open
$moduleModel = Settings_LayoutEditor_Module_Model::getInstance($qualifiedModule)->setSourceModule($request->getByType('sourceModule', \App\Purifier::ALNUM));
- 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
$fieldInstance->set('icon', $fieldVal);
- 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
'success' => true,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'name' => $fieldModel->get('name'),
- Exclude checks
Line exceeds 120 characters; contains 129 characters Open
$relModuleModel = \Vtiger_Module_Model::getInstance(current($fieldInstance->getReferenceList()));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($relModuleModel->getFieldByName($fieldName)->isViewableInDetailView()) {
- 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
$fieldVal = $iconField->getDBValue($value);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
break;
- 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('defaultvalue')) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$uitypeModel->setDefaultValueFromRequest($request);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldInstance->save();
- 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
* @throws \App\Exceptions\IllegalValue
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function save(App\Request $request): void
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (empty($fieldId)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldUITypeModel->validate($value, true);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($request->has('anonymizationTarget')) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
try {
- 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
$response->setResult($responseData);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$picklistValues = [];
- 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
} catch (Exception $e) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$response->setResult(['success' => false, 'message' => \App\Language::translate('LBL_NON_CUSTOM_FIELD_CANNOT_DELETE', 'Settings::LayoutEditor')]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldModel = Settings_LayoutEditor_Field_Model::getInstance($fieldId);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} catch (Exception $e) {
- 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
try {
- 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
try {
- 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
*
- 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
* @return void
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} catch (Exception $e) {
- 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
$fieldInstance = Vtiger_Field_Model::getInstance($fieldName, $moduleModel);
- 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
$moduleModel = Settings_LayoutEditor_Module_Model::getInstance($request->getModule(false))->setSourceModule($moduleName);
- 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
}
- Exclude checks
Line exceeds 120 characters; contains 129 characters Open
$moduleModel = Settings_LayoutEditor_Module_Model::getInstance($request->getModule(false))->setSourceModule($moduleName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Check if picklist exist.
- 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
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Create system field.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
try {
- 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->emit();
- 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
* @return 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
* @return void
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Settings_LayoutEditor_Block_Model::updateFieldSequenceNumber($request->getMultiDimensionArray('updatedFields',
- 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 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
public function getPicklist(App\Request $request): void
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!empty($fieldName) && !empty($moduleName) && '-' != $fieldName) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$moduleModel = Vtiger_Module_Model::getInstance($moduleName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$picklistValues = [];
- 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
$response = new Vtiger_Response();
- 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
$fieldInstance->delete();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function unHide(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
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function checkPicklistExist(App\Request $request): void
- 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
$response->emit();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldInstance = Settings_LayoutEditor_Field_Model::getInstance($request->getInteger('fieldid'));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$responseData[] = array_merge(['id' => $fieldModel->getId(), 'blockid' => $fieldModel->get('block')->id, 'customField' => $fieldModel->isCustomField()], $fieldInfo);
- Exclude checks
Line exceeds 120 characters; contains 185 characters Open
$responseData[] = array_merge(['id' => $fieldModel->getId(), 'blockid' => $fieldModel->get('block')->id, 'customField' => $fieldModel->isCustomField()], $fieldInfo);
- 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
* @param \App\Request $request
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$response->setResult($picklistValues);
- 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
* Delete field.
- 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 delete(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
*
- 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
*/
- 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
$response->emit();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldName = $request->getByType('rfield', 'Alnum');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$picklistValues = $fieldInstance->getPicklistValues();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$response->setError($e->getCode(), $e->getMessage());
- 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 (!$fieldInstance->isCustomField()) {
- 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
* Make field active.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$responseData = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldInfo = $fieldModel->getFieldInfo();
- 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', 'Alnum');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$moduleModel->addSystemField($request->getByType('field', 'Alnum'), $request->getInteger('blockId'), [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'generatedtype' => 2,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} catch (Error $e) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} catch (Exception $e) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Move field.
- 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
Settings_LayoutEditor_Field_Model::makeFieldActive($fieldIds, $request->getInteger('blockId'));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($fieldIds as $fieldId) {
- 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
$response->setResult(\App\Fields\Picklist::isPicklistExist($request->getByType('fieldName', 'Alnum')));
- 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
$response->setError($e->getCode(), $e->getMessage());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'fieldid' => 'Integer',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!empty($fieldIds)) {
- 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
$response->setError($e->getCode(), $e->getMessage());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function move(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
$response->setResult(['success' => true]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldIds = $request->getArray('fieldIdList', '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
* Get picklist values.
- 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(['success' => true]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'block' => 'Integer',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (null === $picklistValues) {
- Exclude checks
Line exceeds 120 characters; contains 126 characters Open
'label' => \App\Language::translate($fieldInstance->get('label'), $request->getByType('sourceModule', 2)), ]);
- Exclude checks
Line exceeds 120 characters; contains 158 characters Open
$response->setResult(['success' => false, 'message' => \App\Language::translate('LBL_NON_CUSTOM_FIELD_CANNOT_DELETE', 'Settings::LayoutEditor')]);
- 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
$response->setError($e->getCode(), $e->getMessage());
- 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
* @param \App\Request $request
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'sequence' => 'Integer',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$response->setError($e->getCode(), $e->getMessage());
- 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
$response->emit();
- 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
*/
- 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
$moduleName = $request->getByType('rmodule', 'Alnum');
- 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 createSystemField(App\Request $request): void
- Exclude checks
Class name "Settings_LayoutEditor_Field_Action" is not in camel caps format Open
class Settings_LayoutEditor_Field_Action extends Settings_Vtiger_Index_Action
- Exclude checks
Opening parenthesis of a multi-line function call must be the last content on the line Open
Settings_LayoutEditor_Block_Model::updateFieldSequenceNumber($request->getMultiDimensionArray('updatedFields',
- Exclude checks
Multi-line function call not indented correctly; expected 12 spaces but found 8 Open
[
- Exclude checks
Closing parenthesis of a multi-line function call must be on a line by itself Open
]));
- Exclude checks