UniSharp/laravel-filemanager

View on GitHub

Showing 35 of 35 total issues

File script.js has 651 lines of code (exceeds 250 allowed). Consider refactoring.
Open

var lfm_route = location.origin + location.pathname;
var show_list;
var sort_type = 'alphabetic';
var multi_selection_enabled = false;
var selected = [];
Severity: Major
Found in public/js/script.js - About 1 day to fix

    Function use has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
    Open

    function use(items) {
      function useTinymce3(url) {
        if (!usingTinymce3()) { return; }
    
        var win = tinyMCEPopup.getWindowArg("window");
    Severity: Minor
    Found in public/js/script.js - 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

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

        public function getDelete()
        {
            $item_names = request('items');
            $errors = [];
    
    
    Severity: Minor
    Found in src/Controllers/DeleteController.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

    Lfm has 27 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Lfm
    {
        const PACKAGE_NAME = 'laravel-filemanager';
        const DS = '/';
    
    
    Severity: Minor
    Found in src/Lfm.php - About 3 hrs to fix

      Function loadItems has 79 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function loadItems(page) {
        loading(true);
        performLfmRequest('jsonitems', {show_list: show_list, sort_type: sort_type, page: page || 1}, 'html')
          .done(function (data) {
            selected = [];
      Severity: Major
      Found in public/js/script.js - About 3 hrs to fix

        Method routes has 74 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public static function routes()
            {
                $middleware = [ CreateDefaultFolder::class, MultiUser::class ];
                $as = 'unisharp.lfm.';
                $namespace = '\\UniSharp\\LaravelFilemanager\\Controllers\\';
        Severity: Major
        Found in src/Lfm.php - About 2 hrs to fix

          Function use has 74 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function use(items) {
            function useTinymce3(url) {
              if (!usingTinymce3()) { return; }
          
              var win = tinyMCEPopup.getWindowArg("window");
          Severity: Major
          Found in public/js/script.js - About 2 hrs to fix

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

                for (i = 1; i < rangeStart; i++) {
                  var button = $(template)
                    .attr('data-num', i)
                    .append($(linkTemplate).html(i));
                  if (i == currentPage) {
            Severity: Major
            Found in public/js/script.js and 1 other location - About 2 hrs to fix
            public/js/script.js on lines 328..336

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

            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

                for (i = 1; i <= totalPage; i++) {
                  var button = $(template)
                    .attr('data-num', i)
                    .append($(linkTemplate).html(i));
                  if (i == currentPage) {
            Severity: Major
            Found in public/js/script.js and 1 other location - About 2 hrs to fix
            public/js/script.js on lines 342..350

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

            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 generatePaginationHTML has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
            Open

            function generatePaginationHTML(el, args) {
              var template = '<li class="page-item"><\/li>';
              var linkTemplate = '<a class="page-link"><\/a>';
              var currentPage = args.currentPage;
              var totalPage = args.totalPage;
            Severity: Minor
            Found in public/js/script.js - 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

            LfmPath has 24 functions (exceeds 20 allowed). Consider refactoring.
            Open

            class LfmPath
            {
                private $working_dir;
                private $item_name;
                private $is_thumb = false;
            Severity: Minor
            Found in src/LfmPath.php - About 2 hrs to fix

              Function generatePaginationHTML has 65 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function generatePaginationHTML(el, args) {
                var template = '<li class="page-item"><\/li>';
                var linkTemplate = '<a class="page-link"><\/a>';
                var currentPage = args.currentPage;
                var totalPage = args.totalPage;
              Severity: Major
              Found in public/js/script.js - About 2 hrs to fix

                File index.blade.php has 273 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                <!DOCTYPE html>
                <html lang="en">
                <head>
                  <meta charset="UTF-8">
                  <meta http-equiv="X-UA-Compatible" content="IE=EDGE" />
                Severity: Minor
                Found in src/views/index.blade.php - About 2 hrs to fix

                  Function getRename has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function getRename()
                      {
                          $old_name = $this->helper->input('file');
                          $new_name = $this->helper->input('new_name');
                  
                  
                  Severity: Minor
                  Found in src/Controllers/RenameController.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

                  File Lfm.php has 257 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  <?php
                  
                  namespace UniSharp\LaravelFilemanager;
                  
                  use Illuminate\Contracts\Config\Repository as Config;
                  Severity: Minor
                  Found in src/Lfm.php - About 2 hrs to fix

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

                            return view('laravel-filemanager::tree')
                                ->with([
                                    'root_folders' => array_map(function ($type) use ($folder_types) {
                                        $path = $this->lfm->dir($this->helper->getRootFolder($type));
                    
                    
                    Severity: Major
                    Found in src/Controllers/FolderController.php and 1 other location - About 2 hrs to fix
                    src/Controllers/ItemsController.php on lines 45..57

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

                    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

                            return view('laravel-filemanager::move')
                                ->with([
                                    'root_folders' => array_map(function ($type) use ($folder_types) {
                                        $path = $this->lfm->dir($this->helper->getRootFolder($type));
                    
                    
                    Severity: Major
                    Found in src/Controllers/ItemsController.php and 1 other location - About 2 hrs to fix
                    src/Controllers/FolderController.php on lines 21..33

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

                    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 getRename has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function getRename()
                        {
                            $old_name = $this->helper->input('file');
                            $new_name = $this->helper->input('new_name');
                    
                    
                    Severity: Minor
                    Found in src/Controllers/RenameController.php - About 1 hr to fix

                      Function preview has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      function preview(items) {
                        var carousel = $('#carouselTemplate').clone().attr('id', 'previewCarousel').removeClass('d-none');
                        var imageTemplate = carousel.find('.carousel-item').clone().removeClass('active');
                        var indicatorTemplate = carousel.find('.carousel-indicators > li').clone().removeClass('active');
                        carousel.children('.carousel-inner').html('');
                      Severity: Minor
                      Found in public/js/script.js - About 1 hr to fix

                        Method getDelete has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public function getDelete()
                            {
                                $item_names = request('items');
                                $errors = [];
                        
                        
                        Severity: Minor
                        Found in src/Controllers/DeleteController.php - About 1 hr to fix
                          Severity
                          Category
                          Status
                          Source
                          Language