open-orchestra/open-orchestra-cms-bundle

View on GitHub
ModelLogBundle/Repository/LogRepository.php

Summary

Maintainability
A
35 mins
Test Coverage

Function filterSearch has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    protected function filterSearch(PaginateFinderConfiguration $configuration, Stage $qa)
    {
        $qa->match(array('extra.site_id' => $configuration->getSearchIndex('site_id')));

        $userName = $configuration->getSearchIndex('user_name');
Severity: Minor
Found in ModelLogBundle/Repository/LogRepository.php - About 35 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

Missing class import via use statement (line '88', column '52').
Open

                $qa->match(array('datetime' => new \MongoRegex('/' . $date . '.*/i')));

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 '72', column '55').
Open

            $qa->match(array('extra.user_name' => new \MongoRegex('/.*' . $userName . '.*/i')));

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 '77', column '53').
Open

            $qa->match(array('extra.user_ip' => new \MongoRegex('/.*' . $userIP . '.*/i')));

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

Call to method getSearchIndex from undeclared class \OpenOrchestra\Pagination\Configuration\PaginateFinderConfiguration
Open

        $userIP = $configuration->getSearchIndex('user_ip');

Call to method getSkip from undeclared class \OpenOrchestra\Pagination\Configuration\PaginateFinderConfiguration
Open

        $qa->skip($configuration->getSkip());

Call to method match from undeclared class \Solution\MongoAggregation\Pipeline\Stage
Open

            $qa->match(array('extra.user_ip' => new \MongoRegex('/.*' . $userIP . '.*/i')));

Call to method match from undeclared class \Solution\MongoAggregation\Pipeline\Stage
Open

        $qa->match(array('extra.site_id' => $configuration->getSearchIndex('site_id')));

Class extends undeclared class \OpenOrchestra\Repository\AbstractAggregateRepository
Open

class LogRepository extends AbstractAggregateRepository implements LogRepositoryInterface

Parameter $configuration has undeclared type \OpenOrchestra\Pagination\Configuration\PaginateFinderConfiguration
Open

    protected function filterSearch(PaginateFinderConfiguration $configuration, Stage $qa)

Call to undeclared method \OpenOrchestra\ModelLogBundle\Repository\LogRepository::createAggregationQuery
Open

        $qa = $this->createAggregationQuery();

Call to method __construct from undeclared class \MongoRegex
Open

                $qa->match(array('datetime' => new \MongoRegex('/' . $date . '.*/i')));

Call to method getOrder from undeclared class \OpenOrchestra\Pagination\Configuration\PaginateFinderConfiguration
Open

        $order = $configuration->getOrder();

Call to method match from undeclared class \Solution\MongoAggregation\Pipeline\Stage
Open

                $qa->match(array('datetime' => new \MongoRegex('/' . $date . '.*/i')));

Call to method getLimit from undeclared class \OpenOrchestra\Pagination\Configuration\PaginateFinderConfiguration
Open

        $qa->limit($configuration->getLimit());

Call to method getSearchIndex from undeclared class \OpenOrchestra\Pagination\Configuration\PaginateFinderConfiguration
Open

        $userName = $configuration->getSearchIndex('user_name');

Call to method __construct from undeclared class \MongoRegex
Open

            $qa->match(array('extra.user_name' => new \MongoRegex('/.*' . $userName . '.*/i')));

Call to undeclared method \OpenOrchestra\ModelLogBundle\Repository\LogRepository::hydrateAggregateQuery
Open

        return $this->hydrateAggregateQuery($qa);

Call to undeclared method \OpenOrchestra\ModelLogBundle\Repository\LogRepository::createAggregationQuery
Open

        $qa = $this->createAggregationQuery();

Parameter $qa has undeclared type \Solution\MongoAggregation\Pipeline\Stage
Open

    protected function filterSearch(PaginateFinderConfiguration $configuration, Stage $qa)

Parameter $configuration has undeclared type \OpenOrchestra\Pagination\Configuration\PaginateFinderConfiguration
Open

    public function findForPaginate(PaginateFinderConfiguration $configuration)

Call to undeclared method \OpenOrchestra\ModelLogBundle\Repository\LogRepository::countDocumentAggregateQuery
Open

        return $this->countDocumentAggregateQuery($qa);

Parameter $configuration has undeclared type \OpenOrchestra\Pagination\Configuration\PaginateFinderConfiguration
Open

    public function countWithFilter(PaginateFinderConfiguration $configuration)

Returning type \Solution\MongoAggregation\Pipeline\Stage but filterSearch() is declared to return array
Open

        return $qa;

Call to undeclared method \OpenOrchestra\ModelLogBundle\Repository\LogRepository::countDocumentAggregateQuery
Open

        return $this->countDocumentAggregateQuery($qa);

Call to method match from undeclared class \Solution\MongoAggregation\Pipeline\Stage
Open

            $qa->match(array('extra.user_name' => new \MongoRegex('/.*' . $userName . '.*/i')));

Call to method getSearchIndex from undeclared class \OpenOrchestra\Pagination\Configuration\PaginateFinderConfiguration
Open

        $date = $configuration->getSearchIndex('date');

Call to undeclared method \OpenOrchestra\ModelLogBundle\Repository\LogRepository::createAggregationQuery
Open

        $qa = $this->createAggregationQuery();

Call to method __construct from undeclared class \MongoRegex
Open

            $qa->match(array('extra.user_ip' => new \MongoRegex('/.*' . $userIP . '.*/i')));

Call to method getSearchIndex from undeclared class \OpenOrchestra\Pagination\Configuration\PaginateFinderConfiguration
Open

        $qa->match(array('extra.site_id' => $configuration->getSearchIndex('site_id')));

Call to method getSearchIndex from undeclared class \OpenOrchestra\Pagination\Configuration\PaginateFinderConfiguration
Open

            $dateFormat = $configuration->getSearchIndex('date-format');

Avoid variables with short names like $qa. Configured minimum length is 3.
Open

        $qa = $this->createAggregationQuery();

ShortVariable

Since: 0.2

Detects when a field, local, or parameter has a very short name.

Example

class Something {
    private $q = 15; // VIOLATION - Field
    public static function main( array $as ) { // VIOLATION - Formal
        $r = 20 + $this->q; // VIOLATION - Local
        for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
            $r += $this->q;
        }
    }
}

Source https://phpmd.org/rules/naming.html#shortvariable

Avoid variables with short names like $qa. Configured minimum length is 3.
Open

        $qa = $this->createAggregationQuery();

ShortVariable

Since: 0.2

Detects when a field, local, or parameter has a very short name.

Example

class Something {
    private $q = 15; // VIOLATION - Field
    public static function main( array $as ) { // VIOLATION - Formal
        $r = 20 + $this->q; // VIOLATION - Local
        for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
            $r += $this->q;
        }
    }
}

Source https://phpmd.org/rules/naming.html#shortvariable

Avoid variables with short names like $qa. Configured minimum length is 3.
Open

    protected function filterSearch(PaginateFinderConfiguration $configuration, Stage $qa)

ShortVariable

Since: 0.2

Detects when a field, local, or parameter has a very short name.

Example

class Something {
    private $q = 15; // VIOLATION - Field
    public static function main( array $as ) { // VIOLATION - Formal
        $r = 20 + $this->q; // VIOLATION - Local
        for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
            $r += $this->q;
        }
    }
}

Source https://phpmd.org/rules/naming.html#shortvariable

Avoid variables with short names like $qa. Configured minimum length is 3.
Open

        $qa = $this->createAggregationQuery();

ShortVariable

Since: 0.2

Detects when a field, local, or parameter has a very short name.

Example

class Something {
    private $q = 15; // VIOLATION - Field
    public static function main( array $as ) { // VIOLATION - Formal
        $r = 20 + $this->q; // VIOLATION - Local
        for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
            $r += $this->q;
        }
    }
}

Source https://phpmd.org/rules/naming.html#shortvariable

There are no issues that match your filters.

Category
Status