voyager-admin/voyager

View on GitHub

Showing 47 of 67 total issues

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

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

    Voyager has 30 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Voyager
    {
        /**
         * The route prefix that Voyager will use when registering routes.
         *
    Severity: Minor
    Found in src/Voyager.php - About 3 hrs to fix

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

          public function handle(PluginManager $pluginmanager)
          {
              $name = $this->argument('plugin');
              $plugin = null;
              if (!is_null($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

      File Breads.php has 299 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 3 hrs to fix

        File Voyager.php has 289 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        <?php
        
        namespace Voyager\Admin;
        
        use Illuminate\Support\Collection;
        Severity: Minor
        Found in src/Voyager.php - About 2 hrs to fix

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

              private function setSettings(SettingManager $settingsmanager)
              {
                  $content = file_get_contents(realpath(__DIR__.'/../../resources/presets/settings.json'));
                  if (is_null($settingsmanager->setting())) {
                      $settingsmanager->save($content);
          Severity: Minor
          Found in src/Commands/InstallCommand.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 getThumbnailOptions has 72 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function getThumbnailOptions(Request $request)
              {
                  extract($request->all());
          
                  $options = [
          Severity: Major
          Found in src/Http/Controllers/VoyagerController.php - About 2 hrs to fix

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

            class Breads
            {
                protected $formfields;
                protected $path;
                protected $breads;
            Severity: Minor
            Found in src/Manager/Breads.php - About 2 hrs to fix

              File VoyagerServiceProvider.php has 269 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 2 hrs to fix

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

                    public function transformResults($layout, $translatable, $query)
                    {
                        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

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

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

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

                        install: function (app, config) {
                            app.config.globalProperties.__ = function (key, replace = {}) {
                                return this.trans(key, replace);
                            };
                            app.config.globalProperties.trans = function (key, replace = {}) {
                    Severity: Minor
                    Found in resources/assets/js/multilanguage.js - About 1 hr to fix

                      Method getModelRelationships has 46 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: Minor
                      Found in src/Manager/Breads.php - About 1 hr to fix

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

                            public function relationship(Request $request)
                            {
                                // TODO: Validate that the method exists in edit/add layout
                                $bread = $this->getBread($request);
                                $perpage = 5;
                        Severity: Minor
                        Found in src/Http/Controllers/BreadController.php - About 1 hr to fix

                          Method edit has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              public function edit(Request $request, $id)
                              {
                                  $bread = $this->getBread($request);
                                  $layout = $this->getLayoutForAction($bread, 'edit');
                                  $new = false;
                          Severity: Minor
                          Found in src/Http/Controllers/BreadController.php - About 1 hr to fix

                            Function createVoyager has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            window.createVoyager = function (data = {}, main = true) {
                                voyager = createApp((main ? Voyager : Login), data);
                            
                                voyager.config.globalProperties.Status = Object.freeze({
                                    Pending  : 1,
                            Severity: Minor
                            Found in resources/assets/js/voyager.js - About 1 hr to fix

                              Method getThumbnailDefinitions has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  public function getThumbnailDefinitions()
                                  {
                                      $thumbs = collect($this->settingmanager->setting('thumbnails'));
                              
                                      return $thumbs->map(function ($thumb, $name) {
                              Severity: Minor
                              Found in src/Voyager.php - About 1 hr to fix

                                Function createRequest has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                    createRequest(url, method = 'post', parameters = {}, responseType = 'text') {
                                        var body = null;
                                
                                        if (method.toLocaleLowerCase() !== 'get') {
                                            body = (parameters instanceof FormData ? parameters : JSON.stringify(parameters));
                                Severity: Minor
                                Found in resources/assets/js/fetch.js - About 1 hr to fix

                                  Method registerActions has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                      public function registerActions()
                                      {
                                          $read_action = (new Action('voyager::generic.read', 'book-open'))
                                          ->route(function ($bread) {
                                              return 'voyager.'.$bread->slug.'.read';
                                  Severity: Minor
                                  Found in src/VoyagerServiceProvider.php - About 1 hr to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language