Oluwasegun-AA/md-generator

View on GitHub
src/core/actions/createActions/index.ts

Summary

Maintainability
A
2 hrs
Test Coverage

Function createMdFiles has 40 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const createMdFiles = async (USE_DEFAULT: boolean, filesToBeCreated: string[] | ICurrentFile[], isEmpty: boolean): Promise<void> => {
  const { validFileNames, inValidFileNames }: ISortedFiles = await handleOverride(filesToBeCreated);
  if (validFileNames.length === 0 && inValidFileNames.length === 0) {
    useHelpAlert({
      errorText: 'Error:  No option selected, Press <space> to select, <a> to toggle all, <i> to invert selection',
Severity: Minor
Found in src/core/actions/createActions/index.ts - About 1 hr to fix

    Function processCreation has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Invalid

    const processCreation = async (allItems: IAllFiles | ICurrentFile[], mode: any, IS_EMPTY_FILE?: boolean): Promise<any> => {
      const USE_DEFAULT_VALUES: boolean = true;
      let CREATE_EMPTY_FILE: boolean = false;
      let filesToBeCreated: ICurrentFile[];
      return inquirer.prompt(mode(getArrayOfValues(allItems as IAllFiles)))
    Severity: Minor
    Found in src/core/actions/createActions/index.ts - About 1 hr to fix

      Function createMdFiles has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      export const createMdFiles = async (USE_DEFAULT: boolean, filesToBeCreated: string[] | ICurrentFile[], isEmpty: boolean): Promise<void> => {
        const { validFileNames, inValidFileNames }: ISortedFiles = await handleOverride(filesToBeCreated);
        if (validFileNames.length === 0 && inValidFileNames.length === 0) {
          useHelpAlert({
            errorText: 'Error:  No option selected, Press <space> to select, <a> to toggle all, <i> to invert selection',
      Severity: Minor
      Found in src/core/actions/createActions/index.ts - About 25 mins to fix

      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

      There are no issues that match your filters.

      Category
      Status