junebug12851/pokered-save-editor

View on GitHub
src/app/data/savefile-expanded/fragments/PokemonBox.ts

Summary

Maintainability
C
1 day
Test Coverage

Showing 100 of 101 total issues

File PokemonBox.ts has 321 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { SaveFileIterator } from './../SaveFileIterator';
import { SaveFileService } from './../../savefile.service';
import {Pokemon} from '../../../../assets/data/pokemon';
import { GameDataService } from '../../gameData.service';
import { PokemonDBService } from '../../pokemonDB.service';
Severity: Minor
Found in src/app/data/savefile-expanded/fragments/PokemonBox.ts - About 3 hrs to fix

Function load has 61 lines of code (exceeds 25 allowed). Consider refactoring.
Wontfix

public load(saveFile: SaveFileService,
startOffset: number,
nicknameStartOffset: number,
otNameStartOffset: number,
index: number,
Severity: Major
Found in src/app/data/savefile-expanded/fragments/PokemonBox.ts - About 2 hrs to fix

Function save has 52 lines of code (exceeds 25 allowed). Consider refactoring.
Open

public save(saveFile: SaveFileService,
startOffset: number,
speciesStartOffset: number | null,
nicknameStartOffset: number,
otNameStartOffset: number,
Severity: Major
Found in src/app/data/savefile-expanded/fragments/PokemonBox.ts - About 2 hrs to fix

Function newPokemon has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

static newPokemon(file: SaveFileService, pdb: PokemonDBService, gd: GameDataService) {
const pkmn = new PokemonBox();
const pkmnList = gd.file("randomPkmn").data;
const pkmnData = pdb.pokemon[_.snakeCase(pkmnList[_.random(0, pkmnList.length, false)])];
 
 
Severity: Minor
Found in src/app/data/savefile-expanded/fragments/PokemonBox.ts - About 1 hr to fix

Function newPokemon has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

static newPokemon(file: SaveFileService, pdb: PokemonDBService, gd: GameDataService) {
const pkmn = new PokemonBox();
const pkmnList = gd.file("randomPkmn").data;
const pkmnData = pdb.pokemon[_.snakeCase(pkmnList[_.random(0, pkmnList.length, false)])];
 
 
Severity: Minor
Found in src/app/data/savefile-expanded/fragments/PokemonBox.ts - About 1 hr to fix

Function save has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

public save(saveFile: SaveFileService,
startOffset: number,
speciesStartOffset: number | null,
nicknameStartOffset: number,
otNameStartOffset: number,
Severity: Minor
Found in src/app/data/savefile-expanded/fragments/PokemonBox.ts - About 45 mins to fix

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

pkmn.moves[i].pp = (pkmnData.initial[i]) ? pkmnData.initial[i].pp : 0;
Severity: Minor
Found in src/app/data/savefile-expanded/fragments/PokemonBox.ts and 1 other location - About 30 mins to fix
src/app/data/savefile-expanded/fragments/PokemonBox.ts on lines 62..62

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

pkmn.moves[i].moveID = (pkmnData.initial[i]) ? pkmnData.initial[i].ind : 0;
Severity: Minor
Found in src/app/data/savefile-expanded/fragments/PokemonBox.ts and 1 other location - About 30 mins to fix
src/app/data/savefile-expanded/fragments/PokemonBox.ts on lines 63..63

if statements must be braced
Open

if(this.isValidPokemon === false)
return this.exp;

missing whitespace
Open

exp = (1.2 * Math.pow(level, 3)) - (15 * Math.pow(level, 2)) + (100*level) - 140;

missing whitespace
Open

return Math.floor((((baseStat+dv)*2+Math.floor(Math.floor(Math.sqrt(ev))/4))*this.level)/100) + 5;

missing whitespace
Open

return Math.floor((((baseStat+dv)*2+Math.floor(Math.floor(Math.sqrt(ev))/4))*this.level)/100) + 5;

missing whitespace
Open

return Math.floor((((baseStat+dv)*2+Math.floor(Math.floor(Math.sqrt(ev))/4))*this.level)/100) + 5;

missing whitespace
Open

if(pkmnData.type1 !== undefined)

if statements must be braced
Open

if(pkmnData.type2 !== undefined)
pkmn.type2 = pkmnData.type2.ind;

if statements must be braced
Open

if(pkmnData.initial == undefined)
continue;

if statements must be braced
Open

if(pkmnData.catchRate !== undefined)
pkmn.catchRate = pkmnData.catchRate;

" should be '
Open

if(nickname == "NIDORAN<F>")

" should be '
Open

return this.getNonHPStat("baseSpeed", this.dv.speed, this.speedExp);

missing whitespace
Open

return Math.floor((((record.baseHp+this.hpDV)*2+Math.floor(Math.floor(Math.sqrt(this.hpExp))/4))*this.level)/100) + this.level + 10;

missing whitespace
Open

return Math.floor((((record.baseHp+this.hpDV)*2+Math.floor(Math.floor(Math.sqrt(this.hpExp))/4))*this.level)/100) + this.level + 10;

missing whitespace
Open

return Math.floor((((baseStat+dv)*2+Math.floor(Math.floor(Math.sqrt(ev))/4))*this.level)/100) + 5;

missing whitespace
Open

if(gr == 0)

missing whitespace
Open

if(this.isValidPokemon === false)

missing whitespace
Open

if((this.dv.speed % 2) !== 0)

if statements must be braced
Open

if(record === false)
return exp;

if statements must be braced
Open

if(this.level >= 100)
return 1;

" should be '
Open

return this.getNonHPStat("baseSpecial", this.dv.special, this.specialExp);

if statements must be braced
Open

else if(gr == 3)
exp = (1.2 * Math.pow(level, 3)) - (15 * Math.pow(level, 2)) + (100*level) - 140;

" should be '
Open

const _ = window.require("lodash");

Missing semicolon
Open

nickname = "NIDORAN<f>"

missing whitespace
Open

return Math.floor((((record.baseHp+this.hpDV)*2+Math.floor(Math.floor(Math.sqrt(this.hpExp))/4))*this.level)/100) + this.level + 10;

missing whitespace
Open

return Math.floor((((baseStat+dv)*2+Math.floor(Math.floor(Math.sqrt(ev))/4))*this.level)/100) + 5;

missing whitespace
Open

if(pkmnData.type2 !== undefined)

if statements must be braced
Open

else if(nickname == "NIDORAN<M>")
nickname = "NIDORAN<m>"

missing whitespace
Open

for(let i = 0; i < 4; i++) {

missing whitespace
Open

return Math.floor((((baseStat+dv)*2+Math.floor(Math.floor(Math.sqrt(ev))/4))*this.level)/100) + 5;

missing whitespace
Open

else if(gr == 5)

if statements must be braced
Open

if(record === false)
return 0;

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

let record = this.pkmnArr[this.species - 1];

" should be '
Open

nickname = "NIDORAN<m>"

missing whitespace
Open

return Math.floor((((record.baseHp+this.hpDV)*2+Math.floor(Math.floor(Math.sqrt(this.hpExp))/4))*this.level)/100) + this.level + 10;

missing whitespace
Open

return Math.floor((((record.baseHp+this.hpDV)*2+Math.floor(Math.floor(Math.sqrt(this.hpExp))/4))*this.level)/100) + this.level + 10;

missing whitespace
Open

return Math.floor((((baseStat+dv)*2+Math.floor(Math.floor(Math.sqrt(ev))/4))*this.level)/100) + 5;

missing whitespace
Open

if(pkmnData.initial == undefined)

missing whitespace
Open

if(pkmnData.catchRate !== undefined)

missing whitespace
Open

if((this.dv.attack % 2) !== 0)

if statements must be braced
Open

if((this.dv.defense % 2) !== 0)
hpDv |= 4;

" should be '
Open

return this.getNonHPStat("baseAttack", this.dv.attack, this.attackExp);

missing whitespace
Open

if((this.dv.special % 2) !== 0)

if statements must be braced
Open

if(pkmnData.type1 !== undefined)
pkmn.type1 = pkmnData.type1.ind;

" should be '
Open

const pkmnList = gd.file("randomPkmn").data;

" should be '
Open

nickname = "NIDORAN<f>"

missing whitespace
Open

if(this.isValidPokemon === false)

missing whitespace
Open

exp = (1.2 * Math.pow(level, 3)) - (15 * Math.pow(level, 2)) + (100*level) - 140;

missing whitespace
Open

return Math.floor((((record.baseHp+this.hpDV)*2+Math.floor(Math.floor(Math.sqrt(this.hpExp))/4))*this.level)/100) + this.level + 10;

missing whitespace
Open

return Math.floor((((record.baseHp+this.hpDV)*2+Math.floor(Math.floor(Math.sqrt(this.hpExp))/4))*this.level)/100) + this.level + 10;

missing whitespace
Open

if(this.level >= 100)

missing whitespace
Open

return Math.floor((((baseStat+dv)*2+Math.floor(Math.floor(Math.sqrt(ev))/4))*this.level)/100) + 5;

missing whitespace
Open

if(nickname == "NIDORAN<F>")

missing whitespace
Open

if(speciesStartOffset !== null) {

missing whitespace
Open

if(this.isValidPokemon === false)

if statements must be braced
Open

if(pkmn.type1 == pkmn.type2)
pkmn.type2 = 0xFF;

if statements must be braced
Open

else if(gr == 4)
exp = (4 * Math.pow(level, 3)) / 5

if statements must be braced
Open

if(this.isValidPokemon === false)
return;

if statements must be braced
Open

if((this.dv.attack % 2) !== 0)
hpDv |= 8;

missing whitespace
Open

return Math.floor((((record.baseHp+this.hpDV)*2+Math.floor(Math.floor(Math.sqrt(this.hpExp))/4))*this.level)/100) + this.level + 10;

missing whitespace
Open

return Math.floor((((baseStat+dv)*2+Math.floor(Math.floor(Math.sqrt(ev))/4))*this.level)/100) + 5;

missing whitespace
Open

return Math.floor((((baseStat+dv)*2+Math.floor(Math.floor(Math.sqrt(ev))/4))*this.level)/100) + 5;

missing whitespace
Open

if(record === false)

if statements must be braced
Open

if(gr == 0)
exp = Math.pow(level, 3);

if statements must be braced
Open

else if(gr == 5)
exp = (5 * Math.pow(level, 3)) / 4

if statements must be braced
Open

if((this.dv.speed % 2) !== 0)
hpDv |= 2;

" should be '
Open

return this.getNonHPStat("baseDefense", this.dv.defense, this.defenseExp);

Missing semicolon
Open

exp = (5 * Math.pow(level, 3)) / 4

missing whitespace
Open

return Math.floor((((record.baseHp+this.hpDV)*2+Math.floor(Math.floor(Math.sqrt(this.hpExp))/4))*this.level)/100) + this.level + 10;

missing whitespace
Open

else if(gr == 3)

missing whitespace
Open

else if(gr == 4)

if statements must be braced
Open

if(this.isValidPokemon === false)
return this.exp;

if statements must be braced
Open

if(record === false || record.baseHp == undefined)
return 1;

missing whitespace
Open

return Math.floor((((record.baseHp+this.hpDV)*2+Math.floor(Math.floor(Math.sqrt(this.hpExp))/4))*this.level)/100) + this.level + 10;

missing whitespace
Open

if((this.dv.defense % 2) !== 0)

if statements must be braced
Open

if(nickname == "NIDORAN<F>")
nickname = "NIDORAN<f>"

if statements must be braced
Open

if((this.dv.special % 2) !== 0)
hpDv |= 1;

" should be '
Open

else if(nickname == "NIDORAN<M>")

missing whitespace
Open

else if(nickname == "NIDORAN<M>")

missing whitespace
Open

if(this.isValidPokemon === false)

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

let record = this.isValidPokemon;

missing whitespace
Open

return Math.floor((((baseStat+dv)*2+Math.floor(Math.floor(Math.sqrt(ev))/4))*this.level)/100) + 5;

missing whitespace
Open

if(pkmn.type1 == pkmn.type2)

missing whitespace
Open

if(record == undefined || record.pokedex == null || record.pokedex == undefined)

missing whitespace
Open

if(record === false)

if statements must be braced
Open

if(record == undefined || record.pokedex == null || record.pokedex == undefined)
return false;

if statements must be braced
Open

if(this.isValidPokemon === false)
return 0;

" should be '
Open

this.pkmnArr = this.gd.file("pokemon").data;

Missing semicolon
Open

nickname = "NIDORAN<m>"

missing whitespace
Open

return Math.floor((((record.baseHp+this.hpDV)*2+Math.floor(Math.floor(Math.sqrt(this.hpExp))/4))*this.level)/100) + this.level + 10;

Missing semicolon
Open

exp = (4 * Math.pow(level, 3)) / 5

missing whitespace
Open

return Math.floor((((record.baseHp+this.hpDV)*2+Math.floor(Math.floor(Math.sqrt(this.hpExp))/4))*this.level)/100) + this.level + 10;

missing whitespace
Open

return Math.floor((((baseStat+dv)*2+Math.floor(Math.floor(Math.sqrt(ev))/4))*this.level)/100) + 5;

missing whitespace
Open

if(record === false || record.baseHp == undefined)
Category
Status