Smile-SA/elasticsuite

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

Summary

Maintainability
D
1 day
Test Coverage

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

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 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

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

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

    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 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

    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 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

        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

        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);

        There are no issues that match your filters.

        Category
        Status