grommet/grommet

View on GitHub

Showing 2,098 of 2,098 total issues

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

  test('select a suggestion with onSuggestionSelect', () => {
    const onSuggestionSelect = jest.fn();
    const { getByTestId, container } = render(
      <Grommet>
        <TextInput
Severity: Major
Found in src/js/components/TextInput/__tests__/TextInput-test.tsx and 1 other location - About 1 day to fix
src/js/components/TextInput/__tests__/TextInput-test.tsx on lines 268..295

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

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

  test('select a suggestion with onSelect', () => {
    const onSelect = jest.fn();
    const { getByTestId, container } = render(
      <Grommet>
        <TextInput
Severity: Major
Found in src/js/components/TextInput/__tests__/TextInput-test.tsx and 1 other location - About 1 day to fix
src/js/components/TextInput/__tests__/TextInput-test.tsx on lines 397..424

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

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

File Calendar-test.tsx has 671 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import React from 'react';

import 'jest-styled-components';
import 'jest-axe/extend-expect';
import 'regenerator-runtime/runtime';
Severity: Major
Found in src/js/components/Calendar/__tests__/Calendar-test.tsx - About 1 day to fix

    Function Box has a Cognitive Complexity of 75 (exceeds 5 allowed). Consider refactoring.
    Open

      (
        {
          a11yTitle,
          background: backgroundProp,
          border,
    Severity: Minor
    Found in src/js/components/Box/Box.js - About 1 day 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

    File WorldMap.js has 661 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import React, { forwardRef } from 'react';
    import { ThemeContext } from 'styled-components';
    
    import { Drop } from '../Drop';
    import { defaultProps } from '../../default-props';
    Severity: Major
    Found in src/js/components/WorldMap/WorldMap.js - About 1 day to fix

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

      export const marginProp = PropTypes.oneOfType([
        PropTypes.oneOf(['none', ...MARGIN_SIZES]),
        PropTypes.shape({
          bottom: PropTypes.oneOfType([
            PropTypes.oneOf(MARGIN_SIZES),
      Severity: Major
      Found in src/js/utils/general-prop-types.js and 1 other location - About 1 day to fix
      src/js/utils/general-prop-types.js on lines 115..134

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

      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

      export const padPropType = PropTypes.oneOfType([
        PropTypes.oneOf(['none', ...PAD_SIZES]),
        PropTypes.shape({
          bottom: PropTypes.oneOfType([PropTypes.oneOf(PAD_SIZES), PropTypes.string]),
          end: PropTypes.oneOfType([PropTypes.oneOf(PAD_SIZES), PropTypes.string]),
      Severity: Major
      Found in src/js/utils/general-prop-types.js and 1 other location - About 1 day to fix
      src/js/utils/general-prop-types.js on lines 80..111

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

      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

      File DataChart.js has 651 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import React, { forwardRef, useContext, useMemo, useState } from 'react';
      import { ThemeContext } from 'styled-components';
      import { Box } from '../Box';
      import { Chart, calcs, calcBounds } from '../Chart';
      import { Grid } from '../Grid';
      Severity: Major
      Found in src/js/components/DataChart/DataChart.js - About 1 day to fix

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

            margin: PropTypes.oneOfType([
              PropTypes.oneOf(['none', ...PAD_SIZES]),
              PropTypes.shape({
                bottom: PropTypes.oneOfType([
                  PropTypes.oneOf(PAD_SIZES),
        Severity: Major
        Found in src/js/components/Layer/propTypes.js and 1 other location - About 1 day to fix
        src/js/components/Text/propTypes.js on lines 14..51

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

        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

            margin: PropTypes.oneOfType([
              PropTypes.oneOf(['none', ...MARGIN_SIZES]),
              PropTypes.shape({
                bottom: PropTypes.oneOfType([
                  PropTypes.oneOf(MARGIN_SIZES),
        Severity: Major
        Found in src/js/components/Text/propTypes.js and 1 other location - About 1 day to fix
        src/js/components/Layer/propTypes.js on lines 19..56

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

        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

        File Chart.js has 648 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import React, { useContext, useEffect, useMemo, useState } from 'react';
        
        import { ThemeContext } from 'styled-components';
        import { useLayoutEffect } from '../../utils/use-isomorphic-layout-effect';
        import { defaultProps } from '../../default-props';
        Severity: Major
        Found in src/js/components/Chart/Chart.js - About 1 day to fix

          File List.js has 643 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import React, {
            Fragment,
            cloneElement,
            useContext,
            useMemo,
          Severity: Major
          Found in src/js/components/List/List.js - About 1 day to fix

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

              test(`should display specified item when show is less than step`, () => {
                const step = 30;
                const numItems = 200;
                const showIndex = 26;
                const { container, getByText } = render(
            src/js/components/InfiniteScroll/__tests__/InfiniteScroll-test.tsx on lines 316..345

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

            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

              test(`should display specified item when show is greater than step`, () => {
                const step = 8;
                const numItems = 200;
                const showIndex = 41;
                const { container, getByText } = render(
            src/js/components/InfiniteScroll/__tests__/InfiniteScroll-test.tsx on lines 347..377

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

            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

            const columns: ColumnConfig<RowType>[] = [
              {
                property: 'name',
                header: <Text>Name with extra</Text>,
                primary: true,
            Severity: Major
            Found in src/js/components/DataTable/stories/typescript/Paginated.tsx and 1 other location - About 1 day to fix
            src/js/components/DataTable/stories/typescript/Clickable.tsx on lines 17..56

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

            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

            const columns: ColumnConfig<RowType>[] = [
              {
                property: 'name',
                header: <Text>Name with extra</Text>,
                primary: true,
            Severity: Major
            Found in src/js/components/DataTable/stories/typescript/Clickable.tsx and 1 other location - About 1 day to fix
            src/js/components/DataTable/stories/typescript/Paginated.tsx on lines 16..55

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

            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

            File TextInput-test.tsx has 631 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            import React from 'react';
            import 'jest-styled-components';
            import 'regenerator-runtime/runtime';
            import { fireEvent, render, waitFor } from '@testing-library/react';
            import { getByText, screen } from '@testing-library/dom';
            Severity: Major
            Found in src/js/components/TextInput/__tests__/TextInput-test.tsx - About 1 day to fix

              File Form.js has 626 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              import React, {
                forwardRef,
                useCallback,
                useContext,
                useEffect,
              Severity: Major
              Found in src/js/components/Form/Form.js - About 1 day to fix

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

                  rectilinear: (fromPoint, toPoint, offset, anchor) => {
                    const midPoint = computeMidPoint(fromPoint, toPoint);
                    let cmds = `M ${fromPoint[0] + offset},${fromPoint[1] + offset} `;
                    if (anchor === 'horizontal') {
                      cmds +=
                Severity: Major
                Found in src/js/components/Diagram/Diagram.js and 1 other location - About 1 day to fix
                src/js/components/Diagram/Diagram.js on lines 27..41

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

                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

                  curved: (fromPoint, toPoint, offset, anchor) => {
                    const midPoint = computeMidPoint(fromPoint, toPoint);
                    let cmds = `M ${fromPoint[0] + offset},${fromPoint[1] + offset} `;
                    if (anchor === 'horizontal') {
                      cmds +=
                Severity: Major
                Found in src/js/components/Diagram/Diagram.js and 1 other location - About 1 day to fix
                src/js/components/Diagram/Diagram.js on lines 45..59

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

                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

                Severity
                Category
                Status
                Source
                Language