junebug12851/pokered-save-editor

View on GitHub
src/app/data/text.service.ts

Summary

Maintainability
C
1 day
Test Coverage

Showing 51 of 51 total issues

Function convertEngToHTML has 56 lines of code (exceeds 25 allowed). Consider refactoring.
Open

public convertEngToHTML(msg: string, maxChars: number, rival: string = "BLUE", player: string = "RED") {
// Convert string to char codes
let charCodes = Array.from(this.convertToCode(msg, maxChars, false));
 
// Pre-pass
Severity: Major
Found in src/app/data/text.service.ts - About 2 hrs to fix

Function convertEngToHTML has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

public convertEngToHTML(msg: string, maxChars: number, rival: string = "BLUE", player: string = "RED") {
// Convert string to char codes
let charCodes = Array.from(this.convertToCode(msg, maxChars, false));
 
// Pre-pass
Severity: Minor
Found in src/app/data/text.service.ts - About 2 hrs to fix

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

else if (char === 0x5A) {
const str = Array.from(this.convertToCode("Enemy BLASTOISE", 100, false));
charCodes.splice(i, 1, ...str);
}
// <pc>
Severity: Major
Found in src/app/data/text.service.ts and 6 other locations - About 35 mins to fix
src/app/data/text.service.ts on lines 176..214
src/app/data/text.service.ts on lines 181..214
src/app/data/text.service.ts on lines 186..214
src/app/data/text.service.ts on lines 196..214
src/app/data/text.service.ts on lines 201..214
src/app/data/text.service.ts on lines 206..214

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

else if (char === 0x5B) {
const str = Array.from(this.convertToCode("PC", 100, false));
charCodes.splice(i, 1, ...str);
}
// <tm>
Severity: Major
Found in src/app/data/text.service.ts and 6 other locations - About 35 mins to fix
src/app/data/text.service.ts on lines 176..214
src/app/data/text.service.ts on lines 181..214
src/app/data/text.service.ts on lines 186..214
src/app/data/text.service.ts on lines 191..214
src/app/data/text.service.ts on lines 201..214
src/app/data/text.service.ts on lines 206..214

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

else if (char === 0x56) {
const str = Array.from(this.convertToCode("<...><...>", 10, false));
charCodes.splice(i, 1, ...str);
}
// <targ>
Severity: Major
Found in src/app/data/text.service.ts and 6 other locations - About 35 mins to fix
src/app/data/text.service.ts on lines 176..214
src/app/data/text.service.ts on lines 186..214
src/app/data/text.service.ts on lines 191..214
src/app/data/text.service.ts on lines 196..214
src/app/data/text.service.ts on lines 201..214
src/app/data/text.service.ts on lines 206..214

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

else if (char === 0x5D) {
const str = Array.from(this.convertToCode("TRAINER", 100, false));
charCodes.splice(i, 1, ...str);
}
// <rocket>
Severity: Major
Found in src/app/data/text.service.ts and 6 other locations - About 35 mins to fix
src/app/data/text.service.ts on lines 176..214
src/app/data/text.service.ts on lines 181..214
src/app/data/text.service.ts on lines 186..214
src/app/data/text.service.ts on lines 191..214
src/app/data/text.service.ts on lines 196..214
src/app/data/text.service.ts on lines 201..214

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

else if (char === 0x54) {
const str = Array.from(this.convertToCode("POK<e>", 10, false));
charCodes.splice(i, 1, ...str);
}
// <......>
Severity: Major
Found in src/app/data/text.service.ts and 6 other locations - About 35 mins to fix
src/app/data/text.service.ts on lines 181..214
src/app/data/text.service.ts on lines 186..214
src/app/data/text.service.ts on lines 191..214
src/app/data/text.service.ts on lines 196..214
src/app/data/text.service.ts on lines 201..214
src/app/data/text.service.ts on lines 206..214

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

else if (char === 0x59) {
const str = Array.from(this.convertToCode("CHARIZARD", 100, false));
charCodes.splice(i, 1, ...str);
}
// <user>
Severity: Major
Found in src/app/data/text.service.ts and 6 other locations - About 35 mins to fix
src/app/data/text.service.ts on lines 176..214
src/app/data/text.service.ts on lines 181..214
src/app/data/text.service.ts on lines 191..214
src/app/data/text.service.ts on lines 196..214
src/app/data/text.service.ts on lines 201..214
src/app/data/text.service.ts on lines 206..214

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

else if (char === 0x5C) {
const str = Array.from(this.convertToCode("TM", 100, false));
charCodes.splice(i, 1, ...str);
}
// <trainer>
Severity: Major
Found in src/app/data/text.service.ts and 6 other locations - About 35 mins to fix
src/app/data/text.service.ts on lines 176..214
src/app/data/text.service.ts on lines 181..214
src/app/data/text.service.ts on lines 186..214
src/app/data/text.service.ts on lines 191..214
src/app/data/text.service.ts on lines 196..214
src/app/data/text.service.ts on lines 206..214

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

else if (char === 0x53) {
const rivalName = Array.from(this.convertToCode(rival, 7, false));
charCodes.splice(i, 1, ...rivalName);
}
// POK<e>
Severity: Minor
Found in src/app/data/text.service.ts and 1 other location - About 35 mins to fix
src/app/data/text.service.ts on lines 166..214

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

else if (char === 0x52) {
const playerName = Array.from(this.convertToCode(player, 7, false));
charCodes.splice(i, 1, ...playerName);
}
// <rival>
Severity: Minor
Found in src/app/data/text.service.ts and 1 other location - About 35 mins to fix
src/app/data/text.service.ts on lines 171..214

misplaced 'else'
Open

else if (char === 0x5E) {
Severity: Minor
Found in src/app/data/text.service.ts by tslint

comment must start with a space
Open

//and stop here
Severity: Minor
Found in src/app/data/text.service.ts by tslint

if statements must be braced
Open

if (this.indToEng[char].useTilemap)
fontStr.push(`<div class="pr pr-pic pr-${char.toString(16).toUpperCase().padStart(2, "0")}"></div>`);
Severity: Minor
Found in src/app/data/text.service.ts by tslint

misplaced 'else'
Open

else if (char === 0x52) {
Severity: Minor
Found in src/app/data/text.service.ts by tslint

" should be '
Open

const str = Array.from(this.convertToCode("PC", 100, false));
Severity: Minor
Found in src/app/data/text.service.ts by tslint

" should be '
Open

const str = Array.from(this.convertToCode("TRAINER", 100, false));
Severity: Minor
Found in src/app/data/text.service.ts by tslint

Missing semicolon
Open

}
Severity: Minor
Found in src/app/data/text.service.ts by tslint

if statements must be braced
Open

if (this.indToEng[code] === undefined)
continue;
Severity: Minor
Found in src/app/data/text.service.ts by tslint

misplaced 'else'
Open

else if (char === 0x5A) {
Severity: Minor
Found in src/app/data/text.service.ts by tslint

" should be '
Open

return new TextSearch(this.gd.file("text").data);
Severity: Minor
Found in src/app/data/text.service.ts by tslint

" should be '
Open

fontStr.push(`<div class="pr pr-pic pr-${char.toString(16).toUpperCase().padStart(2, "0")}"></div>`);
Severity: Minor
Found in src/app/data/text.service.ts by tslint

if statements must be braced
Open

if (code.length === maxLength ||
lastCode === 0x50)
break;
Severity: Minor
Found in src/app/data/text.service.ts by tslint

if statements must be braced
Open

if ((typeof str !== 'string') && autoEnd)
return new Uint8Array([0x50]);
Severity: Minor
Found in src/app/data/text.service.ts by tslint

misplaced 'else'
Open

else if (char === 0x5D) {
Severity: Minor
Found in src/app/data/text.service.ts by tslint

if statements must be braced
Open

if (!str.startsWith(transPair.eng))
continue;
Severity: Minor
Found in src/app/data/text.service.ts by tslint

misplaced 'else'
Open

else if (char === 0x53) {
Severity: Minor
Found in src/app/data/text.service.ts by tslint

misplaced 'else'
Open

else if (char === 0x56) {
Severity: Minor
Found in src/app/data/text.service.ts by tslint

misplaced 'else'
Open

else if (char === 0x59) {
Severity: Minor
Found in src/app/data/text.service.ts by tslint

" should be '
Open

const text: Text[] = this.gd.file("text").data;
Severity: Minor
Found in src/app/data/text.service.ts by tslint

" should be '
Open

public convertEngToHTML(msg: string, maxChars: number, rival: string = "BLUE", player: string = "RED") {
Severity: Minor
Found in src/app/data/text.service.ts by tslint

" should be '
Open

const str = Array.from(this.convertToCode("POK<e>", 10, false));
Severity: Minor
Found in src/app/data/text.service.ts by tslint

" should be '
Open

const str = Array.from(this.convertToCode("ROCKET", 100, false));
Severity: Minor
Found in src/app/data/text.service.ts by tslint

if statements must be braced
Open

if (autoEnd)
code.push(0x50);
Severity: Minor
Found in src/app/data/text.service.ts by tslint

if statements must be braced
Open

if (i === maxLength)
break;
Severity: Minor
Found in src/app/data/text.service.ts by tslint

else statements must be braced
Open

else
fontStr.push(`<div class="pr pr-${char.toString(16).toUpperCase().padStart(2, "0")}"></div>`);
Severity: Minor
Found in src/app/data/text.service.ts by tslint

" should be '
Open

let eng = "";
Severity: Minor
Found in src/app/data/text.service.ts by tslint

" should be '
Open

public convertEngToHTML(msg: string, maxChars: number, rival: string = "BLUE", player: string = "RED") {
Severity: Minor
Found in src/app/data/text.service.ts by tslint

" should be '
Open

const str = Array.from(this.convertToCode("CHARIZARD", 100, false));
Severity: Minor
Found in src/app/data/text.service.ts by tslint

misplaced 'else'
Open

else if (char === 0x5B) {
Severity: Minor
Found in src/app/data/text.service.ts by tslint

Identifier 'code' is never reassigned; use 'const' instead of 'let'.
Open

let code = [];
Severity: Minor
Found in src/app/data/text.service.ts by tslint

Identifier 'charCodes' is never reassigned; use 'const' instead of 'let'.
Open

let charCodes = Array.from(this.convertToCode(msg, maxChars, false));
Severity: Minor
Found in src/app/data/text.service.ts by tslint

if statements must be braced
Open

if (match === false)
str = str.substring(1);
Severity: Minor
Found in src/app/data/text.service.ts by tslint

if statements must be braced
Open

else if ((typeof str !== 'string') && !autoEnd)
return new Uint8Array();
Severity: Minor
Found in src/app/data/text.service.ts by tslint

" should be '
Open

const str = Array.from(this.convertToCode("TM", 100, false));
Severity: Minor
Found in src/app/data/text.service.ts by tslint

" should be '
Open

fontStr.push(`<div class="pr pr-${char.toString(16).toUpperCase().padStart(2, "0")}"></div>`);
Severity: Minor
Found in src/app/data/text.service.ts by tslint

misplaced 'else'
Open

else if (char === 0x54) {
Severity: Minor
Found in src/app/data/text.service.ts by tslint

misplaced 'else'
Open

else if (char === 0x5C) {
Severity: Minor
Found in src/app/data/text.service.ts by tslint

" should be '
Open

const str = Array.from(this.convertToCode("<...><...>", 10, false));
Severity: Minor
Found in src/app/data/text.service.ts by tslint

if statements must be braced
Open

if (code === 0x50)
break;
Severity: Minor
Found in src/app/data/text.service.ts by tslint

" should be '
Open

const str = Array.from(this.convertToCode("Enemy BLASTOISE", 100, false));
Severity: Minor
Found in src/app/data/text.service.ts by tslint

There are no issues that match your filters.

Category
Status