ahbeng/NUSMods

View on GitHub

Showing 205 of 536 total issues

File NusModsParser.ts has 1870 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: Major
Found in scrapers/nus-v2/src/services/requisite-tree/antlr4/NusModsParser.ts - About 5 days to fix

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

    import CS4238Timetable from './fixtures/api-timetable/CS4238.json';
    import MA2213Timetable from './fixtures/api-timetable/MA2213.json';
    import CS2100Timetable from './fixtures/api-timetable/CS2100_2.json';
    import CN4205ETimetable from './fixtures/api-timetable/CN4205E.json';
    import CS1010XTimetable from './fixtures/api-timetable/CS1010X.json';
    Severity: Major
    Found in scrapers/nus-v2/src/tasks/GetSemesterTimetable.test.ts - About 4 days to fix

      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

            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

                File timetables.ts has 388 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

                  Function ModuleFinderSidebar has 125 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

                    Function KeyboardShortcuts has 114 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    const KeyboardShortcuts: React.FC = () => {
                      const [helpShown, setHelpShown] = useState(false);
                      const closeModal = useCallback(() => setHelpShown(false), []);
                    
                      const store = useStore<State>();
                    Severity: Major
                    Found in website/src/views/components/KeyboardShortcuts.tsx - About 4 hrs to fix

                      Function MpeContainer has 101 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      const MpeContainer: React.FC = () => {
                        const [isGettingSSOLink, setIsGettingSSOLink] = useState(false);
                        const [isModalOpen, setIsModalOpen] = useState(false);
                        const [isLoggedIn, setIsLoggedIn] = useState(getLoginState(useLocation(), useHistory()));
                      
                      
                      Severity: Major
                      Found in website/src/views/mpe/MpeContainer.tsx - About 4 hrs to fix

                        Function scraper has 101 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        async function scraper() {
                          const getDepartmentsResponse = await axios.post<ApiResponse<GetDepartmentsResponseData[]>>(
                            `${baseUrl}/config/get-acadorg`,
                            {
                              eff_status: 'A',
                        Severity: Major
                        Found in scrapers/cpex-scraper/src/index.ts - About 4 hrs to fix

                          Function TimetableModulesTableComponent has 100 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          export const TimetableModulesTableComponent: React.FC<Props> = (props) => {
                            const renderModuleActions = (module: ModuleWithColor) => {
                              const hideBtnLabel = `${module.hiddenInTimetable ? 'Show' : 'Hide'} ${module.moduleCode}`;
                              const removeBtnLabel = `Remove ${module.moduleCode} from timetable`;
                              const { semester } = props;
                          Severity: Major
                          Found in website/src/views/timetable/TimetableModulesTable.tsx - About 4 hrs to fix

                            Function checkPrerequisite has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
                            Open

                            export function checkPrerequisite(moduleSet: Set<ModuleCode>, tree: PrereqTree) {
                              function walkTree(fragment: PrereqTree): PrereqTree[] | null {
                                if (typeof fragment === 'string') {
                                  if (fragment.includes(GRADE_REQUIREMENT_SEPARATOR)) {
                                    const [module] = fragment.split(GRADE_REQUIREMENT_SEPARATOR);
                            Severity: Minor
                            Found in website/src/utils/planner.ts - About 3 hrs 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

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

                            import { render } from '@testing-library/react';
                            import userEvent from '@testing-library/user-event';
                            import { Provider } from 'react-redux';
                            import { MemoryRouter } from 'react-router-dom';
                            import produce from 'immer';
                            Severity: Minor
                            Found in website/src/views/layout/GlobalSearchContainer.test.tsx - About 3 hrs to fix

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

                              import { clone } from 'lodash';
                              import { getAcadYearModules, getPrereqModuleCode } from 'selectors/planner';
                              import { PlannerState } from 'types/reducers';
                              import { ModuleCode } from 'types/modules';
                              
                              
                              Severity: Minor
                              Found in website/src/selectors/planner.test.ts - About 3 hrs to fix

                                NusModsParser has 30 functions (exceeds 20 allowed). Consider refactoring.
                                Open

                                export class NusModsParser extends Parser {
                                    public static readonly COMMA = 1;
                                    public static readonly LPAREN = 2;
                                    public static readonly RPAREN = 3;
                                    public static readonly IF_IN = 4;
                                Severity: Minor
                                Found in scrapers/nus-v2/src/services/requisite-tree/antlr4/NusModsParser.ts - About 3 hrs to fix

                                  Function scraper has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                  async function scraper() {
                                    const getDepartmentsResponse = await axios.post<ApiResponse<GetDepartmentsResponseData[]>>(
                                      `${baseUrl}/config/get-acadorg`,
                                      {
                                        eff_status: 'A',
                                  Severity: Minor
                                  Found in scrapers/cpex-scraper/src/index.ts - About 3 hrs 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

                                  File ModulePageContent.tsx has 314 lines of code (exceeds 250 allowed). Consider refactoring.
                                  Open

                                  import { memo, useState } from 'react';
                                  import classnames from 'classnames';
                                  import ScrollSpy from 'react-scrollspy';
                                  import { kebabCase, map, mapValues, values, sortBy } from 'lodash';
                                  
                                  
                                  Severity: Minor
                                  Found in website/src/views/modules/ModulePageContent.tsx - About 3 hrs to fix

                                    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
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language