Missing class import via use statement (line '29', column '21'). Open
$returnVal = (new \App\Db\Query())
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Avoid using static access to class '\Vtiger_Inventory_Model' in method 'getTaxParam'. Open
$globalTaxes = \Vtiger_Inventory_Model::getGlobalTaxes();
- 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_Inventory_Model' in method 'getTaxParam'. Open
$taxConfig = \Vtiger_Inventory_Model::getTaxesConfig();
- 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\Double' in method 'getTaxParam'. Open
$taxParam['regionalTax'] = \App\Fields\Double::formatToDb($globalTaxes[$taxId]['value']);
- 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\Double' in method 'getTaxParam'. Open
$taxParam['groupTax'] = \App\Fields\Double::formatToDb($globalTaxes[$taxId]['value']);
- 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 undeclared method \App\Db\Query::select
Open
$returnVal = (new \App\Db\Query())
- Exclude checks
Similar blocks of code found in 2 locations. Consider refactoring. Open
if (\in_array('LBL_REGIONAL_TAX', $availableTaxes) && !empty($regionalTaxes) && \in_array(3, $taxConfig['taxs'])) {
$taxParam['aggregationType'][] = 'regional';
$taxId = explode(',', $regionalTaxes)[0];
$taxParam['regionalTax'] = \App\Fields\Double::formatToDb($globalTaxes[$taxId]['value']);
}
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 101.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
if (\in_array('LBL_GROUP_TAX', $availableTaxes) && !empty($groupTaxes) && \in_array(1, $taxConfig['taxs'])) {
$taxParam['aggregationType'][] = 'group';
$taxId = explode(',', $groupTaxes)[0];
$taxParam['groupTax'] = \App\Fields\Double::formatToDb($globalTaxes[$taxId]['value']);
}
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 101.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Spaces must be used to indent lines; tabs are not allowed Open
->where(['vtiger_account.accountid' => $accountId])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $groupTaxes
- 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
$taxConfig = \Vtiger_Inventory_Model::getTaxesConfig();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Returns taxparam.
- 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
$returnVal = (new \App\Db\Query())
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$availableTaxes = explode(' |##| ', $availableTaxes);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->leftJoin('vtiger_pricebookproductrel', 'vtiger_pricebookproductrel.pricebookid = vtiger_account.pricebook_id')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->andWhere(['vtiger_pricebookproductrel.productid' => $productId])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$globalTaxes = \Vtiger_Inventory_Model::getGlobalTaxes();
- 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 float|null
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $availableTaxes
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $regionalTaxes
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get the price from the pricebook.
- 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
->scalar();
- 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
->from('vtiger_account')
- Exclude checks
Line exceeds 120 characters; contains 124 characters Open
->leftJoin('vtiger_pricebookproductrel', 'vtiger_pricebookproductrel.pricebookid = vtiger_account.pricebook_id')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return false === $returnVal ? null : (float) $returnVal;
- 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 static function getTaxParam(string $availableTaxes, string $groupTaxes, string $regionalTaxes): array
- 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
$taxParam = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (\in_array('LBL_REGIONAL_TAX', $availableTaxes) && !empty($regionalTaxes) && \in_array(3, $taxConfig['taxs'])) {
- 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('LBL_GROUP_TAX', $availableTaxes) && !empty($groupTaxes) && \in_array(1, $taxConfig['taxs'])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$taxParam['aggregationType'][] = 'group';
- Exclude checks
Line exceeds 120 characters; contains 123 characters Open
if (\in_array('LBL_REGIONAL_TAX', $availableTaxes) && !empty($regionalTaxes) && \in_array(3, $taxConfig['taxs'])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$taxParam['regionalTax'] = \App\Fields\Double::formatToDb($globalTaxes[$taxId]['value']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param int $accountId
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param int $productId
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getPriceFromPricebook(int $accountId, int $productId): ?float
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->select(['vtiger_pricebookproductrel.listprice'])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$taxId = explode(',', $groupTaxes)[0];
- 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
$taxParam['aggregationType'][] = 'regional';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$taxId = explode(',', $regionalTaxes)[0];
- 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
$taxParam['groupTax'] = \App\Fields\Double::formatToDb($globalTaxes[$taxId]['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
return $taxParam;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks