sasalatart/on-this-day

View on GitHub

Showing 20 of 20 total issues

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

      it('must be less than the maximum number of days for the month', () => {
        const opts = { message: 'errors.invalidDayForMonth' };
        return Promise.all([
          expect(new YearDate({ month: 2, day: 30 })).toFailValidation(
            'day',
Severity: Major
Found in packages/server/src/models/year-dates.test.ts and 1 other location - About 3 hrs to fix
packages/server/src/models/episodes.test.ts on lines 52..64

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

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('must be less than the maximum number of days for the month', () => {
        const opts = { message: 'errors.invalidDayForMonth' };
        return Promise.all([
          expect(new Episode({ month: 2, day: 30 })).toFailValidation(
            'day',
Severity: Major
Found in packages/server/src/models/episodes.test.ts and 1 other location - About 3 hrs to fix
packages/server/src/models/year-dates.test.ts on lines 23..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 100.

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

    context('when day is over 31', () => {
      beforeEach(() => {
        selectDate('32', '7');
      });

Severity: Major
Found in packages/client/cypress/integration/date-select-spec.ts and 2 other locations - About 2 hrs to fix
packages/client/cypress/integration/date-select-spec.ts on lines 50..62
packages/client/cypress/integration/date-select-spec.ts on lines 64..76

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

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

    context('when day is below 1', () => {
      beforeEach(() => {
        selectDate('-1', '7');
      });

Severity: Major
Found in packages/client/cypress/integration/date-select-spec.ts and 2 other locations - About 2 hrs to fix
packages/client/cypress/integration/date-select-spec.ts on lines 36..48
packages/client/cypress/integration/date-select-spec.ts on lines 64..76

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

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

    context('when month and day are valid, but the day of month is not', () => {
      beforeEach(() => {
        selectDate('30', '2');
      });

Severity: Major
Found in packages/client/cypress/integration/date-select-spec.ts and 2 other locations - About 2 hrs to fix
packages/client/cypress/integration/date-select-spec.ts on lines 36..48
packages/client/cypress/integration/date-select-spec.ts on lines 50..62

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

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

    describe('month', () => {
      it('is required', () => expect('month').toBeRequiredFor(YearDate));

      it('must be a number between 1 and 12', () => {
        return expect('month').toBeBetween(1, 12, YearDate);
Severity: Major
Found in packages/server/src/models/year-dates.test.ts and 1 other location - About 1 hr to fix
packages/server/src/models/episodes.test.ts on lines 37..43

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

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

      describe('title', () => {
        it('is required', () => {
          return expect(
            new Episode({ keywords: [{ href: '/something' }] }),
          ).toFailValidation('keywords.0.title', { kind: 'required' });
Severity: Major
Found in packages/server/src/models/episodes.test.ts and 1 other location - About 1 hr to fix
packages/server/src/models/episodes.test.ts on lines 94..100

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

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

      describe('href', () => {
        it('is required', () => {
          return expect(
            new Episode({ keywords: [{ title: 'Something' }] }),
          ).toFailValidation('keywords.0.href', { kind: 'required' });
Severity: Major
Found in packages/server/src/models/episodes.test.ts and 1 other location - About 1 hr to fix
packages/server/src/models/episodes.test.ts on lines 86..92

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

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

    describe('month', () => {
      it('is required', () => expect('month').toBeRequiredFor(Episode));

      it('must be a number between 1 and 12', () => {
        return expect('month').toBeBetween(1, 12, Episode);
Severity: Major
Found in packages/server/src/models/episodes.test.ts and 1 other location - About 1 hr to fix
packages/server/src/models/year-dates.test.ts on lines 8..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 66.

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

export function DateSelect(): JSX.Element {
  const { t } = useTranslation();
  const { push } = useHistory();

  const handleSubmit = useCallback(
Severity: Minor
Found in packages/client/src/components/date-select/index.tsx - About 1 hr to fix

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

    const TabsContainer = styled(Paper)`
      ${({ theme }: StyledTheme): string => `
        margin: 0 5px;
        ${theme.breakpoints.up('sm')} {
          margin: 0 25px;
    Severity: Major
    Found in packages/client/src/components/year-date/index.tsx and 2 other locations - About 1 hr to fix
    packages/client/src/components/common/paper-box.tsx on lines 6..19
    packages/client/src/components/date-select/form.tsx on lines 63..71

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

    const Paper = styled(MUIPaper)`
      ${({ theme }: StyledTheme): string => `
        max-height: 100%;
        max-width: 100%;
        height: auto;
    Severity: Major
    Found in packages/client/src/components/common/paper-box.tsx and 2 other locations - About 1 hr to fix
    packages/client/src/components/date-select/form.tsx on lines 63..71
    packages/client/src/components/year-date/index.tsx on lines 101..108

    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

    const FooterText = styled(Typography)`
      ${({ theme }: StyledTheme): string => `
        color: ${theme.palette.primary.contrastText};
      `}
    `;
    Severity: Major
    Found in packages/client/src/components/app-layout/footer.tsx and 1 other location - About 1 hr to fix
    packages/client/src/components/app-layout/header.tsx on lines 31..38

    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

    const Title = styled(Typography)`
      ${({ theme }: StyledTheme): string => `
        flex-grow: 1;
        a {
          color: ${theme.palette.primary.contrastText};
    Severity: Major
    Found in packages/client/src/components/app-layout/header.tsx and 1 other location - About 1 hr to fix
    packages/client/src/components/app-layout/footer.tsx 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 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 3 locations. Consider refactoring.
    Open

    const Container = styled(Form)`
      ${({ theme }: StyledTheme): string => `
        display: block;
        ${theme.breakpoints.up('sm')} {
          display: flex;
    Severity: Major
    Found in packages/client/src/components/date-select/form.tsx and 2 other locations - About 1 hr to fix
    packages/client/src/components/common/paper-box.tsx on lines 6..19
    packages/client/src/components/year-date/index.tsx on lines 101..108

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

    function scrapEpisodes(
      $: CheerioStatic,
      episodeKind: EpisodeKindTagId,
    ): ScrapedEpisode[] {
      const itemToEpisode = (
    Severity: Minor
    Found in packages/scraper/src/scrape.ts - About 1 hr to fix

      Function scrapEpisodes has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

      function scrapEpisodes(
        $: CheerioStatic,
        episodeKind: EpisodeKindTagId,
      ): ScrapedEpisode[] {
        const itemToEpisode = (
      Severity: Minor
      Found in packages/scraper/src/scrape.ts - 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

      Function registerValidSW has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function registerValidSW(swUrl: string, config?: Config) {
        navigator.serviceWorker
          .register(swUrl)
          .then((registration) => {
            registration.onupdatefound = () => {
      Severity: Minor
      Found in packages/client/src/serviceWorker.ts - About 1 hr to fix

        Function createYearDate has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        async function createYearDate(
          formattedDate: string,
          scrapedYearDate: ScrapedYearDate,
          yearDateModel: YearDateModel,
          episodeModel: EpisodeModel,
        Severity: Minor
        Found in packages/server/src/db/seeds/year-dates.ts - About 1 hr to fix

          Function useValidateYearDate has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export function useValidateYearDate(): ValidationResult {
            const { search } = useLocation();
            const [validationStatus, setValidationStatus] = useState<ValidationStatus>(
              'validating',
            );
            Severity
            Category
            Status
            Source
            Language