voyager-admin/voyager

View on GitHub
src/Traits/Bread/Browsable.php

Summary

Maintainability
C
1 day
Test Coverage
F
46%

Method transformResults has 51 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function transformResults(Layout $layout, bool $translatable, mixed $query, ?string $global, mixed $filters): mixed
    {
        return $query->transform(function ($item) use ($translatable, $layout) {
            $item->primary_key = $item->getKey();
            if ($translatable) {
Severity: Major
Found in src/Traits/Bread/Browsable.php - About 2 hrs to fix

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

        public function applyCustomScope(Bread $bread, Layout $layout, mixed $filter, mixed $query, array &$warnings): mixed
        {
            if (!is_null($filter) && is_array($filter)) {
                // Validate filter exists in layout
                if (collect($layout->options->filters)->where('column', $filter['column'])->where('operator', $filter['operator'])->where('value', $filter['value'])->count() > 0) {
    Severity: Minor
    Found in src/Traits/Bread/Browsable.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 orderQuery has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        public function orderQuery(Layout $layout, mixed $direction, mixed $order, mixed $query, string $locale, array &$warnings): mixed
        {
            if (!empty($direction) && !empty($order)) {
                $formfield = $layout->getFormfieldByColumn($order);
                if ($formfield && $formfield->column->type == 'column') {
    Severity: Minor
    Found in src/Traits/Bread/Browsable.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

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

        public function orderQuery(Layout $layout, mixed $direction, mixed $order, mixed $query, string $locale, array &$warnings): mixed
    Severity: Minor
    Found in src/Traits/Bread/Browsable.php - About 45 mins to fix

      Method columnSearchQuery has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          public function columnSearchQuery(array $filters, Layout $layout, mixed $query, string $locale, array &$warnings): mixed
      Severity: Minor
      Found in src/Traits/Bread/Browsable.php - About 35 mins to fix

        Method applyCustomScope has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            public function applyCustomScope(Bread $bread, Layout $layout, mixed $filter, mixed $query, array &$warnings): mixed
        Severity: Minor
        Found in src/Traits/Bread/Browsable.php - About 35 mins to fix

          Method queryColumn has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              private function queryColumn(mixed $query, Formfield $formfield, mixed $filter, string $locale, bool $global = false): mixed
          Severity: Minor
          Found in src/Traits/Bread/Browsable.php - About 35 mins to fix

            Method transformResults has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                public function transformResults(Layout $layout, bool $translatable, mixed $query, ?string $global, mixed $filters): mixed
            Severity: Minor
            Found in src/Traits/Bread/Browsable.php - About 35 mins to fix

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

                  public function applyCustomFilter(Bread $bread, Layout $layout, mixed $filter, mixed $query): mixed
                  {
                      if (!is_null($filter) && is_array($filter)) {
                          // Validate filter exists in layout
                          if (collect($layout->options->filters)->where('column', $filter['column'])->where('operator', $filter['operator'])->where('value', $filter['value'])->count() > 0) {
              Severity: Minor
              Found in src/Traits/Bread/Browsable.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

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

                  private function queryColumn(mixed $query, Formfield $formfield, mixed $filter, string $locale, bool $global = false): mixed
                  {
                      $filter = '%'.strtolower($filter).'%';
                      $translatable = $formfield->translatable ?? false;
                      $column = $formfield->column->column;
              Severity: Minor
              Found in src/Traits/Bread/Browsable.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

              There are no issues that match your filters.

              Category
              Status