voyager-admin/voyager

View on GitHub

Showing 105 of 127 total issues

Function show has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    show() {
        if (this._confirm && this._buttons.length == 0) {
            this.addButton({
                key: true,
                value: 'voyager::generic.yes',
Severity: Minor
Found in resources/assets/js/notify.ts - About 1 hr to fix

    Method validateData has 32 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected function validateData(Collection $formfields, array|Collection $data, bool $all_locales = false): array
        {
            $errors = [];
    
            $formfields->each(function ($formfield) use (&$errors, $data, $all_locales) {
    Severity: Minor
    Found in src/Http/Controllers/Controller.php - About 1 hr to fix

      Function delete has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          public function delete(Request $request)
          {
              $storage = Storage::disk($this->disk);
              $files_deleted = 0;
              $dirs_deleted = 0;
      Severity: Minor
      Found in src/Http/Controllers/MediaController.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 __construct has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          public function __construct(?object $json = null)
          {
              if ($json) {
                  foreach ((array)$json as $key => $value) {
                      if ($key == 'column') {
      Severity: Minor
      Found in src/Classes/Formfield.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 getProperties has 31 lines of code (exceeds 25 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 1 hr to fix

        Method register has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function register()
            {
                app()->register(\Inertia\ServiceProvider::class);
        
                $loader = AliasLoader::getInstance();
        Severity: Minor
        Found in src/VoyagerServiceProvider.php - About 1 hr to fix

          Method stored has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function stored(mixed $model, mixed $value): void
              {
                  $relationship = $this->getRelationship();
                  $method = $model->{$relationship['method']}();
          
          
          Severity: Minor
          Found in src/Formfields/Relationship.php - About 1 hr to fix

            Method getFormfields has 28 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function getFormfields()
                {
                    return $this->formfields->map(function ($formfield) {
                        $component = 'Formfield'.Str::studly($formfield->type());
                        $builder_component = 'Formfield'.Str::studly($formfield->type()).'Builder';
            Severity: Minor
            Found in src/Manager/Breads.php - About 1 hr to fix

              Function resolve has 28 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                      resolve: name => {
                          // This is necessary so webpack doesn't load ALL components (by using require(`@components/${name}`))
                          let component = require(`@components/Generic.vue`).default;
              
                          if (name == 'Dashboard') {
              Severity: Minor
              Found in resources/assets/js/voyager.ts - About 1 hr to fix

                Method read has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

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

                  Function stored has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function stored(mixed $model, mixed $value): void
                      {
                          $relationship = $this->getRelationship();
                          $method = $model->{$relationship['method']}();
                  
                  
                  Severity: Minor
                  Found in src/Formfields/Relationship.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 getThumbnailOptions has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function getThumbnailOptions(Request $request): DynamicInput
                      {
                          $method = $request->input('method', 'fit');
                  
                          $select = (new DynamicInput())
                  Severity: Minor
                  Found in src/Http/Controllers/VoyagerController.php - About 1 hr to fix

                    Method getBreads has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function getBreads()
                        {
                            if (!$this->breads) {
                                VoyagerFacade::ensureDirectoryExists($this->path);
                                $this->breads = collect(File::files($this->path))->transform(function ($bread) {
                    Severity: Minor
                    Found in src/Manager/Breads.php - About 1 hr to fix

                      Method globalSearch has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function globalSearch(Request $request): ?array
                          {
                              $q = $request->get('query');
                              $results = [];
                              $this->breadmanager->getBreads()->each(function ($bread) use ($q, &$results) {
                      Severity: Minor
                      Found in src/Http/Controllers/VoyagerController.php - About 1 hr to fix

                        Method store has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public function store(Request $request): \Illuminate\Http\Response|\Illuminate\Http\JsonResponse
                            {
                                // Push a fake column object to settings
                                $settings = collect($request->get('settings', []))->transform(function ($setting) {
                                    $setting = (object) $setting;
                        Severity: Minor
                        Found in src/Http/Controllers/SettingsController.php - About 1 hr to fix

                          Function download has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                          Open

                              public function download(Request $request)
                              {
                                  $files = $request->get('files', []);
                                  if (count($files) == 1 && $files[0]['file']['type'] !== 'directory') {
                                      return Storage::disk($this->disk)->get($files[0]['file']['relative_path'].$files[0]['file']['name']);
                          Severity: Minor
                          Found in src/Http/Controllers/MediaController.php - About 45 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

                          Avoid deeply nested control flow statements.
                          Open

                                                          if (!empty($setting->key) && !empty($setting->info)) {
                                                              if (empty($setting->group)) {
                                                                  $this->line('New setting: "'.$setting->key.'": '.$setting->info);
                                                              } else {
                                                                  $this->line('New setting: "'.$setting->group.'.'.$setting->key.'": '.$setting->info);
                          Severity: Major
                          Found in src/Commands/InstallCommand.php - About 45 mins to fix

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

                                public function addNumber(?string $key = null, string|array|null $title = null, string|array|null $placeholder = null, ?int $value = null, ?int $min = null, ?int $max = null): self
                            Severity: Minor
                            Found in src/Classes/DynamicInput.php - About 45 mins to fix

                              Function mounted has a Cognitive Complexity of 8 (exceeds 5 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: Minor
                              Found in resources/assets/js/directives/tooltip.ts - About 45 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

                              Severity
                              Category
                              Status
                              Source
                              Language