ahbeng/NUSMods

View on GitHub
website/src/views/today/TodayContainer/TodayContainer.test.tsx

Summary

Maintainability
F
3 days
Test Coverage

File TodayContainer.test.tsx has 323 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { flatten, size } from 'lodash';
import { shallow } from 'enzyme';

import * as weather from 'apis/weather';
import { waitFor } from 'test-utils/async';
Severity: Minor
Found in website/src/views/today/TodayContainer/TodayContainer.test.tsx - About 3 hrs to fix

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

    describe(mapStateToProps, () => {
      test('should use correct semester (test 4)', () => {
        // On week -1 of special term I, it should be sem2
        const ownProps: any = {
          currentTime: new Date('2025-05-11T00:00:00.000Z'),
    website/src/views/today/TodayContainer/TodayContainer.test.tsx on lines 284..312
    website/src/views/today/TodayContainer/TodayContainer.test.tsx on lines 314..342
    website/src/views/today/TodayContainer/TodayContainer.test.tsx on lines 374..402

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

    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

    describe(mapStateToProps, () => {
      test('should use correct semester (test 5)', () => {
        // On week -1 of special term II, it should be special term I
        const ownProps: any = {
          currentTime: new Date('2025-06-22T00:00:00.000Z'),
    website/src/views/today/TodayContainer/TodayContainer.test.tsx on lines 284..312
    website/src/views/today/TodayContainer/TodayContainer.test.tsx on lines 314..342
    website/src/views/today/TodayContainer/TodayContainer.test.tsx on lines 344..372

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

    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

    describe(mapStateToProps, () => {
      test('should use correct semester (test 2)', () => {
        // On week -1 of orientation week, it should be special term II
        const ownProps: any = {
          currentTime: new Date('2024-08-04T00:00:00.000Z'),
    website/src/views/today/TodayContainer/TodayContainer.test.tsx on lines 314..342
    website/src/views/today/TodayContainer/TodayContainer.test.tsx on lines 344..372
    website/src/views/today/TodayContainer/TodayContainer.test.tsx on lines 374..402

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

    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

    describe(mapStateToProps, () => {
      test('should use correct semester (test 3)', () => {
        // On orientation week, it should be sem1
        const ownProps: any = {
          currentTime: new Date('2024-08-05T00:00:00.000Z'),
    website/src/views/today/TodayContainer/TodayContainer.test.tsx on lines 284..312
    website/src/views/today/TodayContainer/TodayContainer.test.tsx on lines 344..372
    website/src/views/today/TodayContainer/TodayContainer.test.tsx on lines 374..402

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

    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 CS3216_LESSONS = {
      Lecture: [
        {
          moduleCode: 'CS3216',
          title: 'Software Product Engineering for Digital Markets',
    website/src/views/today/TodayContainer/TodayContainer.test.tsx on lines 41..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 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

    const CS1010S_LESSONS = {
      Recitation: [
        {
          moduleCode: 'CS1010S',
          title: 'Programming Methodology',
    website/src/views/today/TodayContainer/TodayContainer.test.tsx on lines 25..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 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

    There are no issues that match your filters.

    Category
    Status