Function process
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function process(App\Request $request)
{
$fields = Settings_MailIntegration_ConfigForm_Model::getFields($request->getModule(false));
$field = $request->getByType('updateField');
if (!isset($fields[$field])) {
- 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 process
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function process(App\Request $request)
{
$fields = Settings_MailIntegration_ConfigForm_Model::getFields($request->getModule(false));
$field = $request->getByType('updateField');
if (!isset($fields[$field])) {
Missing class import via use statement (line '37', column '19'). Open
$security = new \App\ConfigFile('security');
- 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 '23', column '14'). Open
throw new \App\Exceptions\IllegalValue('ERR_ILLEGAL_VALUE');
- 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 '51', 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 '33', column '21'). Open
$configFile = new \App\ConfigFile('module', 'MailIntegration');
- 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 'Settings_MailIntegration_ConfigForm_Model' in method 'process'. Open
$fields = Settings_MailIntegration_ConfigForm_Model::getFields($request->getModule(false));
- 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 'process'. Open
$response->setResult(['notify' => ['type' => 'success', 'text' => \App\Language::translate('LBL_CHANGES_SAVED')]]);
- 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 '42', column '21'). Open
public function process(App\Request $request)
{
$fields = Settings_MailIntegration_ConfigForm_Model::getFields($request->getModule(false));
$field = $request->getByType('updateField');
if (!isset($fields[$field])) {
- 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
Reference to static property outlookUrls
from undeclared class \Config\Modules\MailIntegration
Open
$oldValue = \Config\Modules\MailIntegration::$outlookUrls;
- Exclude checks
Avoid excessively long class names like Settings_MailIntegration_SaveConfigForm_Action. Keep class name length under 40. Open
class Settings_MailIntegration_SaveConfigForm_Action extends Settings_Vtiger_Basic_Action
{
/** {@inheritdoc} */
public function process(App\Request $request)
{
- Read upRead up
- Exclude checks
LongClassName
Since: 2.9
Detects when classes or interfaces are declared with excessively long names.
Example
class ATooLongClassNameThatHintsAtADesignProblem {
}
interface ATooLongInterfaceNameThatHintsAtADesignProblem {
}
Source https://phpmd.org/rules/naming.html#longclassname
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class Settings_MailIntegration_SaveConfigForm_Action extends Settings_Vtiger_Basic_Action
- Exclude checks
The class Settings_MailIntegration_SaveConfigForm_Action is not named in CamelCase. Open
class Settings_MailIntegration_SaveConfigForm_Action extends Settings_Vtiger_Basic_Action
{
/** {@inheritdoc} */
public function process(App\Request $request)
{
- 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
if (!isset($fields[$field])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$configFile->create();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function process(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
$value = $fieldModel->get('isArray') ? $request->getArray($field, $fieldModel->get('purifyType')) : $request->getByType($field, $fieldModel->get('purifyType'));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$oldValue = \Config\Modules\MailIntegration::$outlookUrls;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ('outlookUrls' === $field) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$configFile->set($field, $value);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$updateValue = array_unique(array_merge((\Config\Security::$allowedFrameDomains), $value));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** {@inheritdoc} */
- 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
$configFile = new \App\ConfigFile('module', 'MailIntegration');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ('outlookUrls' === $field) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (isset($toRemove)) {
- 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->emit();
- Exclude checks
Line exceeds 120 characters; contains 168 characters Open
$value = $fieldModel->get('isArray') ? $request->getArray($field, $fieldModel->get('purifyType')) : $request->getByType($field, $fieldModel->get('purifyType'));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$field = $request->getByType('updateField');
- 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
$security->create();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$security->set('allowedFrameDomains', array_values($updateValue));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fields = Settings_MailIntegration_ConfigForm_Model::getFields($request->getModule(false));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
unset($updateValue[$key]);
- Exclude checks
Line exceeds 120 characters; contains 123 characters Open
$response->setResult(['notify' => ['type' => 'success', 'text' => \App\Language::translate('LBL_CHANGES_SAVED')]]);
- 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
$toRemove = array_diff($oldValue, $value);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (false !== ($key = array_search($value, $updateValue))) {
- 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(['notify' => ['type' => 'success', 'text' => \App\Language::translate('LBL_CHANGES_SAVED')]]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
throw new \App\Exceptions\IllegalValue('ERR_ILLEGAL_VALUE');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldModel->getUITypeModel()->validate($value, true);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldModel = $fields[$field];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$security = new \App\ConfigFile('security');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($toRemove as $value) {
- 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
Class name "Settings_MailIntegration_SaveConfigForm_Action" is not in camel caps format Open
class Settings_MailIntegration_SaveConfigForm_Action extends Settings_Vtiger_Basic_Action
- Exclude checks