grommet/react-desc

View on GitHub

Showing 17 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

Identical blocks of code found in 2 locations. Consider refactoring.
Open

  Object.defineProperty(
    propTypeObj,
    'isRequired', {
      get: function getRequired() {
        if (!this.reactDesc) {
Severity: Major
Found in src/PropTypes.js and 1 other location - About 2 hrs to fix
src/PropTypes.js on lines 45..58

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 79.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Identical blocks of code found in 2 locations. Consider refactoring.
Open

  Object.defineProperty(
    propTypeObj,
    'isRequired', {
      get: function getRequired() {
        if (!this.reactDesc) {
Severity: Major
Found in src/PropTypes.js and 1 other location - About 2 hrs to fix
src/PropTypes.js on lines 22..35

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 79.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

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

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

            if (value.type &&
              ((value.type === 'arrayOf' || value.type === 'oneOfType' ||
                value.type === 'oneOf') && Array.isArray(value.args))) {
              valueFormat = `\n${propTypeFormat(value, `${prefix}    `)}`;
            } else if (value.type === 'shape') {
        Severity: Major
        Found in src/descToJSON.js and 1 other location - About 1 hr to fix
        src/descToTypescript.js on lines 9..17

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 58.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

            if (value.type &&
              ((value.type === 'arrayOf' || value.type === 'oneOfType' ||
                value.type === 'oneOf') && Array.isArray(value.args))) {
              valueFormat = `${propTypeFormat(value)}`;
            } else if (value.type === 'shape') {
        Severity: Major
        Found in src/descToTypescript.js and 1 other location - About 1 hr to fix
        src/descToJSON.js on lines 9..17

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 58.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        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

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

        function definePropType(type) {
          Object.defineProperty(
            PropTypes,
            type, {
              get: function getPropType() {
        Severity: Minor
        Found in src/PropTypes.js and 1 other location - About 50 mins to fix
        src/PropTypes.js on lines 85..96

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 52.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

        function definePropTypeWithArgs(type) {
          Object.defineProperty(
            PropTypes,
            type, {
              get: function getPropType() {
        Severity: Minor
        Found in src/PropTypes.js and 1 other location - About 50 mins to fix
        src/PropTypes.js on lines 72..83

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 52.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        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