FC-softwares/baseball-scoreboard

View on GitHub
app/js/app.js

Summary

Maintainability
A
0 mins
Test Coverage

Showing 0 of 20 total issues

Function updateScoreboard has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Wontfix

function updateScoreboard(obj) {
try { document.querySelector("div.teamScore#home").innerHTML = obj.Teams.Home.Score; } catch (error) { console.error(error); }
try { document.querySelector("div.teamScore#away").innerHTML = obj.Teams.Away.Score; } catch (error) { console.error(error); }
// Ball Strike
updateNumber(obj?.Ball, "ball");
Severity: Minor
Found in app/js/app.js - About 3 hrs to fix

Function updateSettings has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Wontfix

function updateSettings(obj){
// Settings
const oldMaxInning = parseInt(localStorage.getItem("MaxInning"));
localStorage.setItem("MaxInning",obj.MaxInning);
localStorage.setItem("BlackenLastInning",obj.BlackenLastInning);
Severity: Minor
Found in app/js/app.js - About 2 hrs to fix

Function maxInning has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Wontfix

function maxInning(obj, extraInningScoreAway, extraInningScoreHome) {
if( obj.Inning <= parseInt(localStorage.getItem("MaxInning"))){
document.documentElement.style.setProperty('--i-inning', localStorage.getItem("MaxInning"));
try{document.querySelector("div.container > div#iex").remove();}catch(error){console.log(error);}
}else if (obj.Inning > parseInt(localStorage.getItem("MaxInning")) + 1 || (obj.Arrow == 2 && obj.Inning == parseInt(localStorage.getItem("MaxInning"))+1) || extraInningScoreAway != 0 || extraInningScoreHome != 0) {
Severity: Minor
Found in app/js/app.js - About 2 hrs to fix

Function updateBase has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Wontfix

function updateBase(base,id) {
if (base !== undefined) {
if (base) {
try { document.querySelector("div#"+id).classList.remove("disabled"); } catch (error) { console.error(error); }
} else {
Severity: Minor
Found in app/js/app.js - About 1 hr to fix

Function updateInning has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Wontfix

function updateInning(obj) {
let { extraInningScoreAway, extraInningScoreHome } = updateGeneralInning(obj);
for (let i = 1; i <= obj.Inning; i++) {
if (i > localStorage.getItem("MaxInning")) {
extraInningScoreAway += obj.Int[i].A;
Severity: Minor
Found in app/js/app.js - About 55 mins to fix

Function updateTeams has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Wontfix

function updateTeams(data,team) {
setName(data?.Name, team, ["pregame","postgame"]);
setName(data?.Short, team, ["scoreboard","inning"]);
if (data?.Color !== undefined) {
document.documentElement.style.setProperty('--c-' + team, data.Color);
Severity: Minor
Found in app/js/app.js - About 35 mins to fix

Function connectSettings has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Wontfix

function connectSettings(obj) {
// Settings
localStorage.setItem("MaxInning",obj.MaxInning);
localStorage.setItem("BlackenLastInning",obj.BlackenLastInning);
// Set the container with the innings
Severity: Minor
Found in app/js/app.js - About 25 mins to fix

Function activeDeactiveInning has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Wontfix

function activeDeactiveInning(i,team,active,score){
if(active){
try{
document.querySelector("#i" + i + " > #"+team).classList.remove("disabledinng");
document.querySelector("#i" + i + " > #"+team).innerHTML = score;
Severity: Minor
Found in app/js/app.js - About 25 mins to fix

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

if (obj.Arrow == 1) {
try { document.querySelector(".inning > span#up").classList.remove("disabled"); } catch (error) { console.error(error); }
try { document.querySelector(".inning > span#down").classList.add("disabled"); } catch (error) { console.error(error); }
} else {
Severity: Major
Found in app/js/app.js and 1 other location - About 3 hrs to fix
app/js/app.js on lines 154..157

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

} else {
try { document.querySelector(".inning > span#up").classList.add("disabled"); } catch (error) { console.error(error); }
try { document.querySelector(".inning > span#down").classList.remove("disabled"); } catch (error) { console.error(error); }
}
Severity: Major
Found in app/js/app.js and 1 other location - About 3 hrs to fix
app/js/app.js on lines 151..154

Identical blocks of code found in 2 locations. Consider refactoring.
Wontfix

function activeDeactiveScoreboard(data,url){
if (data !== undefined && document.URL.includes(url)) {
if (data) {
document.querySelector("div.scoreboard").classList.remove("disabled");
} else {
Severity: Major
Found in app/js/app.js and 1 other location - About 2 hrs to fix
app/js/appOfficials.js on lines 19..27

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

if( obj.Inning <= parseInt(localStorage.getItem("MaxInning"))){
document.documentElement.style.setProperty('--i-inning', localStorage.getItem("MaxInning"));
try{document.querySelector("div.container > div#iex").remove();}catch(error){console.log(error);}
}else if (obj.Inning > parseInt(localStorage.getItem("MaxInning")) + 1 || (obj.Arrow == 2 && obj.Inning == parseInt(localStorage.getItem("MaxInning"))+1) || extraInningScoreAway != 0 || extraInningScoreHome != 0) {
let inning = getComputedStyle(document.documentElement).getPropertyValue('--i-inning');
Severity: Major
Found in app/js/app.js and 1 other location - About 2 hrs to fix
app/js/app.js on lines 135..138

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

} else if (getComputedStyle(document.documentElement).getPropertyValue('--i-inning') != localStorage.getItem("MaxInning")) {
document.documentElement.style.setProperty('--i-inning', localStorage.getItem("MaxInning"));
try { document.querySelector("div.container > #iex.inning").remove(); } catch (error) { console.error(error); }
}
Severity: Major
Found in app/js/app.js and 1 other location - About 2 hrs to fix
app/js/app.js on lines 118..138

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

function updateActive(json){
const obj = JSON.parse(json);
activeDeactiveScoreboard(obj?.main, 'scoreboard.html');
activeDeactiveScoreboard(obj?.pre, 'pregame.html');
activeDeactiveScoreboard(obj?.post, 'postgame.html');
Severity: Major
Found in app/js/app.js and 1 other location - About 1 hr to fix
app/js/appOfficials.js on lines 11..17

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

function updateNumber(data, id) {
if(data !== undefined)
try { document.querySelector("span#" + id).innerHTML = data; } catch (error) { console.error(error); }
}
Severity: Major
Found in app/js/app.js and 1 other location - About 1 hr to fix
app/js/app.js on lines 94..97

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

function updateGeneralSccoreInning(Score,id) {
if (Score !== undefined)
try { document.querySelector(".score > #"+id).innerHTML = Score; } catch (error) { console.error(error); }
}
Severity: Major
Found in app/js/app.js and 1 other location - About 1 hr to fix
app/js/app.js on lines 183..186

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

} else {
try { document.querySelector("div#"+id).classList.add("disabled"); } catch (error) { console.error(error); }
}
Severity: Major
Found in app/js/app.js and 1 other location - About 1 hr to fix
app/js/app.js on lines 175..177

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

if (base) {
try { document.querySelector("div#"+id).classList.remove("disabled"); } catch (error) { console.error(error); }
} else {
Severity: Major
Found in app/js/app.js and 1 other location - About 1 hr to fix
app/js/app.js on lines 177..179

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

if (data !== undefined)
try { document.querySelector("div.teamScore#"+team+" > span").innerHTML = data; } catch (error) { console.error(error); }
Severity: Minor
Found in app/js/app.js and 1 other location - About 55 mins to fix
app/js/app.js on lines 60..61

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

if (data !== undefined && scoreboards.includes(document.URL.split("/").pop().split(".")[0]))
try { document.querySelector("div.teamName#" + team + " > div > span").innerHTML = data; } catch (error) { console.error(error); }
Severity: Minor
Found in app/js/app.js and 1 other location - About 55 mins to fix
app/js/app.js on lines 37..38

There are no issues that match your filters.

Category
Status