voyager-admin/voyager

View on GitHub

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

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

        <?php
        
        namespace Voyager\Admin\Formfields;
        
        use Voyager\Admin\Classes\Formfield;
        Severity: Major
        Found in src/Formfields/MediaPicker.php and 1 other location - About 4 hrs to fix
        src/Formfields/Checkbox.php on lines 1..55

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

        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

        <?php
        
        namespace Voyager\Admin\Formfields;
        
        use Voyager\Admin\Classes\Formfield;
        Severity: Major
        Found in src/Formfields/Checkbox.php and 1 other location - About 4 hrs to fix
        src/Formfields/MediaPicker.php on lines 1..55

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

        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

        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

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

          <?php
          
          namespace Voyager\Admin\Formfields;
          
          use Voyager\Admin\Classes\Formfield;
          Severity: Major
          Found in src/Formfields/SimpleArray.php and 1 other location - About 3 hrs to fix
          src/Formfields/Tags.php on lines 1..50

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

          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

          <?php
          
          namespace Voyager\Admin\Formfields;
          
          use Voyager\Admin\Classes\Formfield;
          Severity: Major
          Found in src/Formfields/Tags.php and 1 other location - About 3 hrs to fix
          src/Formfields/SimpleArray.php on lines 1..50

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

          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

          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

                        Severity
                        Category
                        Status
                        Source
                        Language