Showing 187 of 448 total issues
Function new
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
static new(logger: Logger, name: string, symbol: string, initialTotal = 0): ProgressBarCLI {
if (!ProgressBarCLI.multiBar) {
ProgressBarCLI.multiBar = new cliProgress.MultiBar(
{
stream: logger.getLogLevel() < LogLevel.NEVER ? logger.getStream() : new PassThrough(),
Function prefer
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
prefer(
dat: DAT,
parentsToCandidates: Map<Parent, ReleaseCandidate[]>,
): Map<Parent, ReleaseCandidate[]> {
this.progressBar.logTrace(`${dat.getNameShort()}: preferring candidates`);
Function fromFilePoly
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
static async fromFilePoly(patchFile: FilePoly): Promise<VcdiffHeader> {
const header = await patchFile.readNext(3);
if (!header.equals(VcdiffHeader.FILE_SIGNATURE)) {
await patchFile.close();
throw new ExpectedError(`Vcdiff patch header is invalid: ${patchFile.getPathLike()}`);
Function filter
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
filter(dat: DAT): DAT {
// Return early if there aren't any games
if (dat.getGames().length === 0) {
this.progressBar.logTrace(`${dat.getNameShort()}: no games to filter`);
return dat;
Function getOrComputeFileChecksums
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
async getOrComputeFileChecksums(filePath: string, checksumBitmask: number): Promise<File> {
// NOTE(cemmer): we're explicitly not catching ENOENT errors here, we want it to bubble up
const stats = await FsPoly.stat(filePath);
const cacheKey = await this.getCacheKey(filePath, undefined, ValueType.FILE_CHECKSUMS);
Function filesFrom
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
Open
async filesFrom(
filePath: string,
fileChecksumBitmask: number = ChecksumBitmask.CRC32,
archiveChecksumBitmask = fileChecksumBitmask,
): Promise<File[]> {
- 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 getAllowedTypes
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
Open
private static getAllowedTypes(options: Options): ROMType[] {
return [
!options.getOnlyBios() && !options.getOnlyDevice() && !options.getOnlyRetail()
? ROMType.GAME
: undefined,
- 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 missingGames
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
.flatMap((game) => {
let missingDependencies: string[] = [];
// Validate dependent parent was found
if (
Function toConsole
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
toConsole(options: Options): string {
return `${DATStatus.getAllowedTypes(options)
.filter((type) => this.allRomTypesToGames.get(type)?.length)
.map((type) => {
const found = this.foundRomTypesToReleaseCandidates.get(type) ?? [];
Function entriesFromArchiveExtension
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private async entriesFromArchiveExtension(
filePath: string,
checksumBitmask: number,
fileExt = filePath.replace(/.+?(?=(\.[a-zA-Z0-9]+)+)/, ''),
): Promise<ArchiveEntry<Archive>[] | undefined> {
Function merge
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
merge(dat: DAT): DAT {
// Don't do anything if no type provided
if (this.options.getMergeRoms() === undefined) {
this.progressBar.logTrace(
`${dat.getNameShort()}: no ROM merge option provided, doing nothing`,
Function validateUniqueOutputPaths
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private validateUniqueOutputPaths(
dat: DAT,
parentsToCandidates: Map<Parent, ReleaseCandidate[]>,
): ReleaseCandidate[] {
const outputPathsToCandidates = [...parentsToCandidates.values()]
Function decode
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
decode(
copyAddressesData: Buffer,
copyAddressesOffset: number,
here: number,
mode: number,
Function scanPaths
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private static async scanPaths(
globPatterns: string[],
walkCallback?: FsWalkCallback,
requireFiles = true,
): Promise<string[]> {
Function getArchiveEntries
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
async getArchiveEntries(checksumBitmask: number): Promise<ArchiveEntry<this>[]> {
// https://github.com/ZJONSSON/node-unzipper/issues/280
// UTF-8 entry names are not decoded correctly
// But this is mitigated by `extractEntryToStream()` and therefore `extractEntryToFile()` both
// using `unzipper.Open.file()` as well, so mangled filenames here will still extract fine
Function getArchiveEntriesNotCached
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private async getArchiveEntriesNotCached(checksumBitmask: number): Promise<ArchiveEntry<this>[]> {
/**
* WARN(cemmer): {@link _7z.list} seems to have issues with any amount of real concurrency,
* it will return no files but also no error. Try to prevent that behavior.
*/
Function globPath
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private static async globPath(
inputPath: string,
walkCallback: FsWalkCallback,
): Promise<string[]> {
// Windows will report that \\.\nul doesn't exist, catch it explicitly
Function hashedReleaseCandidates
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
releaseCandidates.map(async (releaseCandidate) => {
const hashedRomsWithFiles = await Promise.all(
releaseCandidate.getRomsWithFiles().map(async (romWithFiles) => {
const correctedRom = await this.buildCorrectedRom(
dat,
Function downloadDats
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private async downloadDats(datFiles: File[]): Promise<File[]> {
if (!datFiles.some((datFile) => datFile.isURL())) {
return datFiles;
}
Function hash
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
async hash(
dat: DAT,
parentsToCandidates: Map<Parent, ReleaseCandidate[]>,
): Promise<Map<Parent, ReleaseCandidate[]>> {
if (parentsToCandidates.size === 0) {