axsh/wakame-vdc

View on GitHub
frontend/dcmgr_gui/public/javascripts/sprintf-0.7-beta1.js

Summary

Maintainability
F
3 days
Test Coverage

Function sprintf has a Cognitive Complexity of 113 (exceeds 5 allowed). Consider refactoring.
Open

var sprintf = (function() {
    function get_type(variable) {
        return Object.prototype.toString.call(variable).slice(8, -1).toLowerCase();
    }
    function str_repeat(input, multiplier) {
Severity: Minor
Found in frontend/dcmgr_gui/public/javascripts/sprintf-0.7-beta1.js - About 2 days 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 sprintf has 109 lines of code (exceeds 25 allowed). Consider refactoring.
Open

var sprintf = (function() {
    function get_type(variable) {
        return Object.prototype.toString.call(variable).slice(8, -1).toLowerCase();
    }
    function str_repeat(input, multiplier) {
Severity: Major
Found in frontend/dcmgr_gui/public/javascripts/sprintf-0.7-beta1.js - About 4 hrs to fix

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

    str_format.format = function(parse_tree, argv) {
        var cursor = 1, tree_length = parse_tree.length, node_type = '', arg, output = [], i, k, match, pad, pad_character, pad_length;
        for (i = 0; i < tree_length; i++) {
            node_type = get_type(parse_tree[i]);
            if (node_type === 'string') {
Severity: Minor
Found in frontend/dcmgr_gui/public/javascripts/sprintf-0.7-beta1.js - About 1 hr to fix

Function parse has 45 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    str_format.parse = function(fmt) {
        var _fmt = fmt, match = [], parse_tree = [], arg_names = 0;
        while (_fmt) {
            if ((match = /^[^\x25]+/.exec(_fmt)) !== null) {
                parse_tree.push(match[0]);
Severity: Minor
Found in frontend/dcmgr_gui/public/javascripts/sprintf-0.7-beta1.js - About 1 hr to fix

Avoid deeply nested control flow statements.
Open

                        if (!arg.hasOwnProperty(match[2][k])) {
                            throw(sprintf('[sprintf] property "%s" does not exist', match[2][k]));
                        }
Severity: Major
Found in frontend/dcmgr_gui/public/javascripts/sprintf-0.7-beta1.js - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

                        while ((replacement_field = replacement_field.substring(field_match[0].length)) !== '') {
                            if ((field_match = /^\.([a-z_][a-z_\d]*)/i.exec(replacement_field)) !== null) {
                                field_list.push(field_match[1]);
                            }
                            else if ((field_match = /^\[(\d+)\]/.exec(replacement_field)) !== null) {
Severity: Major
Found in frontend/dcmgr_gui/public/javascripts/sprintf-0.7-beta1.js - About 45 mins to fix

There are no issues that match your filters.

Category
Status