magarcia/react-pokedex

View on GitHub

Showing 32 of 32 total issues

Function deepEqual has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

const deepEqual = (a, b) => {
  if (
    typeof a === 'object' &&
    a != null &&
    (typeof b === 'object' && b != null)
Severity: Minor
Found in src/utils.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

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

  <figure style={{display: 'inline-block', height: size, width: size}}>
    <svg style={{height: size, width: size}}>
      <use xlinkHref={`${icons}#pokedex`} />
    </svg>
  </figure>
Severity: Major
Found in src/components/Logo.js and 1 other location - About 2 hrs to fix
src/pages/About.js on lines 8..12

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 90.

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

      <figure style={{display: 'inline-block', height: size, width: size}}>
        <svg style={{height: size, width: size}}>
          <use xlinkHref={`${icons}#backpack`} />
        </svg>
      </figure>
Severity: Major
Found in src/pages/About.js and 1 other location - About 2 hrs to fix
src/components/Logo.js on lines 5..9

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 90.

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 fixNames has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

const fixNames = name => {
  if (name === 'sceptile') {
    return 'sceptille';
  }
  if (name === 'jirachi') {
Severity: Minor
Found in src/components/PokemonImage.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 fixNames has 52 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const fixNames = name => {
  if (name === 'sceptile') {
    return 'sceptille';
  }
  if (name === 'jirachi') {
Severity: Major
Found in src/components/PokemonImage.js - About 2 hrs to fix

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

    const selectColor = name => {
      switch (name) {
        case 'normal':
          return '#A8A77A';
        case 'fire':
    Severity: Minor
    Found in src/components/PokemonType.js - About 1 hr to fix

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

            <Link
              to={`/pokemon/${padNumber(props.id + 1)}`}
              className="button is-pulled-right"
            >
              #{padNumber(props.id + 1)}
      Severity: Major
      Found in src/pages/Pokemon.js and 1 other location - About 1 hr to fix
      src/pages/Pokemon.js on lines 12..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 61.

      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

            <Link
              to={`/pokemon/${padNumber(props.id - 1)}`}
              className="button is-pulled-left"
            >
              #{padNumber(props.id - 1)}
      Severity: Major
      Found in src/pages/Pokemon.js and 1 other location - About 1 hr to fix
      src/pages/Pokemon.js on lines 18..23

      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 61.

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

      const getLimitsFromGeneration = generation => {
        let limit;
        let offset;
        switch (generation) {
          case 'all':
      Severity: Minor
      Found in src/pages/Pokedex.js - About 1 hr to fix

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

          it('renders correctly', () => {
            const tree = renderer.create(<PokemonType {...defaultProps} />).toJSON();
            expect(tree).toMatchSnapshot();
          });
        Severity: Major
        Found in src/components/PokemonType.test.js and 1 other location - About 1 hr to fix
        src/components/PokemonImage.test.js on lines 11..14

        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

          it('renders correctly', () => {
            const tree = renderer.create(<PokemonImage {...defaultProps} />).toJSON();
            expect(tree).toMatchSnapshot();
          });
        Severity: Major
        Found in src/components/PokemonImage.test.js and 1 other location - About 1 hr to fix
        src/components/PokemonType.test.js on lines 20..23

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

        const deepEqual = (a, b) => {
          if (
            typeof a === 'object' &&
            a != null &&
            (typeof b === 'object' && b != null)
        Severity: Minor
        Found in src/utils.js - About 1 hr to fix

          Function withFetching has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

          const withFetching = getUrl => InnerComponent =>
            class WithFetching extends Component {
              constructor(props) {
                super(props);
                this.props = props;
          Severity: Minor
          Found in src/components/withFetching.js - About 55 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

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

            it('should have pokemon number with pad', () => {
              const wrapper = shallowComponent();
              expect(wrapper.find('.pokemoncard-content .subtitle').text()).toEqual(
                '#001',
              );
          Severity: Minor
          Found in src/components/PokedexEntry.test.js and 1 other location - About 55 mins to fix
          src/pages/About.test.js on lines 14..19

          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 53.

          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

            it('should render copyright on the license', () => {
              const wrapper = shallowComponent();
              expect(wrapper.find('.license').text()).toContain(
                'Copyright (c) 2018 Martin Garcia Monterde',
              );
          Severity: Minor
          Found in src/pages/About.test.js and 1 other location - About 55 mins to fix
          src/components/PokedexEntry.test.js on lines 31..36

          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 53.

          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

              for (const key in b) {
                if (!(key in a) || !deepEqual(b[key], a[key])) {
                  return false;
                }
              }
          Severity: Minor
          Found in src/utils.js and 1 other location - About 40 mins to fix
          src/utils.js on lines 30..34

          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 48.

          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

              for (const key in a) {
                if (!(key in b) || !deepEqual(a[key], b[key])) {
                  return false;
                }
              }
          Severity: Minor
          Found in src/utils.js and 1 other location - About 40 mins to fix
          src/utils.js on lines 35..39

          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 48.

          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

          Avoid too many return statements within this function.
          Open

            return a === b;
          Severity: Major
          Found in src/utils.js - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                return 'hooh';
            Severity: Major
            Found in src/components/PokemonImage.js - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                  return 'deoxys';
              Severity: Major
              Found in src/components/PokemonImage.js - About 30 mins to fix
                Severity
                Category
                Status
                Source
                Language