File Rule.php
has 334 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade Smile ElasticSuite to newer
Rule
has 19 functions (exceeds 10 allowed). Consider refactoring. Open
class Rule extends \Smile\ElasticsuiteCatalogRule\Model\Rule implements VirtualRuleInterface
{
/**
* @var QueryFactory
*/
Function addChildrenQueries
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
private function addChildrenQueries($query, CategoryInterface $category, $excludedCategories = []): QueryInterface
{
$childrenCategories = $this->getChildrenCategories($category, $excludedCategories);
$childrenCategoriesIds = [];
- 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 __construct
has 16 arguments (exceeds 4 allowed). Consider refactoring. Open
Context $context,
Registry $registry,
FormFactory $formFactory,
TimezoneInterface $localeDate,
CombineConditionFactory $combineConditionsFactory,
Method addChildrenQueries
has 47 lines of code (exceeds 40 allowed). Consider refactoring. Open
private function addChildrenQueries($query, CategoryInterface $category, $excludedCategories = []): QueryInterface
{
$childrenCategories = $this->getChildrenCategories($category, $excludedCategories);
$childrenCategoriesIds = [];
Function getCategorySearchQuery
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function getCategorySearchQuery($category, $excludedCategories = []): ?QueryInterface
{
\Magento\Framework\Profiler::start('ES:Virtual Rule ' . __FUNCTION__);
$categoryId = (int) (!is_object($category) ? $category : $category->getId());
$storeId = !is_object($category) ? $this->getStoreId() : $category->getStoreId();
- 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
Function buildCategorySearchQuery
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
private function buildCategorySearchQuery($category, $excludedCategories = []): ?QueryInterface
{
$query = null;
if (!in_array($category->getId(), $excludedCategories)) {
- 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
Function getSearchQueriesByChildren
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function getSearchQueriesByChildren(CategoryInterface $rootCategory): array
{
$queries = [];
$childrenIds = $rootCategory->getResource()->getChildren($rootCategory, false);
- 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
Function getVirtualRootCategory
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private function getVirtualRootCategory(CategoryInterface $category): ?CategoryInterface
{
$storeId = $this->getStoreId();
$rootCategory = null;
- 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
Function getVirtualCategoryQuery
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private function getVirtualCategoryQuery(
CategoryInterface $category,
$excludedCategories = []
): ?QueryInterface {
$rootCategory = $this->getVirtualRootCategory($category);
- 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
Argument 1 (condition)
is \Magento\Framework\Api\ExtensibleDataInterface|\Smile\ElasticsuiteCatalogRule\Api\Data\ConditionInterface
but \Smile\ElasticsuiteVirtualCategory\Model\Rule::dataModelToArray()
takes \Smile\ElasticsuiteCatalogRule\Model\Data\Condition
defined at /code/src/module-elasticsuite-catalog-rule/Model/Rule.php:181
Open
$this->getConditions()->setConditions([])->loadArray($this->dataModelToArray($condition));
- Exclude checks
Assigning array<int></int>
to property but \Smile\ElasticsuiteVirtualCategory\Model\Rule->instances
is \Magento\Catalog\Model\Category[]
Open
$this->instances[$rootCategoryId][$cacheKey] = $rootCategory;
- Exclude checks
Suspicious array access to \Magento\Catalog\Model\Category
Open
return $this->instances[$rootCategoryId][$cacheKey];
- Exclude checks
Doc-block of getVirtualCategoryQuery
has declared return type \Smile\ElasticsuiteCore\Search\Request\QueryInterface
which is not a permitted replacement of the nullable return type ?\Smile\ElasticsuiteCore\Search\Request\QueryInterface
declared in the signature ('?T' should be documented as 'T|null' or '?T') Open
* @return QueryInterface
- Exclude checks
TODO found Open
* @TODO: manage cache in this file for getSearchQueriesByChildren,
- Exclude checks
Argument 2 (pieces)
is array{0:'getCategorySearchQuery',1:mixed,2:int,3:mixed,4:bool}
but \implode()
takes string[]
Open
$cacheKey = implode(
- Exclude checks
Call with 2 arg(s) to \Smile\ElasticsuiteCatalogRule\Model\Rule\Condition\Product\QueryBuilder::getSearchQuery()
which only takes 1 arg(s) defined at /code/src/module-elasticsuite-catalog-rule/Model/Rule/Condition/Product/QueryBuilder.php:78
Open
return $this->queryBuilder->getSearchQuery($categoryCondition, $excludedCategories);
- Exclude checks