Method process
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function process(App\Request $request)
{
$mode = $request->getMode();
if (!empty($mode)) {
echo $this->invokeExposedMethod($mode, $request);
Function process
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function process(App\Request $request)
{
$mode = $request->getMode();
if (!empty($mode)) {
echo $this->invokeExposedMethod($mode, $request);
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Missing class import via use statement (line '47', 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 '73', 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 '26'). Open
$taxRecordModel = new Settings_Vtiger_TaxRecord_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
Avoid using static access to class 'Settings_Vtiger_TaxRecord_Model' in method 'checkDuplicateName'. Open
$exists = Settings_Vtiger_TaxRecord_Model::checkDuplicate($taxLabel, $taxId, $type);
- 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 process uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$taxRecordModel = Settings_Vtiger_TaxRecord_Model::getInstanceById($taxId, $type);
}
- 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_Vtiger_TaxRecord_Model' in method 'process'. Open
$recordModel = Settings_Vtiger_TaxRecord_Model::getInstanceById($taxId, $type);
- 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 checkDuplicateName uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$result = ['success' => true, 'message' => \App\Language::translate('LBL_TAX_NAME_EXIST', $qualifiedModuleName)];
}
- 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 'checkDuplicateName'. Open
$result = ['success' => true, 'message' => \App\Language::translate('LBL_TAX_NAME_EXIST', $qualifiedModuleName)];
- 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_TaxRecord_Model' in method 'process'. Open
$taxRecordModel = Settings_Vtiger_TaxRecord_Model::getInstanceById($taxId, $type);
- 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
Call to method checkDuplicate
from undeclared class \Settings_Vtiger_TaxRecord_Model
Open
$exists = Settings_Vtiger_TaxRecord_Model::checkDuplicate($taxLabel, $taxId, $type);
- Exclude checks
Suspicious argument \App\Controller\type
for an echo/print statement Open
echo $this->invokeExposedMethod($mode, $request);
- Exclude checks
Call to method __construct
from undeclared class \Settings_Vtiger_TaxRecord_Model
Open
$taxRecordModel = new Settings_Vtiger_TaxRecord_Model();
- Exclude checks
Call to method set
from undeclared class \Settings_Vtiger_TaxRecord_Model
Open
$taxRecordModel->set($fieldName, $request->get($fieldName));
- Exclude checks
Call to method getInstanceById
from undeclared class \Settings_Vtiger_TaxRecord_Model
Open
$recordModel = Settings_Vtiger_TaxRecord_Model::getInstanceById($taxId, $type);
- Exclude checks
Call to method getCurrentUserModel
from undeclared class \App\User
(Did you mean class \Tests\App\User) Open
$response->setResult(array_merge(['_editurl' => $recordModel->getEditTaxUrl(), 'type' => $recordModel->getType(), 'row_type' => \App\User::getCurrentUserModel()->getDetail('rowheight')], $recordModel->getData()));
- Exclude checks
Call to method getInstanceById
from undeclared class \Settings_Vtiger_TaxRecord_Model
Open
$taxRecordModel = Settings_Vtiger_TaxRecord_Model::getInstanceById($taxId, $type);
- Exclude checks
Call to method setType
from undeclared class \Settings_Vtiger_TaxRecord_Model
Open
$taxRecordModel->setType($type);
- Exclude checks
Call to method save
from undeclared class \Settings_Vtiger_TaxRecord_Model
Open
$taxId = $taxRecordModel->save();
- Exclude checks
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class Settings_Vtiger_TaxAjax_Action extends Settings_Vtiger_Basic_Action
- Exclude checks
The class Settings_Vtiger_TaxAjax_Action is not named in CamelCase. Open
class Settings_Vtiger_TaxAjax_Action extends Settings_Vtiger_Basic_Action
{
use \App\Controller\ExposeMethod;
public function __construct()
- 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
$taxId = $taxRecordModel->save();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function checkDuplicateName(App\Request $request)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$taxId = $request->get('taxid');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!$exists) {
- 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 (empty($taxId)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$taxRecordModel = new Settings_Vtiger_TaxRecord_Model();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($request->has($fieldName)) {
- 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 __construct()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$response->setResult(array_merge(['_editurl' => $recordModel->getEditTaxUrl(), 'type' => $recordModel->getType(), 'row_type' => \App\User::getCurrentUserModel()->getDetail('rowheight')], $recordModel->getData()));
- 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
use \App\Controller\ExposeMethod;
- 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
$taxId = $request->get('taxid');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$exists = Settings_Vtiger_TaxRecord_Model::checkDuplicate($taxLabel, $taxId, $type);
- Exclude checks
Line exceeds 120 characters; contains 125 characters Open
$result = ['success' => true, 'message' => \App\Language::translate('LBL_TAX_NAME_EXIST', $qualifiedModuleName)];
- 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
$fields = ['taxlabel', 'percentage', 'deleted'];
- Exclude checks
Line exceeds 120 characters; contains 225 characters Open
$response->setResult(array_merge(['_editurl' => $recordModel->getEditTaxUrl(), 'type' => $recordModel->getType(), 'row_type' => \App\User::getCurrentUserModel()->getDetail('rowheight')], $recordModel->getData()));
- 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
$taxLabel = $request->get('taxlabel');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($fields as $fieldName) {
- 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 (!empty($mode)) {
- 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
$type = $request->get('type');
- 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
$taxRecordModel->set($fieldName, $request->get($fieldName));
- 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
$recordModel = Settings_Vtiger_TaxRecord_Model::getInstanceById($taxId, $type);
- 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($result);
- 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
$this->exposeMethod('checkDuplicateName');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$taxRecordModel = Settings_Vtiger_TaxRecord_Model::getInstanceById($taxId, $type);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$taxRecordModel->setType($type);
- 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
$qualifiedModuleName = $request->getModule(false);
- 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
$result = ['success' => false];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$type = $request->get('type');
- 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
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$result = ['success' => true, 'message' => \App\Language::translate('LBL_TAX_NAME_EXIST', $qualifiedModuleName)];
- 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;
- 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
echo $this->invokeExposedMethod($mode, $request);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Class name "Settings_Vtiger_TaxAjax_Action" is not in camel caps format Open
class Settings_Vtiger_TaxAjax_Action extends Settings_Vtiger_Basic_Action
- Exclude checks