the-teacher/the_sortable_tree

View on GitHub

Showing 6 of 12 total issues

Function _mouseDrag has 89 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        _mouseDrag: function(event) {

            //Compute the helpers position
            this.position = this._generatePosition(event);
            this.positionAbs = this._convertPositionTo("absolute");
Severity: Major
Found in app/assets/javascripts/the_sortable_tree/jquery.ui.nestedSortable.js - About 3 hrs to fix

    Method build_server_tree has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

      def build_server_tree(tree, options= {})
        result = ''
        tree   = Array.wrap tree
        opts   = {
          # node and base node params
    Severity: Minor
    Found in app/helpers/the_sortable_tree_helper.rb - 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 build_server_tree has 51 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def build_server_tree(tree, options= {})
        result = ''
        tree   = Array.wrap tree
        opts   = {
          # node and base node params
    Severity: Major
    Found in app/helpers/the_sortable_tree_helper.rb - About 2 hrs to fix

      Function toArray has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              toArray: function(o) {
      
                  o = o || {};
                  var sDepth = o.startDepthCount || 0;
                  var ret = [];

        Method rebuild has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def rebuild
              id        = params[:id].to_i
              parent_id = params[:parent_id].to_i
              prev_id   = params[:prev_id].to_i
              next_id   = params[:next_id].to_i
        Severity: Minor
        Found in app/controllers/the_sortable_tree_controller.rb - About 25 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 copy_helper_files has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

              def copy_helper_files
                if param_name == 'tree'
                  puts "Copy of tree render helper file"
                  copy_file "../helpers/render_tree_helper.rb", "app/helpers/render_tree_helper.rb"
                elsif param_name == 'sortable'
        Severity: Minor
        Found in lib/generators/the_sortable_tree/views_generator.rb - About 25 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

        Severity
        Category
        Status
        Source
        Language