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

View on GitHub
src/renderer/ui/pages/PlayerPage.js

Summary

Maintainability
B
4 hrs
Test Coverage

Function render has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  render() {
    return (
      <WindowContainer isMainWindow title={process.platform === 'darwin' ? this.state.title : ''} confirmClose={this._confirmCloseWindow}>
        <div className="drag-handle-large"></div>
        <div className={`loader ${this.state.loading ? '' : 'hidden'}`}>
Severity: Minor
Found in src/renderer/ui/pages/PlayerPage.js - About 1 hr to fix

    Function constructor has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      constructor(...args) {
        super(...args);
    
        this.once = true;
        const service = Settings.get('service');
    Severity: Minor
    Found in src/renderer/ui/pages/PlayerPage.js - About 35 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

    Unexpected constant condition.
    Open

        } else if (service === 'google-play-music' || true) {
    Severity: Minor
    Found in src/renderer/ui/pages/PlayerPage.js by eslint

    disallow constant expressions in conditions (no-constant-condition)

    A constant expression (for example, a literal) as a test condition might be a typo or development trigger for a specific behavior. For example, the following code looks as if it is not ready for production.

    if (false) {
        doSomethingUnfinished();
    }

    Rule Details

    This rule disallows constant expressions in the test condition of:

    • if, for, while, or do...while statement
    • ?: ternary expression

    Examples of incorrect code for this rule:

    /*eslint no-constant-condition: "error"*/
    
    if (false) {
        doSomethingUnfinished();
    }
    
    if (void x) {
        doSomethingUnfinished();
    }
    
    for (;-2;) {
        doSomethingForever();
    }
    
    while (typeof x) {
        doSomethingForever();
    }
    
    do {
        doSomethingForever();
    } while (x = -1);
    
    var result = 0 ? a : b;

    Examples of correct code for this rule:

    /*eslint no-constant-condition: "error"*/
    
    if (x === 0) {
        doSomething();
    }
    
    for (;;) {
        doSomethingForever();
    }
    
    while (typeof x === "undefined") {
        doSomething();
    }
    
    do {
        doSomething();
    } while (x);
    
    var result = x !== 0 ? a : b;

    Options

    checkLoops

    Set to true by default. Setting this option to false allows constant expressions in loops.

    Examples of correct code for when checkLoops is false:

    /*eslint no-constant-condition: ["error", { "checkLoops": false }]*/
    
    while (true) {
        doSomething();
        if (condition()) {
            break;
        }
    };
    
    for (;true;) {
        doSomething();
        if (condition()) {
            break;
        }
    };
    
    do {
        doSomething();
        if (condition()) {
            break;
        }
    } while (true)

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

    Unexpected constant condition.
    Open

        } else if (service === 'google-play-music' || true) {
    Severity: Minor
    Found in src/renderer/ui/pages/PlayerPage.js by eslint

    disallow constant expressions in conditions (no-constant-condition)

    A constant expression (for example, a literal) as a test condition might be a typo or development trigger for a specific behavior. For example, the following code looks as if it is not ready for production.

    if (false) {
        doSomethingUnfinished();
    }

    Rule Details

    This rule disallows constant expressions in the test condition of:

    • if, for, while, or do...while statement
    • ?: ternary expression

    Examples of incorrect code for this rule:

    /*eslint no-constant-condition: "error"*/
    
    if (false) {
        doSomethingUnfinished();
    }
    
    if (void x) {
        doSomethingUnfinished();
    }
    
    for (;-2;) {
        doSomethingForever();
    }
    
    while (typeof x) {
        doSomethingForever();
    }
    
    do {
        doSomethingForever();
    } while (x = -1);
    
    var result = 0 ? a : b;

    Examples of correct code for this rule:

    /*eslint no-constant-condition: "error"*/
    
    if (x === 0) {
        doSomething();
    }
    
    for (;;) {
        doSomethingForever();
    }
    
    while (typeof x === "undefined") {
        doSomething();
    }
    
    do {
        doSomething();
    } while (x);
    
    var result = x !== 0 ? a : b;

    Options

    checkLoops

    Set to true by default. Setting this option to false allows constant expressions in loops.

    Examples of correct code for when checkLoops is false:

    /*eslint no-constant-condition: ["error", { "checkLoops": false }]*/
    
    while (true) {
        doSomething();
        if (condition()) {
            break;
        }
    };
    
    for (;true;) {
        doSomething();
        if (condition()) {
            break;
        }
    };
    
    do {
        doSomething();
        if (condition()) {
            break;
        }
    } while (true)

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

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

        if (service === 'youtube-music') {
          this.targetPage = Settings.get('savePage', true) ?
            Settings.get('lastYTMPage', 'https://music.youtube.com/')
            : 'https://music.youtube.com/';
          this.state = {
    Severity: Major
    Found in src/renderer/ui/pages/PlayerPage.js and 1 other location - About 1 hr to fix
    src/renderer/ui/pages/PlayerPage.js on lines 37..46

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

    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

        } else if (service === 'google-play-music' || true) {
          this.targetPage = Settings.get('savePage', true) ?
            Settings.get('lastPage', 'https://play.google.com/music/listen')
            : 'https://play.google.com/music/listen';
          this.state = {
    Severity: Major
    Found in src/renderer/ui/pages/PlayerPage.js and 1 other location - About 1 hr to fix
    src/renderer/ui/pages/PlayerPage.js on lines 28..46

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

    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

    Using string literals in ref attributes is deprecated.
    Open

              ref="view"
    Severity: Minor
    Found in src/renderer/ui/pages/PlayerPage.js by eslint

    For more information visit Source: http://eslint.org/docs/rules/

    Using this.refs is deprecated.
    Open

          this.refs.view.focus();
    Severity: Minor
    Found in src/renderer/ui/pages/PlayerPage.js by eslint

    For more information visit Source: http://eslint.org/docs/rules/

    Using string literals in ref attributes is deprecated.
    Open

            <ConfirmTrayModal ref="trayModal" />
    Severity: Minor
    Found in src/renderer/ui/pages/PlayerPage.js by eslint

    For more information visit Source: http://eslint.org/docs/rules/

    Empty components are self-closing
    Open

            <div className="drag-handle-large"></div>
    Severity: Minor
    Found in src/renderer/ui/pages/PlayerPage.js by eslint

    For more information visit Source: http://eslint.org/docs/rules/

    Using this.refs is deprecated.
    Open

          this.refs.view.executeJavaScript(`window.location = "${this.targetPage}"`);
    Severity: Minor
    Found in src/renderer/ui/pages/PlayerPage.js by eslint

    For more information visit Source: http://eslint.org/docs/rules/

    JSX not allowed in files with extension '.js'
    Open

          <WindowContainer isMainWindow title={process.platform === 'darwin' ? this.state.title : ''} confirmClose={this._confirmCloseWindow}>
    Severity: Minor
    Found in src/renderer/ui/pages/PlayerPage.js by eslint

    For more information visit Source: http://eslint.org/docs/rules/

    Using this.refs is deprecated.
    Open

        this.refs.trayModal.show();
    Severity: Minor
    Found in src/renderer/ui/pages/PlayerPage.js by eslint

    For more information visit Source: http://eslint.org/docs/rules/

    There are no issues that match your filters.

    Category
    Status