radare/radare2-webui

View on GitHub
www/enyo/js/rightpanel.js

Summary

Maintainability
B
6 hrs
Test Coverage

Function itemSelected has 63 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    itemSelected: function(inSender, inEvent) {
        var self = this;
        var selected = inEvent.originator.content;
        var is_visible = this.$.menu.getShowing();
        r2ui.rp = self;
Severity: Major
Found in www/enyo/js/rightpanel.js - About 2 hrs to fix

    Method 'itemSelected' has a complexity of 10.
    Open

        itemSelected: function(inSender, inEvent) {
    Severity: Minor
    Found in www/enyo/js/rightpanel.js by eslint

    Limit Cyclomatic Complexity (complexity)

    Cyclomatic complexity measures the number of linearly independent paths through a program's source code. This rule allows setting a cyclomatic complexity threshold.

    function a(x) {
        if (true) {
            return x; // 1st path
        } else if (false) {
            return x+1; // 2nd path
        } else {
            return 4; // 3rd path
        }
    }

    Rule Details

    This rule is aimed at reducing code complexity by capping the amount of cyclomatic complexity allowed in a program. As such, it will warn when the cyclomatic complexity crosses the configured threshold (default is 20).

    Examples of incorrect code for a maximum of 2:

    /*eslint complexity: ["error", 2]*/
    
    function a(x) {
        if (true) {
            return x;
        } else if (false) {
            return x+1;
        } else {
            return 4; // 3rd path
        }
    }

    Examples of correct code for a maximum of 2:

    /*eslint complexity: ["error", 2]*/
    
    function a(x) {
        if (true) {
            return x;
        } else {
            return 4;
        }
    }

    Options

    Optionally, you may specify a max object property:

    "complexity": ["error", 2]

    is equivalent to

    "complexity": ["error", { "max": 2 }]

    Deprecated: the object property maximum is deprecated. Please use the property max instead.

    When Not To Use It

    If you can't determine an appropriate complexity limit for your code, then it's best to disable this rule.

    Further Reading

    Related Rules

    • [max-depth](max-depth.md)
    • [max-len](max-len.md)
    • [max-nested-callbacks](max-nested-callbacks.md)
    • [max-params](max-params.md)
    • [max-statements](max-statements.md) Source: http://eslint.org/docs/rules/

    The body of a for-in should be wrapped in an if statement to filter unwanted properties from the prototype.
    Open

                    for (var i in s) {
    Severity: Minor
    Found in www/enyo/js/rightpanel.js by eslint

    Require Guarding for-in (guard-for-in)

    Looping over objects with a for in loop will include properties that are inherited through the prototype chain. This behavior can lead to unexpected items in your for loop.

    for (key in foo) {
        doSomething(key);
    }

    Note that simply checking foo.hasOwnProperty(key) is likely to cause an error in some cases; see [no-prototype-builtins](no-prototype-builtins.md).

    Rule Details

    This rule is aimed at preventing unexpected behavior that could arise from using a for in loop without filtering the results in the loop. As such, it will warn when for in loops do not filter their results with an if statement.

    Examples of incorrect code for this rule:

    /*eslint guard-for-in: "error"*/
    
    for (key in foo) {
        doSomething(key);
    }

    Examples of correct code for this rule:

    /*eslint guard-for-in: "error"*/
    
    for (key in foo) {
        if (Object.prototype.hasOwnProperty.call(foo, key)) {
            doSomething(key);
        }
        if ({}.hasOwnProperty.call(foo, key)) {
            doSomething(key);
        }
    }

    Related Rules

    • [no-prototype-builtins](no-prototype-builtins.md)

    Further Reading

    Redundant double negation.
    Open

            this.$.scroll.setShowing(!!!is_visible);
    Severity: Minor
    Found in www/enyo/js/rightpanel.js by eslint

    disallow unnecessary boolean casts (no-extra-boolean-cast)

    In contexts such as an if statement's test where the result of the expression will already be coerced to a Boolean, casting to a Boolean via double negation (!!) or a Boolean call is unnecessary. For example, these if statements are equivalent:

    if (!!foo) {
        // ...
    }
    
    if (Boolean(foo)) {
        // ...
    }
    
    if (foo) {
        // ...
    }

    Rule Details

    This rule disallows unnecessary boolean casts.

    Examples of incorrect code for this rule:

    /*eslint no-extra-boolean-cast: "error"*/
    
    var foo = !!!bar;
    
    var foo = !!bar ? baz : bat;
    
    var foo = Boolean(!!bar);
    
    var foo = new Boolean(!!bar);
    
    if (!!foo) {
        // ...
    }
    
    if (Boolean(foo)) {
        // ...
    }
    
    while (!!foo) {
        // ...
    }
    
    do {
        // ...
    } while (Boolean(foo));
    
    for (; !!foo; ) {
        // ...
    }

    Examples of correct code for this rule:

    /*eslint no-extra-boolean-cast: "error"*/
    
    var foo = !!bar;
    var foo = Boolean(bar);
    
    function foo() {
        return !!bar;
    }
    
    var foo = bar ? !!baz : !!bat;

    Source: http://eslint.org/docs/rules/

    The body of a for-in should be wrapped in an if statement to filter unwanted properties from the prototype.
    Open

                    for (var i in s) {
    Severity: Minor
    Found in www/enyo/js/rightpanel.js by eslint

    Require Guarding for-in (guard-for-in)

    Looping over objects with a for in loop will include properties that are inherited through the prototype chain. This behavior can lead to unexpected items in your for loop.

    for (key in foo) {
        doSomething(key);
    }

    Note that simply checking foo.hasOwnProperty(key) is likely to cause an error in some cases; see [no-prototype-builtins](no-prototype-builtins.md).

    Rule Details

    This rule is aimed at preventing unexpected behavior that could arise from using a for in loop without filtering the results in the loop. As such, it will warn when for in loops do not filter their results with an if statement.

    Examples of incorrect code for this rule:

    /*eslint guard-for-in: "error"*/
    
    for (key in foo) {
        doSomething(key);
    }

    Examples of correct code for this rule:

    /*eslint guard-for-in: "error"*/
    
    for (key in foo) {
        if (Object.prototype.hasOwnProperty.call(foo, key)) {
            doSomething(key);
        }
        if ({}.hasOwnProperty.call(foo, key)) {
            doSomething(key);
        }
    }

    Related Rules

    • [no-prototype-builtins](no-prototype-builtins.md)

    Further Reading

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

            case 'functions':
                r2.cmd('afl', function(x) {
                    x = x.replace(/0x([a-zA-Z0-9]*)/g, '<a style=\'color:yellow\' href=\'javascript:r2ui.seek("0x$1")\'>0x$1</a>');
                    self.$.output.setContent(x);
                });
    Severity: Major
    Found in www/enyo/js/rightpanel.js and 1 other location - About 1 hr to fix
    www/enyo/js/rightpanel.js on lines 89..94

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

    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

            case 'comments':
                r2.cmd('CC*', function(x) {
                    x = x.replace(/0x([a-zA-Z0-9]*)/g, '<a style=\'color:yellow\' href=\'javascript:r2ui.seek("0x$1")\'>0x$1</a>');
                    self.$.output.setContent(x);
                });
    Severity: Major
    Found in www/enyo/js/rightpanel.js and 1 other location - About 1 hr to fix
    www/enyo/js/rightpanel.js on lines 95..100

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

    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 4 locations. Consider refactoring.
    Open

            case 'symbols':
                r2.bin_symbols(function(x) {
                    self.$.output.setContent(makelist(x));
                });
                break;
    Severity: Major
    Found in www/enyo/js/rightpanel.js and 3 other locations - About 30 mins to fix
    www/enyo/js/rightpanel.js on lines 116..120
    www/enyo/js/rightpanel.js on lines 126..130
    www/enyo/js/rightpanel.js on lines 131..135

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

    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 4 locations. Consider refactoring.
    Open

            case 'relocs':
                r2.bin_relocs(function(x) {
                    self.$.output.setContent(makelist(x));
                });
                break;
    Severity: Major
    Found in www/enyo/js/rightpanel.js and 3 other locations - About 30 mins to fix
    www/enyo/js/rightpanel.js on lines 116..120
    www/enyo/js/rightpanel.js on lines 121..125
    www/enyo/js/rightpanel.js on lines 131..135

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

    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 4 locations. Consider refactoring.
    Open

            case 'imports':
                r2.bin_imports(function(x) {
                    self.$.output.setContent(makelist(x));
                });
                break;
    Severity: Major
    Found in www/enyo/js/rightpanel.js and 3 other locations - About 30 mins to fix
    www/enyo/js/rightpanel.js on lines 116..120
    www/enyo/js/rightpanel.js on lines 121..125
    www/enyo/js/rightpanel.js on lines 126..130

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

    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 4 locations. Consider refactoring.
    Open

            case 'sections':
                r2.bin_sections(function(x) {
                    self.$.output.setContent(makelist(x));
                });
                break;
    Severity: Major
    Found in www/enyo/js/rightpanel.js and 3 other locations - About 30 mins to fix
    www/enyo/js/rightpanel.js on lines 121..125
    www/enyo/js/rightpanel.js on lines 126..130
    www/enyo/js/rightpanel.js on lines 131..135

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

    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