gymnastjs/gymnast

View on GitHub

Showing 22 of 22 total issues

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

  it('should unregister the current mediaQuery listener when "show" prop changes', () => {
    jest.clearAllMocks()

    const { rerender } = render(
      <Fruit fruit={{ YetAnotherKey: '🍏' }} show="large" />
Severity: Major
Found in src/useResolution/index.spec.tsx and 1 other location - About 4 hrs to fix
src/useResolution/index.spec.tsx on lines 109..121

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

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 register the new mediaQuery listener when "show" prop changes', () => {
    jest.clearAllMocks()

    const { rerender } = render(
      <Fruit fruit={{ YetAnotherKey: '🍇' }} show="large" />
Severity: Major
Found in src/useResolution/index.spec.tsx and 1 other location - About 4 hrs to fix
src/useResolution/index.spec.tsx on lines 95..107

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

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 index.spec.tsx has 327 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { size } from 'lodash'
import defaults from '../defaults'
import {
  accumulateOver,
  combineSpacing,
Severity: Minor
Found in src/utils/index.spec.tsx - About 3 hrs to fix

    Function useGrid has 66 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export default function useGrid<A extends {}>(
      props: GridProps & A
    ): [
      boolean,
      A & { className: string | undefined; style: React.CSSProperties }
    Severity: Major
    Found in src/useGrid/index.tsx - About 2 hrs to fix

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

              <GymnastProvider base={4}>
                <GymnastProvider base={2}>
                  <GymnastProvider columns={9}>
                    <TesterComponent>{spy}</TesterComponent>
                  </GymnastProvider>
      Severity: Major
      Found in src/gymnastProvider/index.spec.tsx and 1 other location - About 1 hr to fix
      src/gymnastProvider/index.spec.tsx on lines 78..84

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

      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

            <GymnastProvider columns={2}>
              <GymnastProvider base={4}>
                <GymnastProvider gutter={10}>
                  <TesterComponent>{spy}</TesterComponent>
                </GymnastProvider>
      Severity: Major
      Found in src/gymnastProvider/index.spec.tsx and 1 other location - About 1 hr to fix
      src/gymnastProvider/index.spec.tsx on lines 99..105

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

      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 not log "warn" when log level is "error"', () => {
          log.setLevel('error')
          spyOn(console, 'warn')
      
          log.warn('I do nothing either!')
      Severity: Major
      Found in src/log/index.spec.tsx and 1 other location - About 1 hr to fix
      src/log/index.spec.tsx on lines 25..32

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

      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 not log "info" when log level is "warn"', () => {
          log.setLevel('warn')
          spyOn(console, 'log')
      
          log.info('I do nothing!')
      Severity: Major
      Found in src/log/index.spec.tsx and 1 other location - About 1 hr to fix
      src/log/index.spec.tsx on lines 34..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 65.

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

      export default function useResolution<A extends GridProps>(
        resolutionKeys: Array<string>,
        props: A,
        allowMatchMedia: boolean = supportsMatchMedia
      ): [boolean, A & OneResolutionGrid] {
      Severity: Minor
      Found in src/useResolution/index.tsx - About 1 hr to fix

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

          it('should include invalid keys', () => {
            const out = getMediaQueries('test2', {
              test2: {
                invalidValue: 'meow',
              },
        Severity: Major
        Found in src/useResolution/useResolution.logic.spec.tsx and 3 other locations - About 1 hr to fix
        src/useResolution/useResolution.logic.spec.tsx on lines 32..40
        src/useResolution/useResolution.logic.spec.tsx on lines 57..65
        src/useResolution/useResolution.logic.spec.tsx on lines 67..75

        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 4 locations. Consider refactoring.
        Open

          it('should return a max value only when no min value is provided', () => {
            const out = getMediaQueries('test', {
              test: {
                maxWidth: '2px',
              },
        Severity: Major
        Found in src/useResolution/useResolution.logic.spec.tsx and 3 other locations - About 1 hr to fix
        src/useResolution/useResolution.logic.spec.tsx on lines 57..65
        src/useResolution/useResolution.logic.spec.tsx on lines 67..75
        src/useResolution/useResolution.logic.spec.tsx on lines 77..85

        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 4 locations. Consider refactoring.
        Open

          it('should kebab case keys', () => {
            const out = getMediaQueries('test2', {
              test2: {
                MaxAspectRatio: '1/2',
              },
        Severity: Major
        Found in src/useResolution/useResolution.logic.spec.tsx and 3 other locations - About 1 hr to fix
        src/useResolution/useResolution.logic.spec.tsx on lines 32..40
        src/useResolution/useResolution.logic.spec.tsx on lines 57..65
        src/useResolution/useResolution.logic.spec.tsx on lines 77..85

        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 4 locations. Consider refactoring.
        Open

          it('should return a min value only when no max value is provided', () => {
            const out = getMediaQueries('test', {
              test: {
                minWidth: '1px',
              },
        Severity: Major
        Found in src/useResolution/useResolution.logic.spec.tsx and 3 other locations - About 1 hr to fix
        src/useResolution/useResolution.logic.spec.tsx on lines 32..40
        src/useResolution/useResolution.logic.spec.tsx on lines 67..75
        src/useResolution/useResolution.logic.spec.tsx on lines 77..85

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

        function getSpacing(
          values: Array<number> | void = [],
          type: 'margin' | 'padding'
        ): { [CSSProp: string]: number } {
          if (!values || !values.length) {
        Severity: Minor
        Found in src/utils/index.tsx - About 1 hr to fix

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

            it('should set margin as border width', () => {
              const css = getCSS('marginBottom', 2, 4)
          
              expect(css).toEqual({
                borderBottomWidth: 2 * 4,
          Severity: Minor
          Found in src/utils/index.spec.tsx and 1 other location - About 50 mins to fix
          src/utils/index.spec.tsx on lines 192..198

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

          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 set padding as is', () => {
              const css = getCSS('paddingLeft', 3, 5)
          
              expect(css).toEqual({
                paddingLeft: 3 * 5,
          Severity: Minor
          Found in src/utils/index.spec.tsx and 1 other location - About 50 mins to fix
          src/utils/index.spec.tsx on lines 200..206

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

          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 4 locations. Consider refactoring.
          Open

              expect(child2.mock.calls[0][0]).toEqual(
                expect.objectContaining({
                  columns: 2,
                  base: 1,
                })
          Severity: Major
          Found in src/gymnastProvider/index.spec.tsx and 3 other locations - About 45 mins to fix
          src/gymnastProvider/index.spec.tsx on lines 109..114
          src/gymnastProvider/index.spec.tsx on lines 134..139
          src/gymnastProvider/index.spec.tsx on lines 148..153

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

          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 4 locations. Consider refactoring.
          Open

              expect(spy.mock.calls[0][0]).toEqual(
                expect.objectContaining({
                  columns: 9,
                  base: 2,
                })
          Severity: Major
          Found in src/gymnastProvider/index.spec.tsx and 3 other locations - About 45 mins to fix
          src/gymnastProvider/index.spec.tsx on lines 134..139
          src/gymnastProvider/index.spec.tsx on lines 141..146
          src/gymnastProvider/index.spec.tsx on lines 148..153

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

          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 4 locations. Consider refactoring.
          Open

              expect(child3.mock.calls[0][0]).toEqual(
                expect.objectContaining({
                  columns: 2,
                  base: 4,
                })
          Severity: Major
          Found in src/gymnastProvider/index.spec.tsx and 3 other locations - About 45 mins to fix
          src/gymnastProvider/index.spec.tsx on lines 109..114
          src/gymnastProvider/index.spec.tsx on lines 134..139
          src/gymnastProvider/index.spec.tsx on lines 141..146

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

          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 4 locations. Consider refactoring.
          Open

              expect(child1.mock.calls[0][0]).toEqual(
                expect.objectContaining({
                  columns: 3,
                  base: 5,
                })
          Severity: Major
          Found in src/gymnastProvider/index.spec.tsx and 3 other locations - About 45 mins to fix
          src/gymnastProvider/index.spec.tsx on lines 109..114
          src/gymnastProvider/index.spec.tsx on lines 141..146
          src/gymnastProvider/index.spec.tsx on lines 148..153

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

          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