From d50b7418dc683160b978688c2d25fec3ea285bd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Minelli?= <michael@minelli.me> Date: Thu, 29 Feb 2024 18:03:58 +0100 Subject: [PATCH] Sonar => Restore o. malaspinas comments --- NodeApp/.idea/jetbrainsConfiguration | 2 +- .../subcommands/CompletionBashCommand.ts | 35 +++++++------- .../subcommands/CompletionFishCommand.ts | 32 ++++++------- .../subcommands/CompletionZshCommand.ts | 46 +++++++++---------- 4 files changed, 58 insertions(+), 57 deletions(-) diff --git a/NodeApp/.idea/jetbrainsConfiguration b/NodeApp/.idea/jetbrainsConfiguration index ffc5d65..f572bf3 160000 --- a/NodeApp/.idea/jetbrainsConfiguration +++ b/NodeApp/.idea/jetbrainsConfiguration @@ -1 +1 @@ -Subproject commit ffc5d65f9f0f0e825688177425e526131aa84631 +Subproject commit f572bf3afa0a98675247df85c599b5d1e5a62d0d diff --git a/NodeApp/src/commander/completion/subcommands/CompletionBashCommand.ts b/NodeApp/src/commander/completion/subcommands/CompletionBashCommand.ts index 0127d78..d135440 100644 --- a/NodeApp/src/commander/completion/subcommands/CompletionBashCommand.ts +++ b/NodeApp/src/commander/completion/subcommands/CompletionBashCommand.ts @@ -11,12 +11,12 @@ import GlobalHelper from '../../../helpers class CompletionBashCommand extends CommanderCommand { protected commandName: string = 'bash'; - private installPath = path.join(os.homedir(), '.bash_completion'); + private readonly installPath = path.join(os.homedir(), '.bash_completion'); protected defineCommand() { GlobalHelper.completionCommandDefinition(this.command) - .description('generate bash completion') - .action(this.commandAction.bind(this)); + .description('generate bash completion') + .action(this.commandAction.bind(this)); } private writeFile(filename: string, showInstructions: boolean) { @@ -46,20 +46,21 @@ For more details: ${ TextStyle.URL('https://github.com/scop/bash-completion/blob } /* The completion command must do the following: - - if a file is provided: - - if force is not enabled: - - check if the file exists: - - if it exists, prompt the user that it will be erased - - if ok is given write the file and prompt that a backup has been created - - else create the file containing the completion - - else - - if force is not enabled: - - check if the default file exists: - - if it exists, prompt the user that it will be erased: - - if ok is given write the file and prompt that a backup has been created - - else - - create the file containing the completion - */ + - if a file is provided: + - if force is not enabled: + - check if the bash completion file exists: + - if it exists, prompt the user that it will be overwritten + - if ok is given write the file and prompt that a backup has been created + - else create the file containing the completion + - else + - if force is not enabled: + - check if the default file exists: + - if it exists, prompt the user that it will be erased: + - if ok is given write the file and prompt that a backup has been created + - else + - create the file containing the completion + - create a .zprofile or append the appropriate commands into the .zprofile file + */ protected async commandAction(options: { file: string, force: boolean }): Promise<void> { const filePath = path.resolve(options.file ?? this.installPath); // change that if file is empty const showInstructions = !!options.file; diff --git a/NodeApp/src/commander/completion/subcommands/CompletionFishCommand.ts b/NodeApp/src/commander/completion/subcommands/CompletionFishCommand.ts index 9395550..1b29eab 100644 --- a/NodeApp/src/commander/completion/subcommands/CompletionFishCommand.ts +++ b/NodeApp/src/commander/completion/subcommands/CompletionFishCommand.ts @@ -15,8 +15,8 @@ class CompletionFishCommand extends CommanderCommand { protected defineCommand() { GlobalHelper.completionCommandDefinition(this.command) - .description('generate fish completion') - .action(this.commandAction.bind(this)); + .description('generate fish completion') + .action(this.commandAction.bind(this)); } private writeFile(filename: string, showInstructions: boolean) { @@ -41,20 +41,20 @@ ${ TextStyle.CODE(` cp -i ${ filename } ~/.config/fish/completions # interactiv /* The completion command must do the following: - - if a file is provided: - - if force is not enabled: - - check if the file exists: - - if it exists, prompt the user that it will be erased - - if ok is given write the file and prompt that a backup has been created - - else create the file containing the completion - - else - - if force is not enabled: - - check if the default file exists: - - if it exists, prompt the user that it will be erased: - - if ok is given write the file and prompt that a backup has been created - - else - - create the file containing the completion - */ + - if a file is provided: + - if force is not enabled: + - check if the file exists: + - if it exists, prompt the user that it will be erased + - if ok is given write the file and prompt that a backup has been created + - else create the file containing the completion + - else + - if force is not enabled: + - check if the default file exists: + - if it exists, prompt the user that it will be erased: + - if ok is given write the file and prompt that a backup has been created + - else + - create the file containing the completion + */ protected async commandAction(options: { file: string, force: boolean }): Promise<void> { const filePath = path.resolve(options.file ?? this.installPath); // change that if file is empty const showInstructions = !!options.file; diff --git a/NodeApp/src/commander/completion/subcommands/CompletionZshCommand.ts b/NodeApp/src/commander/completion/subcommands/CompletionZshCommand.ts index 1e97b2b..f7f4b87 100644 --- a/NodeApp/src/commander/completion/subcommands/CompletionZshCommand.ts +++ b/NodeApp/src/commander/completion/subcommands/CompletionZshCommand.ts @@ -11,20 +11,20 @@ import GlobalHelper from '../../../helpers class CompletionZshCommand extends CommanderCommand { protected commandName: string = 'zsh'; - private zprofile: string = path.join(homedir(), '.zprofile'); - private bash_completion = path.join(homedir(), '.bash_completion'); - private load_bash_completion = ` + private readonly zprofile: string = path.join(homedir(), '.zprofile'); + private readonly bashCompletion = path.join(homedir(), '.bash_completion'); + private readonly loadBashCompletion = ` # Added by DojoCLI autoload -U +X compinit && compinit autoload -U +X bashcompinit && bashcompinit -source ${ this.bash_completion } +source ${ this.bashCompletion } `; protected defineCommand() { GlobalHelper.completionCommandDefinition(this.command) - .description('generate zsh completion, which is derived from the bash completion') - .action(this.commandAction.bind(this)); + .description('generate zsh completion, which is derived from the bash completion') + .action(this.commandAction.bind(this)); } private writeFile(filename: string, showInstructions: boolean) { @@ -92,7 +92,7 @@ source ${ filename } } } else { try { - fs.writeFileSync(path, this.load_bash_completion); + fs.writeFileSync(path, this.loadBashCompletion); spinner.succeed(`Zsh profile written.`); } catch ( error ) { spinner.fail(`Error writing in ${ this.zprofile }`); @@ -101,23 +101,23 @@ source ${ filename } } /* The completion command must do the following: - - if a file is provided: - - if force is not enabled: - - check if the bash completion file exists: - - if it exists, prompt the user that it will be overwritten - - if ok is given write the file and prompt that a backup has been created - - else create the file containing the completion - - else - - if force is not enabled: - - check if the default file exists: - - if it exists, prompt the user that it will be erased: - - if ok is given write the file and prompt that a backup has been created - - else - - create the file containing the completion - - create a .zprofile or append the appropriate commands into the .zprofile file - */ + - if a file is provided: + - if force is not enabled: + - check if the bash completion file exists: + - if it exists, prompt the user that it will be overwritten + - if ok is given write the file and prompt that a backup has been created + - else create the file containing the completion + - else + - if force is not enabled: + - check if the default file exists: + - if it exists, prompt the user that it will be erased: + - if ok is given write the file and prompt that a backup has been created + - else + - create the file containing the completion + - create a .zprofile or append the appropriate commands into the .zprofile file + */ protected async commandAction(options: { file: string, force: boolean }): Promise<void> { - const filePath = path.resolve(options.file ?? this.bash_completion); // change that if file is empty + const filePath = path.resolve(options.file ?? this.bashCompletion); // change that if file is empty const showInstructions = !!options.file; if ( !(await tryRenameFile(filePath, options.force)) ) { // means renaming was interrupted return; -- GitLab