Function createInstanceOfCommand
has 26 lines of code (exceeds 25 allowed). Consider refactoring.
private createInstanceOfCommand(command: any): CommandInstance {
const commandInstance = new command();
const commandMetadata: CommandMetadata = getClassMetadata(command);
const paramTypes = getParamTypes(commandInstance, 'execute');
Function createInstanceOfCommand
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
private createInstanceOfCommand(command: any): CommandInstance {
const commandInstance = new command();
const commandMetadata: CommandMetadata = getClassMetadata(command);
const paramTypes = getParamTypes(commandInstance, 'execute');
Function findCommand
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
public findCommand(args: ParsedArgs)
: { command: CommandInstance, depth: number } {
let command: CommandInstance | null = null;
let commands = this.commands;
let subcommands = this.subcommands;
Function tryRunCommand
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
private static tryRunCommand(input: ParsedArgs, commandInstances: MappedCommands) {
let hasRun = true;
try {
* FIXME: this behavior is wrong, atleast until we have custom compiler
Function getParameters
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
private static getParameters(command: CommandInstance, args: ParsedArgs, depth: number) {
const parameters = [];
if (command.params) {
for (const param of command.params) {
const argument = args.arguments[param.index + depth];
Function generateOptionDocs
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
export function generateOptionDocs(options: { [prop: string]: ModifiedOptionMetadata }): string {
let str = '';
for (const option in options) {
const opt = options[option];
str += chalk.blue('--' + opt.name) + s
Function injectOptions
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
private static injectOptions(command: CommandInstance, args: ParsedArgs): void {
for (const opt in command.options) {
const option = command.options[opt];
const value = this.getOption(option, args);
if (value) {