voyager-admin/voyager

View on GitHub

Showing 125 of 127 total issues

Function processUploadedFile has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    protected function processUploadedFile($file, $path)
    {
        $name = '';
        $count = 0;
        $thumbnails = 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

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

    public function edit(Request $request, mixed $id): InertiaResponse
    {
        $bread = $this->getBread($request, true);
        $layout = $this->breadmanager->getLayoutForAction($bread, 'edit');

Severity: Minor
Found in src/Http/Controllers/BreadController.php - About 1 hr to fix

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

        mounted(el, binding) {
            el.addEventListener('click', (e) => {
                let content = document.getElementById('content');
                let element = document.getElementById('top');
                if (binding.value !== '') {
    Severity: Minor
    Found in resources/assets/js/directives/scroll-to.js - About 1 hr to fix

      Method setSettings has 34 lines of code (exceeds 25 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 1 hr to fix

        Method updateStoreData has 33 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function updateStoreData(Collection $formfields, mixed $data, mixed $model, bool $update = true): mixed
            {
                $formfields->each(function ($formfield) use ($data, &$model, $update) {
                    $value = $data[$formfield->column->column] ?? '';
        
        
        Severity: Minor
        Found in src/Traits/Bread/Saveable.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

            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

              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

                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

                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

                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

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

                                if ($formfield->translatable ?? false) {
                                    $translations = [];
                                    $value = json_decode($value) ?? [];
                                    foreach ($value as $locale => $translated) {
                                        $translations[$locale] = $formfield->read($translated);
                    Severity: Major
                    Found in src/Http/Controllers/BreadController.php and 1 other location - About 1 hr to fix
                    src/Http/Controllers/BreadController.php on lines 252..261

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

                    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

                                if ($formfield->translatable ?? false) {
                                    $translations = [];
                                    $value = json_decode($value) ?? [];
                                    foreach ($value as $locale => $translated) {
                                        $translations[$locale] = $formfield->edit($translated);
                    Severity: Major
                    Found in src/Http/Controllers/BreadController.php and 1 other location - About 1 hr to fix
                    src/Http/Controllers/BreadController.php on lines 205..214

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

                    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

                            leaveDuration() {
                                if (typeof this.duration === 'object' && this.duration.constructor === Object) {
                                    return this.duration.leave;
                                }
                    
                    
                    Severity: Major
                    Found in resources/assets/components/Transitions/base.js and 1 other location - About 1 hr to fix
                    resources/assets/components/Transitions/base.js on lines 13..19

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

                    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

                            enterDuration() {
                                if (typeof this.duration === 'object' && this.duration.constructor === Object) {
                                    return this.duration.enter;
                                }
                    
                    
                    Severity: Major
                    Found in resources/assets/components/Transitions/base.js and 1 other location - About 1 hr to fix
                    resources/assets/components/Transitions/base.js on lines 20..26

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

                    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 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
                            Severity
                            Category
                            Status
                            Source
                            Language