Showing 187 of 448 total issues
Function downloadToPath
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
async downloadToPath(filePath: string): Promise<File> {
if (await fsPoly.exists(this.getFilePath())) {
return this;
}
Function filterGame
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private filterGame(game: Game): boolean {
// If any condition evaluates to 'true', then the candidate will be excluded
return (
[
this.options.getFilterRegex() &&
Function parseSourceMaterialDatabase
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private async parseSourceMaterialDatabase(
datFile: File,
fileContents: string,
): Promise<DAT | undefined> {
this.progressBar.logTrace(`${datFile.toString()}: attempting to parse SMDB`);
Function hashedRomsWithFiles
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
releaseCandidate.getRomsWithFiles().map(async (romWithFiles) => {
const inputFile = romWithFiles.getInputFile();
if (!(inputFile instanceof ArchiveFile)) {
return romWithFiles;
}
Function save
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public async save(): Promise<void> {
try {
await this.saveMutex.runExclusive(async () => {
// Clear any existing timeout
if (this.saveToFileTimeout !== undefined) {
Function applyCommandOpen
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
Open
private async applyCommandOpen(patchFile: FilePoly, targetFile: FilePoly): Promise<void> {
const multiFile = (await patchFile.readNext(1)).readUInt8();
if (multiFile > 0) {
throw new ExpectedError(
`Multi-file NINJA patches aren't supported: ${this.getFile().toString()}`,
- Read upRead up
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 trashOrDelete
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
Open
private async trashOrDelete(filePaths: string[]): Promise<void> {
// Prefer recycling...
for (let i = 0; i < filePaths.length; i += Defaults.OUTPUT_CLEANER_BATCH_SIZE) {
const filePathsChunk = filePaths.slice(i, i + Defaults.OUTPUT_CLEANER_BATCH_SIZE);
this.progressBar.logInfo(
- Read upRead up
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 render
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
render(force = false): void {
this.singleBarFormatted?.getSingleBar().update(this.payload);
const callback = (): void => {
// Dequeue all log messages
Function walk
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
static async walk(pathLike: PathLike, callback?: FsWalkCallback): Promise<string[]> {
let output: string[] = [];
let entries: fs.Dirent[];
try {
Function hashStream
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public static async hashStream(stream: Stream, checksumBitmask: number): Promise<ChecksumProps> {
// Not calculating any checksums, do nothing
if (!checksumBitmask) {
// WARN(cemmer): this may leave the stream un-drained and therefore some file handles open!
return {};
Function extractEntryToFile
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
async extractEntryToFile(entryPath: string, extractedFilePath: string): Promise<void> {
const tempDir = await fsPoly.mkdtemp(path.join(Temp.getTempDir(), '7z'));
try {
let tempFile = path.join(tempDir, entryPath);
await new Promise<void>((resolve, reject) => {
Function scan
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
async scan(): Promise<Patch[]> {
this.progressBar.logTrace('scanning patch files');
this.progressBar.setSymbol(ProgressBarSymbol.FILE_SCANNING);
this.progressBar.reset(0);
Function process
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
process(
dat: DAT,
parentsToCandidates: Map<Parent, ReleaseCandidate[]>,
): Map<Parent, ReleaseCandidate[]> {
if (parentsToCandidates.size === 0) {
Function infer
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
infer(dat: DAT): DAT {
if (dat.hasParentCloneInfo() && !this.options.getDatIgnoreParentClone()) {
this.progressBar.logTrace(`${dat.getNameShort()}: DAT has parent/clone info, skipping`);
return dat;
}
Function fromFilePoly
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
static async fromFilePoly(inputRomFile: File, patchFile: FilePoly): Promise<PPFHeader> {
const header = (await patchFile.readNext(5)).toString();
if (!header.startsWith(PPFHeader.FILE_SIGNATURE.toString())) {
throw new ExpectedError(`PPF patch header is invalid: ${patchFile.getPathLike()}`);
}
Function fromFilePoly
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
static async fromFilePoly(patchFile: FilePoly): Promise<VcdiffWindow> {
const winIndicator = (await patchFile.readNext(1)).readUInt8();
let sourceSegmentSize = 0;
let sourceSegmentPosition = 0;
if (winIndicator & (VcdiffWinIndicator.SOURCE | VcdiffWinIndicator.TARGET)) {
Function getArchiveEntries
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
async getArchiveEntries(checksumBitmask: number): Promise<ArchiveEntry<this>[]> {
const archiveEntryPromises: Promise<ArchiveEntry<this>>[] = [];
// WARN(cemmer): entries in tar archives don't have headers, the entire file has to be read to
// calculate the CRCs
Function getOrComputeFileSignature
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
async getOrComputeFileSignature(file: File): Promise<FileSignature | undefined> {
// NOTE(cemmer): we're explicitly not catching ENOENT errors here, we want it to bubble up
const stats = await FsPoly.stat(file.getFilePath());
if (stats.size === 0) {
// An empty file can't have a signature
Function getOrComputeFileHeader
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
async getOrComputeFileHeader(file: File): Promise<ROMHeader | undefined> {
// NOTE(cemmer): we're explicitly not catching ENOENT errors here, we want it to bubble up
const stats = await FsPoly.stat(file.getFilePath());
if (stats.size === 0) {
// An empty file can't have a header
Function parseMameListxml
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private async parseMameListxml(mameExecutable: File): Promise<DAT | undefined> {
this.progressBar.logTrace(
`${mameExecutable.toString()}: attempting to get ListXML from MAME executable`,
);