voyager-admin/voyager

View on GitHub

Showing 125 of 127 total issues

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

        $edit_action = (new Action('voyager::generic.edit', 'pencil', null, 'yellow'))
        ->route(function ($bread) {
            return 'voyager.'.$bread->slug.'.edit';
        })->permission('edit')
        ->displayOnBread(function ($bread) use ($breadmanager) {
Severity: Minor
Found in src/VoyagerServiceProvider.php and 1 other location - About 45 mins to fix
src/VoyagerServiceProvider.php on lines 215..221

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

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

        $read_action = (new Action('voyager::generic.read', 'book-open', null, 'accent'))
        ->route(function ($bread) {
            return 'voyager.'.$bread->slug.'.read';
        })->permission('read')
        ->displayOnBread(function ($bread) use ($breadmanager) {
Severity: Minor
Found in src/VoyagerServiceProvider.php and 1 other location - About 45 mins to fix
src/VoyagerServiceProvider.php on lines 223..229

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

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 __construct has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

        public string $title,
        public ?string $icon = null,
        public ?string $buttoncolor = null,
        public ?string $iconcolor = null,
        public ?string $textcolor = null
Severity: Minor
Found in src/Classes/Action.php - About 35 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 addSelect has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            public function addSelect(?string $key = null, string|array|null $title = null, ?array $options = [], ?bool $multiple = false, mixed $value = null): self
        Severity: Minor
        Found in src/Classes/DynamicInput.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 getBread has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  protected function getBread(Request $request, bool $withRelationships = false): Bread
                  {
                      if ($request->route() instanceof \Illuminate\Routing\Route && $request->route()->getAction()['bread']) {
                          $bread = $request->route()->getAction()['bread'];
                          
              Severity: Minor
              Found in src/Http/Controllers/Controller.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 save has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function save(mixed $content = null): void
                  {
                      if (is_null($content)) {
                          $content = $this->settings;
                      }
              Severity: Minor
              Found in src/Manager/Settings.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 getProperties has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function getProperties(Request $request)
                  {
                      $table = $request->get('table', null);
              
                      if ($this->breadmanager->getBread($table)) {
              Severity: Minor
              Found in src/Http/Controllers/BreadBuilderController.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 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 setTranslation has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function setTranslation(mixed $input, mixed $value, ?string $locale = null): mixed
                  {
                      if ($locale == null) {
                          $locale = app()->getLocale();
                      }
              Severity: Minor
              Found in src/Traits/Facade/Localization.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

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

                  public function boot(Router $router): void
                  {
                      $router->aliasMiddleware('voyager.admin', VoyagerAdminMiddleware::class);
              
                      $this->registerResources();
              Severity: Minor
              Found in src/VoyagerServiceProvider.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 __set has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function __set($key, $value): void
                  {
                      $this->setLocales();
                      if ($this->shouldColumnBeTranslated($key)) {
                          if (is_array($value) || is_object($value)) {
              Severity: Minor
              Found in src/Traits/Translatable.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

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

                      app.config.globalProperties.openSidebar = function () {
                          Store.sidebarOpen = true;
                          EventBus.emit('sidebar-open', true);
                      };
              Severity: Minor
              Found in resources/assets/js/global.ts and 1 other location - About 35 mins to fix
              resources/assets/js/global.ts on lines 73..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 46.

              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

                      app.config.globalProperties.closeSidebar = function () {
                          Store.sidebarOpen = false;
                          EventBus.emit('sidebar-open', false);
                      };
              Severity: Minor
              Found in resources/assets/js/global.ts and 1 other location - About 35 mins to fix
              resources/assets/js/global.ts on lines 69..72

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

              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

              Avoid too many return statements within this method.
              Open

                          return [
                              'key' => $key,
                              'value' => $translatable ? VoyagerFacade::translate($value) : $value
                          ];
              Severity: Major
              Found in src/Http/Controllers/BreadController.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                            return 'voyager.'.$bread->slug.'.delete';
                Severity: Major
                Found in src/VoyagerServiceProvider.php - About 30 mins to fix
                  Severity
                  Category
                  Status
                  Source
                  Language