Showing 212 of 556 total issues
Function handler
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
return async function handler(request, response) {
try {
throwIfAcademicYearNotSet();
setUpSentry();
Function fetchModule
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export function fetchModule(moduleCode: ModuleCode) {
return (dispatch: Dispatch, getState: GetState) => {
const onFinally = () => {
// Update the timestamp of the accessed module if it is in the store.
if (getState().moduleBank.modules[moduleCode]) {
Function run
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
async run(): Promise<Output> {
this.logger.info(
`Getting exams for all modules in ${this.academicYear} semester ${this.semester}`,
);
const term = getTermCode(this.semester, this.academicYear);
Function Announcements
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const Announcements = memo(() => {
const [isOpen, setIsOpen] = useState(() => {
if (!enableAnnouncements) return false;
if (key) return !storage.getItem(key);
return true;
Function courses
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public courses(): CoursesContext {
let _localctx: CoursesContext = new CoursesContext(this._ctx, this.state);
this.enterRule(_localctx, 36, NusModsParser.RULE_courses);
let _la: number;
try {
Function checkPrerequisite
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export function checkPrerequisite(moduleSet: Set<ModuleCode>, tree: PrereqTree): PrereqTree[] {
const moduleArray = Array.from(moduleSet);
function walkTree(fragment: PrereqTree): PrereqTree[] {
if (typeof fragment === 'string') {
Function Tree
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const Tree: React.FC<TreeDisplay> = (props) => {
const { layer, node, isPrereq } = props;
const isConditional = typeof node !== 'string';
const { prefix, name } = nodeName(node);
Function renderModule
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const renderModule = (module: ModuleWithColor) => {
const { semester, readOnly, tombstone, resetTombstone } = props;
if (tombstone && tombstone.moduleCode === module.moduleCode) {
return <ModuleTombstone module={module} resetTombstone={resetTombstone} />;
Function ButtonGroupSelector
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const ButtonGroupSelector: React.FC<Props> = (props) => {
const {
size,
choices,
selectedChoice,
Function renderLesson
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const renderLesson = (lesson: ColoredLesson, i: number) => {
const { openLesson, onOpenLesson, marker, date } = props;
const isOpen =
!!openLesson && isSameDay(openLesson.date, date) && isSameLesson(openLesson.lesson, lesson);
Function getAcadWeekName
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export function getAcadWeekName(acadWeekNumber: number): AcadWeek | null {
switch (acadWeekNumber) {
case 7:
return {
weekType: 'Recess',
Function formatWeekRange
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function formatWeekRange(weekRange: WeekRange) {
const start = parseISO(weekRange.start);
// Start = end means there's just one lesson
if (weekRange.start === weekRange.end) return format(start, lessonDateFormat);
Function must_be_in
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public must_be_in(): Must_be_inContext {
let _localctx: Must_be_inContext = new Must_be_inContext(this._ctx, this.state);
this.enterRule(_localctx, 40, NusModsParser.RULE_must_be_in);
let _la: number;
try {
Function must_not_be_in
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public must_not_be_in(): Must_not_be_inContext {
let _localctx: Must_not_be_inContext = new Must_not_be_inContext(this._ctx, this.state);
this.enterRule(_localctx, 42, NusModsParser.RULE_must_not_be_in);
let _la: number;
try {
Function boolean_expr
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
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 {
Function iterateBoard
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
Open
function iterateBoard(
board: Board,
iterator: (tile: Square, col: number, row: number) => boolean | void,
) {
let continueIterating = 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 requests
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export default function requests(state: Requests = {}, action: FSA): Requests {
const { meta } = action;
// requestStatus is a field specially designed and owned by api request actions
if (!meta || !meta.requestStatus || !meta[API_REQUEST]) {
Function downloadBusStops
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
async function downloadBusStops() {
const busStopResponse = await axios.get(getBusStop);
const data = busStopResponse.data.BusStopsResult.busstops;
// Map bus stops to the correct shape
Function special
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public special(): SpecialContext {
let _localctx: SpecialContext = new SpecialContext(this._ctx, this.state);
this.enterRule(_localctx, 28, NusModsParser.RULE_special);
try {
this.enterOuterAlt(_localctx, 1);
Function run
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
async run() {
try {
const [departments, faculties] = await Promise.all([
this.api.getDepartment(),
this.api.getFaculty(),