MarshallOfSound/Google-Play-Music-Desktop-Player-UNOFFICIAL-

View on GitHub
src/main/features/core/discordRichPresence.js

Summary

Maintainability
C
7 hrs
Test Coverage

Function setPresence has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
Open

const setPresence = () => {
  if (!Settings.get('discordRichPresence', false)) {
    if (client) {
      client.disconnect();
      client = null;
Severity: Minor
Found in src/main/features/core/discordRichPresence.js - About 4 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 setPresence has 58 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const setPresence = () => {
  if (!Settings.get('discordRichPresence', false)) {
    if (client) {
      client.disconnect();
      client = null;
Severity: Major
Found in src/main/features/core/discordRichPresence.js - About 2 hrs to fix

    Unexpected use of continue statement.
    Open

            if (track.album !== queue[i].album) continue;

    disallow continue statements (no-continue)

    The continue statement terminates execution of the statements in the current iteration of the current or labeled loop, and continues execution of the loop with the next iteration. When used incorrectly it makes code less testable, less readable and less maintainable. Structured control flow statements such as if should be used instead.

    var sum = 0,
        i;
    
    for(i = 0; i < 10; i++) {
        if(i >= 5) {
            continue;
        }
    
        a += i;
    }

    Rule Details

    This rule disallows continue statements.

    Examples of incorrect code for this rule:

    /*eslint no-continue: "error"*/
    
    var sum = 0,
        i;
    
    for(i = 0; i < 10; i++) {
        if(i >= 5) {
            continue;
        }
    
        a += i;
    }
    /*eslint no-continue: "error"*/
    
    var sum = 0,
        i;
    
    labeledLoop: for(i = 0; i < 10; i++) {
        if(i >= 5) {
            continue labeledLoop;
        }
    
        a += i;
    }

    Examples of correct code for this rule:

    /*eslint no-continue: "error"*/
    
    var sum = 0,
        i;
    
    for(i = 0; i < 10; i++) {
        if(i < 5) {
           a += i;
        }
    }

    Compatibility

    Unexpected use of continue statement.
    Open

            if (track.title !== queue[i].title) continue;

    disallow continue statements (no-continue)

    The continue statement terminates execution of the statements in the current iteration of the current or labeled loop, and continues execution of the loop with the next iteration. When used incorrectly it makes code less testable, less readable and less maintainable. Structured control flow statements such as if should be used instead.

    var sum = 0,
        i;
    
    for(i = 0; i < 10; i++) {
        if(i >= 5) {
            continue;
        }
    
        a += i;
    }

    Rule Details

    This rule disallows continue statements.

    Examples of incorrect code for this rule:

    /*eslint no-continue: "error"*/
    
    var sum = 0,
        i;
    
    for(i = 0; i < 10; i++) {
        if(i >= 5) {
            continue;
        }
    
        a += i;
    }
    /*eslint no-continue: "error"*/
    
    var sum = 0,
        i;
    
    labeledLoop: for(i = 0; i < 10; i++) {
        if(i >= 5) {
            continue labeledLoop;
        }
    
        a += i;
    }

    Examples of correct code for this rule:

    /*eslint no-continue: "error"*/
    
    var sum = 0,
        i;
    
    for(i = 0; i < 10; i++) {
        if(i < 5) {
           a += i;
        }
    }

    Compatibility

    Unexpected use of continue statement.
    Open

            if (track.artist !== queue[i].artist) continue;

    disallow continue statements (no-continue)

    The continue statement terminates execution of the statements in the current iteration of the current or labeled loop, and continues execution of the loop with the next iteration. When used incorrectly it makes code less testable, less readable and less maintainable. Structured control flow statements such as if should be used instead.

    var sum = 0,
        i;
    
    for(i = 0; i < 10; i++) {
        if(i >= 5) {
            continue;
        }
    
        a += i;
    }

    Rule Details

    This rule disallows continue statements.

    Examples of incorrect code for this rule:

    /*eslint no-continue: "error"*/
    
    var sum = 0,
        i;
    
    for(i = 0; i < 10; i++) {
        if(i >= 5) {
            continue;
        }
    
        a += i;
    }
    /*eslint no-continue: "error"*/
    
    var sum = 0,
        i;
    
    labeledLoop: for(i = 0; i < 10; i++) {
        if(i >= 5) {
            continue labeledLoop;
        }
    
        a += i;
    }

    Examples of correct code for this rule:

    /*eslint no-continue: "error"*/
    
    var sum = 0,
        i;
    
    for(i = 0; i < 10; i++) {
        if(i < 5) {
           a += i;
        }
    }

    Compatibility

    Unary operator '++' used.
    Open

          for (let i = 0; i < queue.length; i++) {

    disallow the unary operators ++ and -- (no-plusplus)

    Because the unary ++ and -- operators are subject to automatic semicolon insertion, differences in whitespace can change semantics of source code.

    var i = 10;
    var j = 20;
    
    i ++
    j
    // i = 11, j = 20
    var i = 10;
    var j = 20;
    
    i
    ++
    j
    // i = 10, j = 21

    Rule Details

    This rule disallows the unary operators ++ and --.

    Examples of incorrect code for this rule:

    /*eslint no-plusplus: "error"*/
    
    var foo = 0;
    foo++;
    
    var bar = 42;
    bar--;
    
    for (i = 0; i < l; i++) {
        return;
    }

    Examples of correct code for this rule:

    /*eslint no-plusplus: "error"*/
    
    var foo = 0;
    foo += 1;
    
    var bar = 42;
    bar -= 1;
    
    for (i = 0; i < l; i += 1) {
        return;
    }

    Options

    This rule has an object option.

    • "allowForLoopAfterthoughts": true allows unary operators ++ and -- in the afterthought (final expression) of a for loop.

    allowForLoopAfterthoughts

    Examples of correct code for this rule with the { "allowForLoopAfterthoughts": true } option:

    /*eslint no-plusplus: ["error", { "allowForLoopAfterthoughts": true }]*/
    
    for (i = 0; i < l; i++) {
        return;
    }
    
    for (i = 0; i < l; i--) {
        return;
    }

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

    There are no issues that match your filters.

    Category
    Status