voyager-admin/voyager

View on GitHub

Showing 105 of 127 total issues

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

    public function registerBulkActions()
    {
        $breadmanager = $this->breadmanager;

        $add_action = (new Action('voyager::generic.add_type', 'plus', null, 'green'))
Severity: Minor
Found in src/VoyagerServiceProvider.php - 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 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 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 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

            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

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

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

                            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

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

                                private function addMultipleChoiceInput(string $type, ?string $key = null, string|array|null $title = null, ?array $options = [], ?bool $multiple = false, mixed $value = null): void
                            Severity: Minor
                            Found in src/Classes/DynamicInput.php - About 45 mins to fix
                              Severity
                              Category
                              Status
                              Source
                              Language