Skip to content

Commit

Permalink
refactor: some code smells by Sonarcloud fixes (#869)
Browse files Browse the repository at this point in the history
Co-authored-by: souvik <[email protected]>
  • Loading branch information
lovebug356 and Souvikns authored Nov 29, 2023
1 parent dd8ccc8 commit 21d782f
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/commands/generate/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -322,15 +322,15 @@ export default class Models extends Command {
const models = await fileGenerator.generateToFiles(
convertedDoc as any,
output,
{ ...fileOptions, } as any);
{ ...fileOptions, });
const generatedModels = models.map((model) => { return model.modelName; });
this.log(`Successfully generated the following models: ${generatedModels.join(', ')}`);
return;
}

const models = await fileGenerator.generateCompleteModels(
convertedDoc as any,
{ ...fileOptions } as any);
{ ...fileOptions });
const generatedModels = models.map((model) => {
return `
## Model name: ${model.modelName}
Expand Down
2 changes: 1 addition & 1 deletion src/flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ export const watchFlag = (description?: string) => {
return Flags.boolean({
default: false,
char: 'w',
description: description || 'Enable watch mode',
description: description ?? 'Enable watch mode',
});
};
2 changes: 1 addition & 1 deletion src/globals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export type SpecWatcherParams = {

export const specWatcher = (params: SpecWatcherParams) => {
if (!params.spec.getFilePath()) { return WATCH_MESSAGES.logOnAutoDisable(params.docVersion); }
if (CHOKIDAR_INSTANCE_STORE.get(params.label || '_default')) { return; }
if (CHOKIDAR_INSTANCE_STORE.get(params.label ?? '_default')) { return; }

const filePath = params.spec.getFilePath() as string;
try {
Expand Down
3 changes: 1 addition & 2 deletions src/hooks/command_not_found/myhook.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {Hook, toConfiguredId, CliUx} from '@oclif/core';
import {Help, Hook, toConfiguredId, CliUx} from '@oclif/core';
import chalk from 'chalk';
import {default as levenshtein} from 'fast-levenshtein';
import { Help } from '@oclif/core';

export const closest = (target: string, possibilities: string[]): string =>
possibilities
Expand Down
2 changes: 1 addition & 1 deletion src/models/SpecificationFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export class Specification {
}

getSource() {
return this.getFilePath() || this.getFileURL();
return this.getFilePath() ?? this.getFileURL();
}

toSourceString() {
Expand Down

0 comments on commit 21d782f

Please sign in to comment.