ahbeng/NUSMods

View on GitHub

Showing 538 of 538 total issues

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

export class Plan_types_conditionContext extends ParserRuleContext {
    public IF_IN(): TerminalNode | undefined { return this.tryGetToken(NusModsParser.IF_IN, 0); }
    public IF_NOT_IN(): TerminalNode | undefined { return this.tryGetToken(NusModsParser.IF_NOT_IN, 0); }
    public must_be_in(): Must_be_inContext | undefined {
        return this.tryGetRuleContext(0, Must_be_inContext);
scrapers/nus-v2/src/services/requisite-tree/antlr4/NusModsParser.ts on lines 1635..1657
scrapers/nus-v2/src/services/requisite-tree/antlr4/NusModsParser.ts on lines 1846..1868

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

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

export class Special_conditionContext extends ParserRuleContext {
    public IF_IN(): TerminalNode | undefined { return this.tryGetToken(NusModsParser.IF_IN, 0); }
    public IF_NOT_IN(): TerminalNode | undefined { return this.tryGetToken(NusModsParser.IF_NOT_IN, 0); }
    public must_be_in(): Must_be_inContext | undefined {
        return this.tryGetRuleContext(0, Must_be_inContext);
scrapers/nus-v2/src/services/requisite-tree/antlr4/NusModsParser.ts on lines 1635..1657
scrapers/nus-v2/src/services/requisite-tree/antlr4/NusModsParser.ts on lines 1723..1745

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

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

import GET1025 from './fixtures/nusmods-timetable/GET1025.json';
import GEK2041 from './fixtures/nusmods-timetable/GEK2041.json';
import PX2108 from './fixtures/nusmods-timetable/PX2108.json';

import CollateVenues, { extractVenueAvailability } from './CollateVenues';
Severity: Major
Found in scrapers/nus-v2/src/tasks/CollateVenues.test.ts - About 1 day to fix

    File timetables.test.ts has 570 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import NUSModerator from 'nusmoderator';
    import _ from 'lodash';
    import { parseISO } from 'date-fns';
    import {
      ColoredLesson,
    Severity: Major
    Found in website/src/utils/timetables.test.ts - About 1 day to fix

      File parseString.test.ts has 543 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import parseString from './parseString';
      import { mockLogger } from '../../utils/test-utils';
      import { PrereqTree } from '../../types/modules';
      
      /* eslint-disable max-len */
      Severity: Major
      Found in scrapers/nus-v2/src/services/requisite-tree/parseString.test.ts - About 1 day to fix

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

        export class Must_be_inContext extends ParserRuleContext {
            public MUST_BE_IN(): TerminalNode { return this.getToken(NusModsParser.MUST_BE_IN, 0); }
            public contains_number(): Contains_numberContext | undefined {
                return this.tryGetRuleContext(0, Contains_numberContext);
            }
        scrapers/nus-v2/src/services/requisite-tree/antlr4/NusModsParser.ts on lines 2003..2021

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

        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

        export class Must_not_be_inContext extends ParserRuleContext {
            public MUST_NOT_BE_IN(): TerminalNode { return this.getToken(NusModsParser.MUST_NOT_BE_IN, 0); }
            public contains_number(): Contains_numberContext | undefined {
                return this.tryGetRuleContext(0, Contains_numberContext);
            }
        scrapers/nus-v2/src/services/requisite-tree/antlr4/NusModsParser.ts on lines 1982..2000

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

        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

          '2': [
            {
              Term: '1820',
              AcademicOrganisation: {
                Code: '00301ACAD1',
        Severity: Major
        Found in scrapers/nus-v2/src/tasks/DataPipeline.test.ts and 1 other location - About 6 hrs to fix
        scrapers/nus-v2/src/tasks/DataPipeline.test.ts on lines 28..69

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

        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

          '1': [
            {
              Term: '1810',
              AcademicOrganisation: {
                Code: '00301ACAD1',
        Severity: Major
        Found in scrapers/nus-v2/src/tasks/DataPipeline.test.ts and 1 other location - About 6 hrs to fix
        scrapers/nus-v2/src/tasks/DataPipeline.test.ts on lines 70..111

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

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

        // Generated from src/services/requisite-tree/antlr4/NusMods.g4 by ANTLR 4.9.0-SNAPSHOT
        
        
        import { ATN } from "antlr4ts/atn/ATN";
        import { ATNDeserializer } from "antlr4ts/atn/ATNDeserializer";
        Severity: Minor
        Found in scrapers/nus-v2/src/services/requisite-tree/antlr4/NusModsLexer.ts - About 5 hrs to fix

          Function PlannerModule has 146 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          const PlannerModule = memo<Props>((props) => {
            const [isEditingPlaceholder, setEditingPlaceholder] = useState(false);
          
            const removeModule = () => props.removeModule(props.id);
          
          
          Severity: Major
          Found in website/src/views/planner/PlannerModule.tsx - About 5 hrs to fix

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

              test('should format time numbers to strings', () => {
                expect(formatTime(0)).toEqual('12 midnight');
                expect(formatTime(10)).toEqual('12:10 am');
                expect(formatTime(900)).toEqual('9:00 am');
                expect(formatTime(1100)).toEqual('11:00 am');
            Severity: Major
            Found in website/src/utils/timify.test.ts and 1 other location - About 5 hrs to fix
            website/src/utils/timify.test.ts on lines 114..124

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

            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

              test('should convert hour to time strings', () => {
                expect(formatHour(0)).toBe('12 midnight');
                expect(formatHour(24)).toBe('12 midnight');
                expect(formatHour(12)).toBe('12 noon');
            
            
            Severity: Major
            Found in website/src/utils/timify.test.ts and 1 other location - About 5 hrs to fix
            website/src/utils/timify.test.ts on lines 134..142

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

            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

            async function injectData(page: Page, data: PageData) {
              const moduleCodes = Object.keys(data.timetable);
              const modules = await getModules(moduleCodes);
            
              await page.evaluate(`
            Severity: Major
            Found in export/src/render.ts and 1 other location - About 5 hrs to fix
            export/src/render-serverless.ts on lines 41..56

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

            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

            async function injectData(page: Page, data: PageData) {
              const moduleCodes = Object.keys(data.timetable);
              const modules = await getModules(moduleCodes);
            
              await page.evaluate(`
            Severity: Major
            Found in export/src/render-serverless.ts and 1 other location - About 5 hrs to fix
            export/src/render.ts on lines 75..90

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

            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

                test('left button', () => {
                  const onButtonClick = jest.fn();
                  const wrapper = shallow(<SemesterSwitcher semester={1} onSelectSemester={onButtonClick} />);
                  const buttons = wrapper.find('button');
                  buttons.at(0).simulate('click');
            website/src/views/components/semester-switcher/SemesterSwitcher.test.tsx on lines 27..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 144.

            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

                test('right button', () => {
                  const onButtonClick = jest.fn();
                  const wrapper = shallow(<SemesterSwitcher semester={4} onSelectSemester={onButtonClick} />);
                  const buttons = wrapper.find('button');
                  buttons.at(1).simulate('click');
            website/src/views/components/semester-switcher/SemesterSwitcher.test.tsx on lines 17..25

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

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

            const ModuleFinderSidebar: React.FC = () => {
              const [isMenuOpen, setMenuOpen] = useState(false);
            
              const getSemesterTimetable = useSelector(getSemesterTimetableLessons);
              const allModules = useSelector((state: StoreState) => state.moduleBank.modules);
            Severity: Major
            Found in website/src/views/modules/ModuleFinderSidebar.tsx - About 5 hrs to fix

              File timetables.ts has 391 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              import { AcadWeekInfo } from 'nusmoderator';
              import {
                castArray,
                difference,
                each,
              Severity: Minor
              Found in website/src/utils/timetables.ts - About 5 hrs to fix

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

                                {
                                this.state = 175;
                                this.match(NusModsParser.SUBJECTS);
                                this.state = 177;
                                this._errHandler.sync(this);
                scrapers/nus-v2/src/services/requisite-tree/antlr4/NusModsParser.ts on lines 1115..1130

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

                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