UniSharp/laravel-filemanager

View on GitHub
public/js/script.js

Summary

Maintainability
F
4 days
Test Coverage

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

      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

        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

        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

          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

            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

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

              confirm(lang['message-delete'], function () {
                performLfmRequest('delete', {
                  items: items.map(function (item) { return item.name; })
                }).done(refreshFoldersAndItems)
              });
            Severity: Minor
            Found in public/js/script.js and 1 other location - About 35 mins to fix
            public/js/script.js on lines 645..648

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

            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

            function move(items) {
              performLfmRequest('move', { items: items.map(function (item) { return item.name; }) })
                .done(refreshFoldersAndItems);
            }
            Severity: Minor
            Found in public/js/script.js and 1 other location - About 35 mins to fix
            public/js/script.js on lines 547..551

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

            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

            There are no issues that match your filters.

            Category
            Status