rinvex/laravel-repositories

View on GitHub

Showing 7 of 38 total issues

EloquentRepository has 27 functions (exceeds 20 allowed). Consider refactoring.
Open

class EloquentRepository extends BaseRepository
{
    /**
     * {@inheritdoc}
     */
Severity: Minor
Found in src/Repositories/EloquentRepository.php - About 3 hrs to fix

BaseRepository has 26 functions (exceeds 20 allowed). Consider refactoring.
Open

abstract class BaseRepository implements RepositoryContract, CacheableContract
{
    use Cacheable;

    /**
Severity: Minor
Found in src/Repositories/BaseRepository.php - About 3 hrs to fix

Method prepareQuery has 45 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected function prepareQuery($model)
    {
        // Set the relationships that should be eager loaded
        if (! empty($this->relations)) {
            $model = $model->with($this->relations);
Severity: Minor
Found in src/Repositories/BaseRepository.php - About 1 hr to fix

Function prepareQuery has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    protected function prepareQuery($model)
    {
        // Set the relationships that should be eager loaded
        if (! empty($this->relations)) {
            $model = $model->with($this->relations);
Severity: Minor
Found in src/Repositories/BaseRepository.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 update has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    public function update($id, array $attributes = [], bool $syncRelations = false)
    {
        $updated = false;

        // Find the given instance
Severity: Minor
Found in src/Repositories/EloquentRepository.php - About 45 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 bindRepository has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    protected function bindRepository($abstract, $concrete = null, $shared = true, $alias = null, $force = false): void
Severity: Minor
Found in src/Traits/Bindable.php - About 35 mins to fix

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

    public function forgetCache()
    {
        if ($this->getCacheLifetime()) {
            // Flush cache tags
            if (method_exists($this->getContainer('cache')->getStore(), 'tags')) {
Severity: Minor
Found in src/Traits/Cacheable.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

Severity
Category
Status
Source
Language