ahbeng/NUSMods

View on GitHub

Showing 538 of 538 total issues

Function mergeDualCodedModules has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

export function mergeDualCodedModules(classes: VenueLesson[]): {
  lessons: VenueLesson[];
  aliases: ModuleAliases;
} {
  // Repeatedly merge lessons that occupy the same space in the timetable
Severity: Minor
Found in scrapers/nus-v2/src/utils/data.ts - About 25 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 mapLessonWeeks has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

export function mapLessonWeeks(dates: string[], semester: number, logger: Logger): Weeks {
  // Sanity check for lessons occurring on duplicate days
  if (dates.length !== new Set(dates).size) {
    logger.error('Lesson has duplicate dates');
  }
Severity: Minor
Found in scrapers/nus-v2/src/tasks/GetSemesterTimetable.ts - About 25 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 parse has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

function parse(data: ModuleWithoutTree[], subLogger: Logger): PrereqTreeMap {
  const results: PrereqTreeMap = {};

  for (const module of data) {
    const { moduleCode, prerequisiteRule: value } = module;
Severity: Minor
Found in scrapers/nus-v2/src/services/requisite-tree/index.ts - About 25 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 env has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

exports.env = () => {
  if (process.env.NODE_ENV === 'test') return 'test';

  // Vercel deployments
  if (process.env.VERCEL_ENV === 'production') return 'production';
Severity: Minor
Found in website/webpack/webpack.parts.js - About 25 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 PlannerSemester has a Cognitive Complexity of 6 (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 25 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 ModulePageContent has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

const ModulePageContent: React.FC<Props> = ({ module, archiveYear }) => {
  const [isMenuOpen, setIsMenuOpen] = useState(false);

  const { moduleCode, title } = module;

Severity: Minor
Found in website/src/views/modules/ModulePageContent.tsx - About 25 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 getAcadWeekName has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

export function getAcadWeekName(acadWeekNumber: number): AcadWeek | null {
  switch (acadWeekNumber) {
    case 7:
      return {
        weekType: 'Recess',
Severity: Minor
Found in packages/nusmoderator/src/academicCalendar.ts - About 25 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 program_types has a Cognitive Complexity of 6 (exceeds 5 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: Minor
Found in scrapers/nus-v2/src/services/requisite-tree/antlr4/NusModsParser.ts - About 25 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 compound has a Cognitive Complexity of 6 (exceeds 5 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: Minor
Found in scrapers/nus-v2/src/services/requisite-tree/antlr4/NusModsParser.ts - About 25 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 getFileSystemWriter has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

export function getFileSystemWriter(academicYear: string): Persist {
  const yearRoot = getFileRoot(academicYear);

  // Directory structure
  //
Severity: Minor
Found in scrapers/nus-v2/src/services/io/fs.ts - About 25 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 authenticate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

export const authenticate = async (req: Request) => {
  const tokenProvided = req.headers.authorization || (req.body && req.body.SAMLResponse);
  if (!tokenProvided) {
    throw new Error(errors.noTokenSupplied);
  }
Severity: Minor
Found in website/src/serverless/nus-auth.ts - About 25 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 TimetableCell has a Cognitive Complexity of 6 (exceeds 5 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 25 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 getDuplicateModules has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

export function getDuplicateModules(classes: VenueLesson[]): ModuleCode[] {
  const lessonsByTime: VenueLesson[][] = values(
    groupBy(classes, (lesson) => [lesson.startTime, lesson.endTime, lesson.weeks, lesson.day]),
  );

Severity: Minor
Found in scrapers/nus-v2/src/utils/data.ts - About 25 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 ExamWeekComponent has a Cognitive Complexity of 6 (exceeds 5 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: Minor
Found in website/src/views/timetable/ExamWeek.tsx - About 25 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 removeCompleteRows has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

export function removeCompleteRows(board: Board) {
  let rowsCleared = 0;

  const newBoard = produce(board, (draft: Board) => {
    // TODO: Optimize based on where the piece has landed
Severity: Minor
Found in website/src/views/tetris/board.ts - About 25 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 buildFacultyMap has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

function buildFacultyMap(departments: AcademicOrg[], faculties: AcademicGrp[]) {
  const departmentFaculty: Record<string, string> = {};

  // Map departments to their corresponding faculty. This works because the first three chars of
  // the department code (AcademicOrganization) matches the faculty code (AcademicGroup)
Severity: Minor
Found in scrapers/nus-v2/src/tasks/MigrateV1ToV2.ts - About 25 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 planner has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

export default function planner(
  state: PlannerState = defaultPlannerState,
  action: Actions,
): PlannerState {
  switch (action.type) {
Severity: Minor
Found in website/src/reducers/planner.ts - About 25 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 DayEvents has a Cognitive Complexity of 6 (exceeds 5 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 25 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