voyager-admin/voyager

View on GitHub

Showing 105 of 127 total issues

Function setSettings has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring.
Open

    private function setSettings(SettingManager $settingsmanager): void
    {
        $path = realpath(__DIR__.'/../../resources/presets/settings.json');
        if ($path !== false) {
            $content = file_get_contents($path);
Severity: Minor
Found in src/Commands/InstallCommand.php - About 6 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

Function install has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
Open

    install(app: Voyager) {
        app.config.globalProperties.__ = function (key: string, replace = {}) {
            return this.trans(key, replace);
        };
        app.config.globalProperties.trans = function (key: string, replace = {}) {
Severity: Minor
Found in resources/assets/js/multilanguage.ts - About 5 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

File BreadController.php has 376 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace Voyager\Admin\Http\Controllers;

use DB;
Severity: Minor
Found in src/Http/Controllers/BreadController.php - About 5 hrs to fix

    File MediaController.php has 369 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    
    namespace Voyager\Admin\Http\Controllers;
    
    use Illuminate\Http\Request;
    Severity: Minor
    Found in src/Http/Controllers/MediaController.php - About 4 hrs to fix

      File Breads.php has 357 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      <?php
      
      namespace Voyager\Admin\Manager;
      
      use Illuminate\Container\Container;
      Severity: Minor
      Found in src/Manager/Breads.php - About 4 hrs to fix

        Function install has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
        Open

            install(app: Voyager) {
                app.config.globalProperties.toggleDirection = function () {
                    Store.rtl = !Store.rtl;
                    if (Store.rtl) {
                        document.querySelector('html')?.setAttribute('dir', 'rtl');
        Severity: Minor
        Found in resources/assets/js/global.ts - About 3 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 listFiles has 93 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function listFiles(Request $request)
            {
                $hide_thumbnails = VoyagerFacade::setting('media.hide-thumbnails', true);
                $thumbnail_names = $this->getThumbnailDefinitions()->pluck('name')->transform(function ($name) {
                    return '_'.$name;
        Severity: Major
        Found in src/Http/Controllers/MediaController.php - About 3 hrs to fix

          File VoyagerServiceProvider.php has 316 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          <?php
          
          namespace Voyager\Admin;
          
          use Illuminate\Contracts\Auth\Access\Gate;
          Severity: Minor
          Found in src/VoyagerServiceProvider.php - About 3 hrs to fix

            Function handle has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
            Open

                public function handle(PluginManager $pluginmanager)
                {
                    $name = $this->argument('plugin');
            
                    if (!is_string($name)) {
            Severity: Minor
            Found in src/Commands/PluginsCommand.php - About 3 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

            Function prepareVoyager has 80 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function prepareVoyager(data: VoyagerData) {
                for (let key of Object.keys(data)) {
                    // @ts-ignore
                    Store[key] = data[key];
                }
            Severity: Major
            Found in resources/assets/js/voyager.ts - About 3 hrs to fix

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

              class Breads
              {
                  protected Collection $formfields;
                  protected string $path;
                  protected ?Collection $breads = null;
              Severity: Minor
              Found in src/Manager/Breads.php - About 3 hrs to fix

                Method relationship has 77 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function relationship(Request $request): array
                    {
                        // TODO: Validate that the method exists in edit/add layout
                        $bread = $this->getBread($request, true);
                        list($perPage, $query, $method, $column) = array_values($request->only(['perPage', 'query', 'method', 'column', 'key']));
                Severity: Major
                Found in src/Http/Controllers/BreadController.php - About 3 hrs to fix

                  Function install has 69 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      install(app: Voyager) {
                          app.config.globalProperties.toggleDirection = function () {
                              Store.rtl = !Store.rtl;
                              if (Store.rtl) {
                                  document.querySelector('html')?.setAttribute('dir', 'rtl');
                  Severity: Major
                  Found in resources/assets/js/global.ts - About 2 hrs to fix

                    Method processUploadedFile has 68 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        protected function processUploadedFile($file, $path)
                        {
                            $name = '';
                            $count = 0;
                            $thumbnails = 0;
                    Severity: Major
                    Found in src/Http/Controllers/MediaController.php - About 2 hrs to fix

                      Function install has 65 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          install(app: Voyager) {
                              app.config.globalProperties.__ = function (key: string, replace = {}) {
                                  return this.trans(key, replace);
                              };
                              app.config.globalProperties.trans = function (key: string, replace = {}) {
                      Severity: Major
                      Found in resources/assets/js/multilanguage.ts - About 2 hrs to fix

                        Function relationship has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                        Open

                            public function relationship(Request $request): array
                            {
                                // TODO: Validate that the method exists in edit/add layout
                                $bread = $this->getBread($request, true);
                                list($perPage, $query, $method, $column) = array_values($request->only(['perPage', 'query', 'method', 'column', 'key']));
                        Severity: Minor
                        Found in src/Http/Controllers/BreadController.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

                        Function mounted has 57 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            mounted(el: TooltipElement, binding: any) {
                                let placement = 'bottom';
                                if (placements.includes(binding.arg)) {
                                    placement = binding.arg;
                                } else if (binding.arg) {
                        Severity: Major
                        Found in resources/assets/js/directives/tooltip.ts - About 2 hrs to fix

                          Method launchPlugins has 57 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              public function launchPlugins(?bool $protected = null): void
                              {
                                  $this->getAllPlugins()->each(function (GenericPlugin $plugin) use ($protected) {
                                      $start = round(microtime(true) * 1000);
                                      $plugin->stats = [
                          Severity: Major
                          Found in src/Manager/Plugins.php - About 2 hrs to fix

                            Method handle has 54 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                public function handle(PluginManager $pluginmanager)
                                {
                                    $name = $this->argument('plugin');
                            
                                    if (!is_string($name)) {
                            Severity: Major
                            Found in src/Commands/PluginsCommand.php - About 2 hrs to fix

                              Method getModelRelationships has 53 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  public function getModelRelationships(\ReflectionClass $reflection, Model $model, bool $resolve = false): Collection
                                  {
                                      $single = [
                                          BelongsTo::class,
                                          HasOne::class,
                              Severity: Major
                              Found in src/Manager/Breads.php - About 2 hrs to fix
                                Severity
                                Category
                                Status
                                Source
                                Language