SylarLong/iztro-hook

View on GitHub

Showing 6 of 6 total issues

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

  it('useIztro() with `exact` year divide', async () => {
    const { result } = renderHook(() =>
      useIztro({
        birthday: '1999-12-29',
        birthdayType: 'lunar',
Severity: Major
Found in __tests__/index.test.ts and 1 other location - About 1 day to fix
__tests__/index.test.ts on lines 303..330

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

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('useIztro() with `normal` year divide', async () => {
    const { result } = renderHook(() =>
      useIztro({
        birthday: '1999-12-29',
        birthdayType: 'lunar',
Severity: Major
Found in __tests__/index.test.ts and 1 other location - About 1 day to fix
__tests__/index.test.ts on lines 332..359

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

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.test.ts has 330 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { renderHook, act } from '@testing-library/react-hooks';
import { useIztro } from '../src/index';

describe('Test useIztro hook', () => {
  it('useIztro() return undefined', () => {
Severity: Minor
Found in __tests__/index.test.ts - About 3 hrs to fix

    Function useIztro has 42 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export function useIztro(input: IztroInput) {
      const _currentDate = new Date();
      const _currentHour = _currentDate.getHours();
      const [astrolabe, _setAstrolabe] = useState<FunctionalAstrolabe>();
      const [_horoscopeDate, _setHoroscopeDate] = useState<string | Date>(_currentDate);
    Severity: Minor
    Found in src/index.ts - About 1 hr to fix

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

          const { result } = renderHook(() =>
            useIztro({
              birthday: '2000-8-16',
              birthdayType: 'solar',
              birthTime: 2,
      Severity: Minor
      Found in __tests__/index.test.ts and 1 other location - About 45 mins to fix
      __tests__/index.test.ts on lines 6..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 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 2 locations. Consider refactoring.
      Open

          const { result } = renderHook(() =>
            useIztro({
              birthday: '2000-18-16',
              birthdayType: 'solar',
              birthTime: 2,
      Severity: Minor
      Found in __tests__/index.test.ts and 1 other location - About 45 mins to fix
      __tests__/index.test.ts on lines 21..29

      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