grommet/react-desc

View on GitHub

Showing 11 of 17 total issues

Function convertPropType has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

const convertPropType = (propType) => {
  let result;
  if (propType && propType.type) {
    if (!PropTypes[propType.type]) {
      throw new Error(`react-desc: unknown type ${propType.type}`);
Severity: Minor
Found in src/describe.js - About 2 hrs 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 propTypeFormat has 53 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const propTypeFormat = (propType, joinWith) => {
  let result;
  if (Array.isArray(propType)) {
    result = arrayFormat(propType).join(joinWith);
  } else if (typeof propType !== 'function' && propType.type) {
Severity: Major
Found in src/descToTypescript.js - About 2 hrs to fix

    Function propTypeFormat has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

    const propTypeFormat = (propType, prefix = '') => {
      let result;
      if (propType.type) {
        switch (propType.type) {
          case 'arrayOf':
    Severity: Minor
    Found in src/descToJSON.js - About 2 hrs 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 describe has 46 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export default function describe(ComponentInstance) {
      if (!ComponentInstance) {
        throw new Error('react-desc: component is required');
      }
    
    
    Severity: Minor
    Found in src/describe.js - About 1 hr to fix

      Function propTypeFormat has 45 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      const propTypeFormat = (propType, prefix = '') => {
        let result;
        if (propType.type) {
          switch (propType.type) {
            case 'arrayOf':
      Severity: Minor
      Found in src/descToJSON.js - About 1 hr to fix

        Function propTypeFormat has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

        const propTypeFormat = (propType, joinWith) => {
          let result;
          if (Array.isArray(propType)) {
            result = arrayFormat(propType).join(joinWith);
          } else if (typeof propType !== 'function' && propType.type) {
        Severity: Minor
        Found in src/descToTypescript.js - About 1 hr 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 shapeFormat has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

        const shapeFormat = (shape) => {
          const props = Object.keys(shape).map((key) => {
            const value = shape[key];
            let valueFormat;
            if (value.type &&
        Severity: Minor
        Found in src/descToTypescript.js - About 1 hr 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 descToTypescript has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

        export default function descToTypescript(component, reactDesc = {}) {
          if (!component) {
            throw new Error('react-desc: component is required');
          }
        
        
        Severity: Minor
        Found in src/descToTypescript.js - 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 getProperties has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

        function getProperties({ properties = [] }) {
          const props = properties.map(
            ({ defaultValue, deprecated, description, format, name, required }) => (`
        ${deprecated ? `**~~${name}~~**` : `**${name}**`}${deprecated ? ` (${deprecated})` : ''}
        
        
        Severity: Minor
        Found in src/descToMarkdown.js - 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 shapeFormat has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

        const shapeFormat = (shape, prefix) => {
          const props = Object.keys(shape).map((key) => {
            const value = shape[key];
            let valueFormat;
            if (value.type &&
        Severity: Minor
        Found in src/descToJSON.js - About 35 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 descToJSON has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

        export default function descToJSON(component, reactDesc = {}) {
          if (!component) {
            throw new Error('react-desc: component is required');
          }
        
        
        Severity: Minor
        Found in src/descToJSON.js - About 35 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