django/django

View on GitHub
django/contrib/admin/static/admin/js/SelectFilter2.js

Summary

Maintainability
C
1 day
Test Coverage

Function init has 153 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        init: function(field_id, field_name, is_stacked) {
            if (field_id.match(/__prefix__/)) {
                // Don't initialize on empty forms.
                return;
            }
Severity: Major
Found in django/contrib/admin/static/admin/js/SelectFilter2.js - About 6 hrs to fix

    Function filter_key_down has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

            filter_key_down: function(event, field_id, source, target) {
                const source_box = document.getElementById(field_id + source);
                // right key (39) or left key (37)
                const direction = source === '_from' ? 39 : 37;
                // right arrow -- move across
    Severity: Minor
    Found in django/contrib/admin/static/admin/js/SelectFilter2.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 init has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

            init: function(field_id, field_name, is_stacked) {
                if (field_id.match(/__prefix__/)) {
                    // Don't initialize on empty forms.
                    return;
                }
    Severity: Minor
    Found in django/contrib/admin/static/admin/js/SelectFilter2.js - About 45 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

    Function move_selection has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

                const move_selection = function(e, elem, move_func, from, to) {
    Severity: Minor
    Found in django/contrib/admin/static/admin/js/SelectFilter2.js - About 35 mins to fix

      There are no issues that match your filters.

      Category
      Status