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

View on GitHub
src/renderer/lastFM.js

Summary

Maintainability
B
4 hrs
Test Coverage

Function waitForBody has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

const waitForBody = setInterval(() => {
  if (document.body) {
    clearInterval(waitForBody);
    document.querySelectorAll('.top-bar')[0].setAttribute('style', '-webkit-app-region: drag');
    setInterval(() => {
Severity: Minor
Found in src/renderer/lastFM.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 waitForBody has 42 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const waitForBody = setInterval(() => {
  if (document.body) {
    clearInterval(waitForBody);
    document.querySelectorAll('.top-bar')[0].setAttribute('style', '-webkit-app-region: drag');
    setInterval(() => {
Severity: Minor
Found in src/renderer/lastFM.js - About 1 hr to fix

    Unexpected alert.
    Open

            alert(TranslationProvider.query('lastfm-login-error'));
    Severity: Minor
    Found in src/renderer/lastFM.js by eslint

    Disallow Use of Alert (no-alert)

    JavaScript's alert, confirm, and prompt functions are widely considered to be obtrusive as UI elements and should be replaced by a more appropriate custom UI implementation. Furthermore, alert is often used while debugging code, which should be removed before deployment to production.

    alert("here!");

    Rule Details

    This rule is aimed at catching debugging code that should be removed and popup UI elements that should be replaced with less obtrusive, custom UIs. As such, it will warn when it encounters alert, prompt, and confirm function calls which are not shadowed.

    Examples of incorrect code for this rule:

    /*eslint no-alert: "error"*/
    
    alert("here!");
    
    confirm("Are you sure?");
    
    prompt("What's your name?", "John Doe");

    Examples of correct code for this rule:

    /*eslint no-alert: "error"*/
    
    customAlert("Something happened!");
    
    customConfirm("Are you sure?");
    
    customPrompt("Who are you?");
    
    function foo() {
        var alert = myCustomLib.customAlert;
        alert();
    }

    Related Rules

    There are no issues that match your filters.

    Category
    Status