Smile-SA/elasticsuite

View on GitHub
src/module-elasticsuite-thesaurus/Model/Import/Thesaurus.php

Summary

Maintainability
D
1 day
Test Coverage

Showing 10 of 10 total issues

Function saveAndReplaceThesaurus has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
Open

private function saveAndReplaceThesaurus(): void
{
$behavior = $this->getBehavior();
$rows = [];
while ($bunch = $this->_dataSourceModel->getNextBunch()) {
Severity: Minor
Found in src/module-elasticsuite-thesaurus/Model/Import/Thesaurus.php - About 4 hrs to fix

Function saveThesaurusFinish has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

private function saveThesaurusFinish(array $thesaurusData): bool
{
foreach ($thesaurusData as $thesaurusRows) {
foreach ($thesaurusRows as $row) {
$model = $this->importProvider->createThesaurus();
Severity: Minor
Found in src/module-elasticsuite-thesaurus/Model/Import/Thesaurus.php - About 3 hrs to fix

Thesaurus has 11 functions (exceeds 10 allowed). Consider refactoring.
Open

class Thesaurus extends AbstractEntity
{
const ENTITY_CODE = 'thesaurus';
const COL_TERMS = 'terms_relations';
const COL_STORES = 'stores';
Severity: Minor
Found in src/module-elasticsuite-thesaurus/Model/Import/Thesaurus.php - About 2 hrs to fix

    Function deleteThesaurus has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

    private function deleteThesaurus(): bool
    {
    $rows = [];
    while ($bunch = $this->_dataSourceModel->getNextBunch()) {
    foreach ($bunch as $rowNum => $rowData) {
    Severity: Minor
    Found in src/module-elasticsuite-thesaurus/Model/Import/Thesaurus.php - About 1 hr to fix

    Function deleteThesaurusFinish has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    private function deleteThesaurusFinish(array $thesaurusIds): bool
    {
    if ($thesaurusIds) {
    try {
    foreach ($thesaurusIds as $thesaurusId) {
    Severity: Minor
    Found in src/module-elasticsuite-thesaurus/Model/Import/Thesaurus.php - About 55 mins to fix

    Method __construct has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    JsonHelper $jsonHelper,
    ImportHelper $importExportData,
    Data $importData,
    Helper $resourceHelper,
    ProcessingErrorAggregatorInterface $errorAggregator,
    Severity: Minor
    Found in src/module-elasticsuite-thesaurus/Model/Import/Thesaurus.php - About 45 mins to fix

      Avoid too many return statements within this method.
      Open

      return false;
      Severity: Minor
      Found in src/module-elasticsuite-thesaurus/Model/Import/Thesaurus.php - About 30 mins to fix

        Function validateRow has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        public function validateRow(array $rowData, $rowNum): bool
        {
        $name = $rowData[ThesaurusInterface::NAME] ?? '';
        $type = $rowData[ThesaurusInterface::TYPE] ?? '';
        $terms = $rowData[self::COL_TERMS] ?? '';
        Severity: Minor
        Found in src/module-elasticsuite-thesaurus/Model/Import/Thesaurus.php - About 25 mins to fix

        Invalid offset "type" of array type array{}
        Open

        $type = $columnValues[ThesaurusInterface::TYPE];

        Argument 2 (type) is null but \Smile\ElasticsuiteThesaurus\Model\Import\Provider::processTermsData() takes string defined at /code/src/module-elasticsuite-thesaurus/Model/Import/Provider.php:123
        Open

        $row[$columnKey] = $this->importProvider->processTermsData($row[$columnKey], $type);
        Category
        Status