feathersjs/feathers-hooks-common

View on GitHub

Showing 32 of 47 total issues

Function convertFieldDefinitionType has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

function convertFieldDefinitionType(fieldDefinitionType: any, errDesc: any, converted?: any): any {
  converted = converted || {
    nonNullTypeList: false,
    listType: false,
    nonNullTypeField: false,
Severity: Minor
Found in src/hooks/fgraphql.ts - About 45 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

Function replaceItems has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

export function replaceItems<H extends HookContext = HookContext>(context: H, items: any): void {
  // @ts-ignore
  if (context.params && context.params._actOn === 'dispatch') {
    context.dispatch = items;
    return;
Severity: Minor
Found in src/utils/replace-items.ts - About 45 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

Function processRecord has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

function processRecord(store: any, query: any, depth: any, rec: any, type: any, j: any): any {
Severity: Minor
Found in src/hooks/fgraphql.ts - About 45 mins to fix

    Function populateItem has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

      options: any,
      context: HookContext,
      item: any,
      includeSchema: any,
      depth: number,
    Severity: Minor
    Found in src/hooks/populate.ts - About 35 mins to fix

      Function populateItemArray has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

        options: any,
        context: HookContext,
        items: any,
        includeSchema: any,
        depth: number,
      Severity: Minor
      Found in src/hooks/populate.ts - About 35 mins to fix

        Function populateAddChild has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

          options: any,
          context: HookContext,
          parentItem: any,
          childSchema: any,
          depth: any,
        Severity: Minor
        Found in src/hooks/populate.ts - About 35 mins to fix

          Function processRecords has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          function processRecords(store: any, query: any, recs: any, type: any, depth = 0): any {
          Severity: Minor
          Found in src/hooks/fgraphql.ts - About 35 mins to fix

            Avoid too many return statements within this function.
            Open

                      return context;
            Severity: Major
            Found in src/hooks/cache.ts - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                  return context;
              Severity: Major
              Found in src/hooks/cache.ts - About 30 mins to fix

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

                function populateAddChild(
                  options: any,
                  context: HookContext,
                  parentItem: any,
                  childSchema: any,
                Severity: Minor
                Found in src/hooks/populate.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

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

                export function getItems<H extends HookContext = HookContext>(context: H): any {
                  // @ts-ignore
                  if (context.params && context.params._actOn === 'dispatch') return context.dispatch;
                
                  const items = context.type === 'before' ? context.data : context.result;
                Severity: Minor
                Found in src/utils/get-items.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

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

                function addNewErrorDflt(errorMessages: any, ajvError: any, itemsLen: any, index: any) {
                  const leader = itemsLen === 1 ? '' : `in row ${index + 1} of ${itemsLen}, `;
                  let message;
                
                  if (ajvError.dataPath) {
                Severity: Minor
                Found in src/hooks/validate-schema.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

                Severity
                Category
                Status
                Source
                Language