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>();
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,
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;
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';
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;
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();
- Read upRead up
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);
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>();
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);
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
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;
- Read upRead up
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,
- Read upRead up
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(
- Read upRead up
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),
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 =
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(
Function mapModuleInfo
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
const mapModuleInfo = (
moduleInfo: ModuleInfo,
departmentMap: DepartmentCodeMap,
facultyMap: FacultyCodeMap,
logger: Logger,
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);
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));
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,