ahbeng/NUSMods

View on GitHub

Showing 212 of 556 total issues

Function renderConflict has 60 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  const renderConflict = (conflict: Conflict) => {
    switch (conflict.type) {
      case 'noInfo':
        return (
          <div className={styles.conflictHeader}>
Severity: Major
Found in website/src/views/planner/PlannerModule.tsx - About 2 hrs to fix

    Function Navtabs has 60 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    const Navtabs: FC = () => {
      const activeSemester = useSelector(({ app }: State) => app.activeSemester);
    
      const tabProps = {
        className: styles.link,
    Severity: Major
    Found in website/src/views/layout/Navtabs.tsx - About 2 hrs to fix

      Function renderType has 60 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function renderType(type: EmptyGroupType) {
        switch (type) {
          case 'winter':
            return (
              <>
      Severity: Major
      Found in website/src/views/today/EmptyLessonGroup.tsx - About 2 hrs to fix

        Function program_types has 59 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public program_types(): Program_typesContext {
                let _localctx: Program_typesContext = new Program_typesContext(this._ctx, this.state);
                this.enterRule(_localctx, 2, NusModsParser.RULE_program_types);
                let _la: number;
                try {
        Severity: Major
        Found in scrapers/nus-v2/src/services/requisite-tree/antlr4/NusModsParser.ts - About 2 hrs to fix

          Function ModuleTreeComponent has 59 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export const ModuleTreeComponent: React.FC<Props> = (props) => {
            const { fulfillRequirements, prereqTree, moduleCode } = props;
          
            return (
              <>
          Severity: Major
          Found in website/src/views/modules/ModuleTree.tsx - About 2 hrs to fix

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

            import { EventOption } from 'ical-generator';
            import config from 'config';
            import iCalForTimetable, {
              calculateNumericWeek,
              calculateWeekRange,
            Severity: Minor
            Found in website/src/utils/ical.test.ts - About 2 hrs to fix

              Function createIndex has 57 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              async function createIndex(client: Client): Promise<Client> {
                try {
                  await client.indices.create({
                    index: INDEX_NAME,
                    body: {
              Severity: Major
              Found in scrapers/nus-v2/src/services/io/elastic.ts - About 2 hrs to fix

                Function makeExportHandler has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                Open

                export function makeExportHandler<T>(
                  parseExportData: (request: VercelRequest) => T,
                  performExport: (response: VercelResponse, page: Page, data: T) => void | Promise<void>,
                ): VercelApiHandler {
                  return async function handler(request, response) {
                Severity: Minor
                Found in export/src/handler.ts - About 2 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

                Function op has 55 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public op(): OpContext {
                        let _localctx: OpContext = new OpContext(this._ctx, this.state);
                        this.enterRule(_localctx, 10, NusModsParser.RULE_op);
                        try {
                            this.state = 93;
                Severity: Major
                Found in scrapers/nus-v2/src/services/requisite-tree/antlr4/NusModsParser.ts - About 2 hrs to fix

                  Function exports has 55 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  module.exports = (api) => {
                    api.cache.using(() => process.env.NODE_ENV);
                  
                    const IS_PROD = api.env('production');
                    const IS_DEV = api.env('development');
                  Severity: Major
                  Found in website/babel.config.js - About 2 hrs to fix

                    Function timetables has 53 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    function timetables(
                      state: TimetablesState = defaultTimetableState,
                      action: Actions,
                    ): TimetablesState {
                      // All normal timetable actions should specify their semester
                    Severity: Major
                    Found in website/src/reducers/timetables.ts - About 2 hrs to fix

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

                      import {
                        getAcadYearStartDate,
                        getAcadYear,
                        getAcadSem,
                        getAcadWeekName,
                      Severity: Minor
                      Found in packages/nusmoderator/src/academicCalendar.test.ts - About 2 hrs to fix

                        Function PlannerModule has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                        Open

                        const PlannerModule = memo<Props>((props) => {
                          const [isEditingPlaceholder, setEditingPlaceholder] = useState(false);
                        
                          const removeModule = () => props.removeModule(props.id);
                        
                        
                        Severity: Minor
                        Found in website/src/views/planner/PlannerModule.tsx - About 2 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 GetSemesterData.ts has 253 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

                        import { strict as assert } from 'assert';
                        import { each, fromPairs, keyBy, isEmpty } from 'lodash';
                        
                        import type { AcademicGrp, AcademicOrg, ModuleAttributeEntry, ModuleInfo } from '../types/api';
                        import type {
                        Severity: Minor
                        Found in scrapers/nus-v2/src/tasks/GetSemesterData.ts - About 2 hrs to fix

                          Function ExamWeekComponent has 51 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          const ExamWeekComponent: React.FC<Props> = (props) => {
                            const { modules, weekNumber, firstDayOfExams, days } = props;
                            const currentTime = useCurrentTime();
                          
                            // Array of dates to display
                          Severity: Major
                          Found in website/src/views/timetable/ExamWeek.tsx - About 2 hrs to fix

                            Function ArrivalTimes has 51 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            export const ArrivalTimes = memo<Props>((props: Props) => {
                              if (props.error) {
                                return (
                                  <>
                                    <h3 className={styles.heading}>{props.name}</h3>
                            Severity: Major
                            Found in website/src/views/components/map/ArrivalTimes.tsx - About 2 hrs to fix

                              Function special_condition has 51 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  public special_condition(): Special_conditionContext {
                                      let _localctx: Special_conditionContext = new Special_conditionContext(this._ctx, this.state);
                                      this.enterRule(_localctx, 30, NusModsParser.RULE_special_condition);
                                      try {
                                          this.state = 171;
                              Severity: Major
                              Found in scrapers/nus-v2/src/services/requisite-tree/antlr4/NusModsParser.ts - About 2 hrs to fix

                                Function compound has 51 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                    public compound(): CompoundContext {
                                        let _localctx: CompoundContext = new CompoundContext(this._ctx, this.state);
                                        this.enterRule(_localctx, 4, NusModsParser.RULE_compound);
                                        try {
                                            this.state = 77;
                                Severity: Major
                                Found in scrapers/nus-v2/src/services/requisite-tree/antlr4/NusModsParser.ts - About 2 hrs to fix

                                  Function programs_condition has 51 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                      public programs_condition(): Programs_conditionContext {
                                          let _localctx: Programs_conditionContext = new Programs_conditionContext(this._ctx, this.state);
                                          this.enterRule(_localctx, 16, NusModsParser.RULE_programs_condition);
                                          try {
                                              this.state = 117;
                                  Severity: Major
                                  Found in scrapers/nus-v2/src/services/requisite-tree/antlr4/NusModsParser.ts - About 2 hrs to fix

                                    Function plan_types_condition has 51 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                        public plan_types_condition(): Plan_types_conditionContext {
                                            let _localctx: Plan_types_conditionContext = new Plan_types_conditionContext(this._ctx, this.state);
                                            this.enterRule(_localctx, 22, NusModsParser.RULE_plan_types_condition);
                                            try {
                                                this.state = 138;
                                    Severity: Major
                                    Found in scrapers/nus-v2/src/services/requisite-tree/antlr4/NusModsParser.ts - About 2 hrs to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language