cloudfoundry/stratos

View on GitHub
src/frontend/packages/kubernetes/src/kubernetes/workloads/chart-values-editor/json-schema-generator.ts

Summary

Maintainability
D
1 day
Test Coverage

Function processArray has a Cognitive Complexity of 51 (exceeds 8 allowed). Consider refactoring.
Open

function processArray(array, output?, nested?: boolean) {
  let format;
  let oneOf;
  let type;

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 processArray has 72 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function processArray(array, output?, nested?: boolean) {
  let format;
  let oneOf;
  let type;

    Function processObject has a Cognitive Complexity of 23 (exceeds 8 allowed). Consider refactoring.
    Open

    function processObject(object: any, output?: any, nested?: boolean) {
      if (nested && output) {
        output = { properties: output };
      } else {
        output = output || {};

    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 processObject has 39 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function processObject(object: any, output?: any, nested?: boolean) {
      if (nested && output) {
        output = { properties: output };
      } else {
        output = output || {};

      Function generateJsonSchemaFromObject has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export function generateJsonSchemaFromObject(title, object) {
        let processOutput;
        const output: any = {
          $schema: DRAFT
        };

        Avoid deeply nested control flow statements.
        Wontfix

                if (itemFormat) {
                  arrayItem.format = itemFormat;
                }

          Avoid too many return statements within this function.
          Wontfix

            return type;

            There are no issues that match your filters.

            Category
            Status