ahbeng/NUSMods

View on GitHub

Showing 212 of 556 total issues

Function ModuleArchiveContainerComponent has 50 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const ModuleArchiveContainerComponent: FC = () => {
  const [ModulePageContent, setModulePageContent] =
    useState<ComponentType<ModulePageContentProps> | null>(null);
  const [error, setError] = useState<Error | undefined>();

Severity: Minor
Found in website/src/views/modules/ModuleArchiveContainer.tsx - About 2 hrs to fix

    Function findExamClashes has 49 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export function findExamClashes(modules: Module[], semester: Semester): ExamClashes {
      // Filter away modules without exam dates or exam durations
      const filteredModules = modules.filter(
        (module) =>
          getExamDate(module, semester) !== null && getExamDuration(module, semester) !== null,
    Severity: Minor
    Found in website/src/utils/timetables.ts - About 1 hr to fix

      Function overall has 48 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public overall(): OverallContext {
              let _localctx: OverallContext = new OverallContext(this._ctx, this.state);
              this.enterRule(_localctx, 0, NusModsParser.RULE_overall);
              try {
                  this.state = 55;
      Severity: Minor
      Found in scrapers/nus-v2/src/services/requisite-tree/antlr4/NusModsParser.ts - About 1 hr to fix

        Function TimetableCell has 48 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        const TimetableCell: React.FC<Props> = (props) => {
          const { lesson, showTitle, onClick, onHover, hoverLesson, transparent } = props;
        
          const moduleName = showTitle ? `${lesson.moduleCode} ${lesson.title}` : lesson.moduleCode;
          const Cell = props.onClick ? 'button' : 'div';
        Severity: Minor
        Found in website/src/views/timetable/TimetableCell.tsx - About 1 hr to fix

          Function coreq has 48 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public coreq(): CoreqContext {
                  let _localctx: CoreqContext = new CoreqContext(this._ctx, this.state);
                  this.enterRule(_localctx, 34, NusModsParser.RULE_coreq);
                  try {
                      this.state = 194;
          Severity: Minor
          Found in scrapers/nus-v2/src/services/requisite-tree/antlr4/NusModsParser.ts - About 1 hr to fix

            Function insertRequisiteTree has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

            export function insertRequisiteTree(modules: Module[], prerequisites: PrereqTreeMap): Module[] {
              // Find modules which this module fulfill the requirements for
              const fulfillModulesMap: { [moduleCode: string]: Set<ModuleCode> } = {};
              for (const module of modules) {
                fulfillModulesMap[module.moduleCode] = new Set();
            Severity: Minor
            Found in scrapers/nus-v2/src/services/requisite-tree/index.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 getAcadWeekInfo has 47 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export function getAcadWeekInfo(date: Date): AcadWeekInfo {
              const currentAcad = getAcadYear(date);
              const acadYear = currentAcad.year;
              const acadYearStartDate = getAcadYearStartDate(acadYear);
            
            
            Severity: Minor
            Found in packages/nusmoderator/src/academicCalendar.ts - About 1 hr to fix

              Function ModulePageContainerComponent has 44 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export const ModulePageContainerComponent: FC = () => {
                const [ModulePageContent, setModulePageContent] =
                  useState<ComponentType<ModulePageContentProps> | null>(null);
                const [error, setError] = useState<Error | undefined>();
              
              
              Severity: Minor
              Found in website/src/views/modules/ModulePageContainer.tsx - About 1 hr to fix

                Function useFetchModuleListAndTimetableModules has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                function useFetchModuleListAndTimetableModules(): {
                  moduleListError: Error | null;
                  refetchModuleListAndTimetableModules: () => void;
                } {
                  const [moduleListError, setModuleListError] = useState<Error | null>(null);
                Severity: Minor
                Found in website/src/views/AppShell.tsx - About 1 hr to fix

                  Function getAcadYearModules has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  export function getAcadYearModules(state: State): PlannerModulesWithInfo {
                    const { planner, moduleBank } = state;
                    const years = getYearsBetween(planner.minYear, planner.maxYear);
                    const exemptions = [
                      // Normal exemptions
                  Severity: Minor
                  Found in website/src/selectors/planner.ts - About 1 hr to fix

                    Function TimetableModulesTableComponent has a Cognitive Complexity of 14 (exceeds 5 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: Minor
                    Found in website/src/views/timetable/TimetableModulesTable.tsx - 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 PlannerSemester has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                    Open

                    const PlannerSemester: React.FC<Props> = ({
                      year,
                      semester,
                      modules,
                      showModuleMeta = true,
                    Severity: Minor
                    Found in website/src/views/planner/PlannerSemester.tsx - 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 run has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                    Open

                      async run(input: Input) {
                        this.logger.info(`Collating venues for ${this.academicYear} semester ${this.semester}`);
                    
                        // Insert module code and flatten lessons
                        const venueLessons: LessonWithModuleCode[] = compact(
                    Severity: Minor
                    Found in scrapers/nus-v2/src/tasks/CollateVenues.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 ModulesTableFooter has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    const ModulesTableFooter: React.FC<Props> = (props) => {
                      const totalMCs = sumBy(props.modules, (module) => parseFloat(module.moduleCredit));
                      const shownMCs = sumBy(
                        props.modules.filter((module) => !props.hiddenInTimetable.includes(module.moduleCode)),
                        (module) => parseFloat(module.moduleCredit),
                    Severity: Minor
                    Found in website/src/views/timetable/ModulesTableFooter.tsx - About 1 hr to fix

                      Function DayEvents has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      const DayEvents = React.memo<Props>((props) => {
                        const renderLesson = (lesson: ColoredLesson, i: number) => {
                          const { openLesson, onOpenLesson, marker, date } = props;
                      
                          const isOpen =
                      Severity: Minor
                      Found in website/src/views/today/DayEvents.tsx - About 1 hr to fix

                        Function run has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          async run(input: Input) {
                            this.logger.info(`Collating venues for ${this.academicYear} semester ${this.semester}`);
                        
                            // Insert module code and flatten lessons
                            const venueLessons: LessonWithModuleCode[] = compact(
                        Severity: Minor
                        Found in scrapers/nus-v2/src/tasks/CollateVenues.ts - About 1 hr to fix

                          Function mapModuleInfo has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          const mapModuleInfo = (
                            moduleInfo: ModuleInfo,
                            departmentMap: DepartmentCodeMap,
                            facultyMap: FacultyCodeMap,
                            logger: Logger,
                          Severity: Minor
                          Found in scrapers/nus-v2/src/tasks/GetSemesterData.ts - About 1 hr to fix

                            Function VenueList has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            const VenueList: React.FC<Props> = (props) => {
                              // Added during the horrible COVID-19 times to hide E-Learning venues
                              const physicalVenues = props.venues.filter((venue) => !venue.startsWith('E-Learn'));
                              const venueList = groupBy(physicalVenues, (venue) => venue.charAt(0).toUpperCase());
                              const sortedVenueList = sortBy(toPairs(venueList), ([key]) => key);
                            Severity: Minor
                            Found in website/src/views/venues/VenueList.tsx - About 1 hr to fix

                              Function TimetableDay has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              const TimetableDay: React.FC<Props> = (props) => {
                                const { startingIndex, endingIndex, verticalMode, highlightPeriod } = props;
                              
                                const columns = endingIndex - startingIndex;
                                const size = 100 / (columns / (NUM_INTERVALS_PER_HOUR * 2));
                              Severity: Minor
                              Found in website/src/views/timetable/TimetableDay.tsx - About 1 hr to fix

                                Function ColorPicker has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                const ColorPicker = memo<Props>((props) => {
                                  const renderColorPicker: ChildrenFunction<ColorIndex> = ({
                                    getToggleButtonProps,
                                    getItemProps,
                                    getMenuProps,
                                Severity: Minor
                                Found in website/src/views/components/ColorPicker.tsx - About 1 hr to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language