ahbeng/NUSMods

View on GitHub

Showing 538 of 538 total issues

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

test('findExamClashes should return non-empty object if exams clash', () => {
  const sem: Semester = 1;
  const examClashes = findExamClashes([CS1010S, CS4243 as any, CS3216], sem);
  const examDate = _.get(getModuleSemesterData(CS1010S, sem), 'examDate');
  if (!examDate) throw new Error('Cannot find ExamDate');
Severity: Major
Found in website/src/utils/timetables.test.ts and 1 other location - About 3 hrs to fix
website/src/utils/timetables.test.ts on lines 382..388

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

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

    expect(
      reducer(initial, addPlannerModule('2018/2019', 2, { type: 'module', moduleCode: 'CS2030' }))
        .modules,
    ).toEqual({
      0: { id: '0', moduleCode: 'CS1010S', year: '2018/2019', semester: 1, index: 0 },
Severity: Major
Found in website/src/reducers/planner.test.ts and 1 other location - About 3 hrs to fix
website/src/reducers/planner.test.ts on lines 110..116

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

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

    expect(
      reducer(initial, addPlannerModule('2018/2019', 1, { type: 'module', moduleCode: 'CS2030' }))
        .modules,
    ).toEqual({
      0: { id: '0', moduleCode: 'CS1010S', year: '2018/2019', semester: 1, index: 0 },
Severity: Major
Found in website/src/reducers/planner.test.ts and 1 other location - About 3 hrs to fix
website/src/reducers/planner.test.ts on lines 101..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 103.

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

    public primitive(): PrimitiveContext {
        let _localctx: PrimitiveContext = new PrimitiveContext(this._ctx, this.state);
        this.enterRule(_localctx, 12, NusModsParser.RULE_primitive);
        try {
            this.state = 104;
Severity: Major
Found in scrapers/nus-v2/src/services/requisite-tree/antlr4/NusModsParser.ts - About 3 hrs to fix

    Function FooterComponent has 82 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export const FooterComponent: React.FC<Props> = (props) => {
      // Try catch because of Chrome crashing on calling toLocaleString with no parameter
      // See https://sentry.io/nusmods/v3/issues/434084130/
      let lastUpdatedText = 'Loading data...';
      if (props.lastUpdatedDate) {
    Severity: Major
    Found in website/src/views/layout/Footer.tsx - About 3 hrs to fix

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

          it('should not open modal when button is disabled', () => {
            const wrapper = shallow(<ModulesSelect {...commonProps} disabled />);
            wrapper.find('button').simulate('click');
            const modal = wrapper.find(Modal).shallow();
            expect(modal.prop('isOpen')).toBe(false);
      Severity: Major
      Found in website/src/views/timetable/ModulesSelect.test.tsx and 1 other location - About 3 hrs to fix
      website/src/views/mpe/form/ModulesSelect.test.tsx on lines 78..83

      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('should not open modal when button is disabled', () => {
            const wrapper = shallow(<ModulesSelectComponent {...commonProps} disabled />);
            wrapper.find('button').simulate('click');
            const modal = wrapper.find(Modal).shallow();
            expect(modal.prop('isOpen')).toBe(false);
      Severity: Major
      Found in website/src/views/mpe/form/ModulesSelect.test.tsx and 1 other location - About 3 hrs to fix
      website/src/views/timetable/ModulesSelect.test.tsx on lines 95..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 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

      Function PlannerSettingsComponent has 81 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export const PlannerSettingsComponent: React.FC<Props> = (props) => {
        const matriculationLabels = getYearLabels(MIN_YEARS, MAX_YEARS).reverse();
        const graduationLabels = getYearLabels(0, GRADUATE_IN);
      
        return (
      Severity: Major
      Found in website/src/views/planner/PlannerSettings.tsx - About 3 hrs to fix

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

            if (showCPExTab) {
              expect(screen.getAllByRole('link').map((elem) => elem.textContent)).toMatchInlineSnapshot(`
                [
                  "Today",
                  "Timetable",
        Severity: Major
        Found in website/src/views/layout/Navtabs.test.tsx and 1 other location - About 3 hrs to fix
        website/src/views/layout/Navtabs.test.tsx on lines 70..97

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

        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

            if (showCPExTab) {
              expect(screen.getAllByRole('link').map((elem) => elem.textContent)).toMatchInlineSnapshot(`
                [
                  "Today",
                  "Timetable",
        Severity: Major
        Found in website/src/views/layout/Navtabs.test.tsx and 1 other location - About 3 hrs to fix
        website/src/views/layout/Navtabs.test.tsx on lines 40..65

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

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

        import { FC, FormEventHandler, memo, useCallback, useState } from 'react';
        import { castArray, groupBy } from 'lodash';
        import classnames from 'classnames';
        import produce from 'immer';
        import axios from 'axios';
        Severity: Minor
        Found in website/src/views/modules/ReportError.tsx - About 3 hrs to fix

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

              const planner: PlannerState = {
                ...defaultState,
                maxYear: '2017/2018',
                minYear: '2017/2018',
                modules: {
          Severity: Major
          Found in website/src/selectors/planner.test.ts and 1 other location - About 3 hrs to fix
          website/src/selectors/planner.test.ts on lines 229..238

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

          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 planner: PlannerState = {
                ...defaultState,
                minYear: '2016/2017',
                maxYear: '2016/2017',
                modules: {
          Severity: Major
          Found in website/src/selectors/planner.test.ts and 1 other location - About 3 hrs to fix
          website/src/selectors/planner.test.ts on lines 185..194

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

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

          export const CustomModuleFormComponent: React.FC<Props> = (props) => {
            // We use an uncontrolled form here because we don't want to update the
            // module title and MCs live
            const inputModuleCredit = React.createRef<HTMLInputElement>();
            const inputTitle = React.createRef<HTMLInputElement>();
          Severity: Major
          Found in website/src/views/planner/CustomModuleForm.tsx - About 3 hrs to fix

            Function settings has 77 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function settings(state: SettingsState = defaultSettingsState, action: Actions): SettingsState {
              switch (action.type) {
                case SELECT_NEW_STUDENT:
                  return {
                    ...state,
            Severity: Major
            Found in website/src/reducers/settings.ts - About 3 hrs to fix

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

                        {member.linkedin && (
                          <div className="col-sm-1 col">
                            <Tooltip content="Linkedin profile" touch="hold">
                              <ExternalLink
                                href={`https://www.linkedin.com/in/${member.linkedin}`}
              Severity: Major
              Found in website/src/views/static/TeamContainer.tsx and 3 other locations - About 3 hrs to fix
              website/src/views/static/TeamContainer.tsx on lines 43..54
              website/src/views/static/TeamContainer.tsx on lines 56..67
              website/src/views/static/TeamContainer.tsx on lines 69..80

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

              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

                        {member.twitter && (
                          <div className="col-sm-1 col">
                            <Tooltip content="Twitter profile" touch="hold">
                              <ExternalLink
                                href={`https://www.twitter.com/${member.twitter}`}
              Severity: Major
              Found in website/src/views/static/TeamContainer.tsx and 3 other locations - About 3 hrs to fix
              website/src/views/static/TeamContainer.tsx on lines 43..54
              website/src/views/static/TeamContainer.tsx on lines 69..80
              website/src/views/static/TeamContainer.tsx on lines 82..93

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

              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

                        {member.facebook && (
                          <div className="col-sm-1 col">
                            <Tooltip content="Facebook profile" touch="hold">
                              <ExternalLink
                                href={`https://www.facebook.com/${member.facebook}`}
              Severity: Major
              Found in website/src/views/static/TeamContainer.tsx and 3 other locations - About 3 hrs to fix
              website/src/views/static/TeamContainer.tsx on lines 56..67
              website/src/views/static/TeamContainer.tsx on lines 69..80
              website/src/views/static/TeamContainer.tsx on lines 82..93

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

              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

                        {member.github && (
                          <div className="col-sm-1 col">
                            <Tooltip content="GitHub profile" touch="hold">
                              <ExternalLink
                                href={`https://www.github.com/${member.github}`}
              Severity: Major
              Found in website/src/views/static/TeamContainer.tsx and 3 other locations - About 3 hrs to fix
              website/src/views/static/TeamContainer.tsx on lines 43..54
              website/src/views/static/TeamContainer.tsx on lines 56..67
              website/src/views/static/TeamContainer.tsx on lines 82..93

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

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

                  public cohort_years(): Cohort_yearsContext {
                      let _localctx: Cohort_yearsContext = new Cohort_yearsContext(this._ctx, this.state);
                      this.enterRule(_localctx, 24, NusModsParser.RULE_cohort_years);
                      let _la: number;
                      try {
              Severity: Major
              Found in scrapers/nus-v2/src/services/requisite-tree/antlr4/NusModsParser.ts - About 3 hrs to fix
                Severity
                Category
                Status
                Source
                Language