ahbeng/NUSMods

View on GitHub

Showing 212 of 556 total issues

Function renderModule has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  const renderModule = (plannerModule: PlannerModuleInfo, index: number) => {
    const { id, moduleCode, moduleInfo, conflict, placeholder } = plannerModule;

    const showExamDate = showModuleMeta && config.academicYear === year;

Severity: Minor
Found in website/src/views/planner/PlannerSemester.tsx - About 1 hr to fix

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

      async run(input: Input) {
        this.logger.info(`Collating modules for ${this.academicYear}`);
    
        const { semesterData, aliases } = input;
        const combinedAliases = mergeAliases(aliases);
    Severity: Minor
    Found in scrapers/nus-v2/src/tasks/CollateModules.ts - About 1 hr to fix

      Function NotFoundPage has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      const NotFoundPage: React.FC = () => {
        Sentry.withScope(() => {
          Sentry.captureMessage('404 - Page Not Found');
        });
      
      
      Severity: Minor
      Found in website/src/views/errors/NotFoundPage.tsx - About 1 hr to fix

        Function contains_number has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public contains_number(): Contains_numberContext {
                let _localctx: Contains_numberContext = new Contains_numberContext(this._ctx, this.state);
                this.enterRule(_localctx, 44, NusModsParser.RULE_contains_number);
                try {
                    this.enterOuterAlt(_localctx, 1);
        Severity: Minor
        Found in scrapers/nus-v2/src/services/requisite-tree/antlr4/NusModsParser.ts - About 1 hr to fix

          Function TetrisLogo has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          const TetrisLogo: React.FC = () => {
            // Create the diagonal bands by offsetting the color using line and char index
            // Make the bands move by offsetting the color using time
            const currentTime = useCurrentTime(INTERVAL);
            const timeOffset = Math.round(currentTime.getTime() / INTERVAL);
          Severity: Minor
          Found in website/src/views/tetris/overlays/TetrisLogo.tsx - About 1 hr to fix

            Function boolean_expr has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                public boolean_expr(): Boolean_exprContext {
                    let _localctx: Boolean_exprContext = new Boolean_exprContext(this._ctx, this.state);
                    this.enterRule(_localctx, 8, NusModsParser.RULE_boolean_expr);
                    let _la: number;
                    try {
            Severity: Minor
            Found in scrapers/nus-v2/src/services/requisite-tree/antlr4/NusModsParser.ts - About 55 mins 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 TimetableContainerComponent has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

            export const TimetableContainerComponent: FC = () => {
              const params = useParams<Params>();
            
              const semester = semesterForTimetablePage(params.semester);
            
            
            Severity: Minor
            Found in website/src/views/timetable/TimetableContainer.tsx - About 55 mins 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 verifyLogin has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              (next: Handler): Handler =>
              async (req, res): Promise<void> => {
                try {
                  const { user } = await authenticate(req);
                  // TODO: Augment VercelApiHandler's request with a user object, or find
            Severity: Minor
            Found in website/src/serverless/nus-auth.ts - About 45 mins 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 process has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

            function process(rawData) {
              const total = rawData.reduce((count, row) => count + row.sum_daily_nb_uniq_visitors, 0);
            
              const output = helpers.getTemplate();
              for (const row of rawData) {
            Severity: Minor
            Found in packages/browserslist-config-nusmods/scripts/generate.js - About 45 mins 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 ModuleArchiveContainerComponent has a Cognitive Complexity of 8 (exceeds 5 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 45 mins 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 createGenericColoredLesson has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

              dayText?: DayText,
              startTime?: LessonTime,
              endTime?: LessonTime,
              lessonType?: LessonType,
              classNo?: ClassNo,
            Severity: Minor
            Found in website/src/test-utils/timetable.ts - About 45 mins to fix

              Consider simplifying this complex logical expression.
              Open

                  if (
                    typeof height !== 'undefined' &&
                    typeof width !== 'undefined' &&
                    !Number.isNaN(height) && // accept floats
                    !Number.isNaN(width) && // accept floats
              Severity: Major
              Found in export/src/app.ts - About 40 mins to fix

                Consider simplifying this complex logical expression.
                Open

                      if (
                        !module.CourseTitle ||
                        !module.ModularCredit ||
                        !module.Subject ||
                        !module.CatalogNumber ||
                Severity: Major
                Found in scrapers/cpex-scraper/src/index.ts - About 40 mins to fix

                  Consider simplifying this complex logical expression.
                  Open

                      if (
                        typeof height !== 'undefined' &&
                        typeof width !== 'undefined' &&
                        !Number.isNaN(height) && // accept floats
                        !Number.isNaN(width) && // accept floats
                  Severity: Major
                  Found in export/api/export/image.ts - About 40 mins to fix

                    Consider simplifying this complex logical expression.
                    Open

                    if (
                      ((NUSMODS_ENV === 'preview' || NUSMODS_ENV === 'staging' || NUSMODS_ENV === 'production') &&
                        'serviceWorker' in navigator &&
                        window.location.protocol === 'https:') ||
                      // Allow us to force service worker to be enabled for debugging
                    Severity: Major
                    Found in website/src/entry/main.tsx - About 40 mins to fix

                      Function iCalForTimetable has 5 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                        semester: Semester,
                        timetable: SemTimetableConfigWithLessons,
                        moduleData: { [moduleCode: string]: Module },
                        hiddenModules: string[],
                        academicYear: string = config.academicYear,
                      Severity: Minor
                      Found in website/src/utils/ical.ts - About 35 mins to fix

                        Function computeUndoStacks has 5 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                          state: UndoHistoryState<T> = {
                            past: [],
                            present: undefined, // Don't pretend to know the present
                            future: [],
                          },
                        Severity: Minor
                        Found in website/src/reducers/undoHistory.ts - About 35 mins to fix

                          Function createGenericLesson has 5 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                            dayText: DayText = 'Monday',
                            startTime: LessonTime = '0800',
                            endTime: LessonTime = '1000',
                            lessonType: LessonType = 'Recitation',
                            classNo: ClassNo = '1',
                          Severity: Minor
                          Found in website/src/test-utils/timetable.ts - About 35 mins to fix

                            Function serializeState has 5 arguments (exceeds 4 allowed). Consider refactoring.
                            Open

                              semester: Semester,
                              timetable: SemTimetableConfig,
                              colorScheme: ColorScheme,
                              state: State,
                              options: ExportOptions = {},
                            Severity: Minor
                            Found in website/src/apis/export.ts - About 35 mins to fix

                              Function defaultFallback has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                              Open

                                (methodHandlers: MethodHandlers) =>
                                async (_req: Request, res: Response): Promise<void> => {
                                  const allowedMethods = Object.entries(methodHandlers).reduce((acc, [method, handler]) => {
                                    if (handler !== undefined) {
                                      if (acc === '') return method;
                              Severity: Minor
                              Found in website/src/serverless/handler.ts - About 35 mins 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

                              Severity
                              Category
                              Status
                              Source
                              Language