boldbrush/bread

View on GitHub

Showing 29 of 29 total issues

File Bread.php has 504 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

declare(strict_types=1);

namespace BoldBrush\Bread;
Severity: Major
Found in src/Bread.php - About 1 day to fix

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

            EloquentBuilder::macro('whereLikeBread', function ($attributes, string $searchTerm) {
                /** @var Builder $this */
                $this->where(function (EloquentBuilder $query) use ($attributes, $searchTerm) {
                    foreach (Arr::wrap($attributes) as $attribute) {
                        $query->when(
    Severity: Major
    Found in src/Provider/BreadServiceProvider.php and 1 other location - About 6 hrs to fix
    src/Provider/BreadServiceProvider.php on lines 77..101

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 217.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

            QueryBuilder::macro('whereLikeBread', function ($attributes, string $searchTerm) {
                /** @var Builder $this */
                $this->where(function (QueryBuilder $query) use ($attributes, $searchTerm) {
                    foreach (Arr::wrap($attributes) as $attribute) {
                        $query->when(
    Severity: Major
    Found in src/Provider/BreadServiceProvider.php and 1 other location - About 6 hrs to fix
    src/Provider/BreadServiceProvider.php on lines 52..76

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 217.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Bread has 42 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Bread
    {
        /** @var string|Model $model */
        protected $model = null;
    
    
    Severity: Minor
    Found in src/Bread.php - About 5 hrs to fix

      Similar blocks of code found in 3 locations. Consider refactoring.
      Open

      <?php
      
      namespace BoldBrush\Bread\View\Components;
      
      use BoldBrush\Bread\Field\Field;
      Severity: Major
      Found in src/View/Components/Checkbox.php and 2 other locations - About 4 hrs to fix
      src/View/Components/Date.php on lines 1..42
      src/View/Components/Number.php on lines 1..42

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 169.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 3 locations. Consider refactoring.
      Open

      <?php
      
      namespace BoldBrush\Bread\View\Components;
      
      use BoldBrush\Bread\Field\Field;
      Severity: Major
      Found in src/View/Components/Number.php and 2 other locations - About 4 hrs to fix
      src/View/Components/Checkbox.php on lines 1..42
      src/View/Components/Date.php on lines 1..42

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 169.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 3 locations. Consider refactoring.
      Open

      <?php
      
      namespace BoldBrush\Bread\View\Components;
      
      use BoldBrush\Bread\Field\Field;
      Severity: Major
      Found in src/View/Components/Date.php and 2 other locations - About 4 hrs to fix
      src/View/Components/Checkbox.php on lines 1..42
      src/View/Components/Number.php on lines 1..42

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 169.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Field has 32 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class Field implements FieldInterface
      {
          protected $name;
      
          protected $editable = true;
      Severity: Minor
      Found in src/Field/Field.php - About 4 hrs to fix

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

        <?php
        
        declare(strict_types=1);
        
        namespace BoldBrush\Bread\View;
        Severity: Major
        Found in src/View/Editor.php and 1 other location - About 4 hrs to fix
        src/View/Adder.php on lines 1..33

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 162.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

        <?php
        
        declare(strict_types=1);
        
        namespace BoldBrush\Bread\View;
        Severity: Major
        Found in src/View/Adder.php and 1 other location - About 4 hrs to fix
        src/View/Editor.php on lines 1..33

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 162.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Identical blocks of code found in 2 locations. Consider refactoring.
        Open

                if (is_callable($query)) {
                    $query = $query(
                        $model,
                        DB::connection($connectionName)
                            ->table($this->getModelMetadata()
        Severity: Major
        Found in src/Bread.php and 1 other location - About 2 hrs to fix
        src/Bread.php on lines 207..220

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 137.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Identical blocks of code found in 2 locations. Consider refactoring.
        Open

                if (is_callable($query)) {
                    $query = $query(
                        $model,
                        DB::connection($connectionName)
                            ->table($this->getModelMetadata()
        Severity: Major
        Found in src/Bread.php and 1 other location - About 2 hrs to fix
        src/Bread.php on lines 174..187

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 137.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Method search has 62 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected function search(?array $sortBy)
            {
                $fields = $this->getFields()
                    ->for(FieldContainer::BROWSE)
                    ->toArray();
        Severity: Major
        Found in src/Bread.php - About 2 hrs to fix

          Function search has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
          Open

              protected function search(?array $sortBy)
              {
                  $fields = $this->getFields()
                      ->for(FieldContainer::BROWSE)
                      ->toArray();
          Severity: Minor
          Found in src/Bread.php - About 2 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

          Method boot has 56 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function boot()
              {
                  $this->loadViewsFrom(
                      realpath(dirname(dirname(__DIR__))) . '/resources/views',
                      'bread'
          Severity: Major
          Found in src/Provider/BreadServiceProvider.php - About 2 hrs to fix

            Method toDBAL has 50 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public static function toDBAL(array $config): array
                {
                    switch (true) {
                        case $config['driver'] === 'sqlite':
                            return [
            Severity: Minor
            Found in src/System/Database/ConfigTransformer.php - About 2 hrs to fix

              Method save has 43 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function save(?int $id = null, ?array $data = [])
                  {
                      $this->checkIfModelHasBeenSetup();
              
                      $model = $this->model;
              Severity: Minor
              Found in src/Bread.php - About 1 hr to fix

                Method browse has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function browse(): string
                    {
                        $this->checkIfModelHasBeenSetup();
                
                        $model = $this->model;
                Severity: Minor
                Found in src/Bread.php - About 1 hr to fix

                  Function browse has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function browse(): string
                      {
                          $this->checkIfModelHasBeenSetup();
                  
                          $model = $this->model;
                  Severity: Minor
                  Found in src/Bread.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 save has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function save(?int $id = null, ?array $data = [])
                      {
                          $this->checkIfModelHasBeenSetup();
                  
                          $model = $this->model;
                  Severity: Minor
                  Found in src/Bread.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

                  Severity
                  Category
                  Status
                  Source
                  Language