Showing 212 of 556 total issues
File NusModsParser.ts
has 1870 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
// Generated from src/services/requisite-tree/antlr4/NusMods.g4 by ANTLR 4.9.0-SNAPSHOT
import { ATN } from "antlr4ts/atn/ATN";
import { ATNDeserializer } from "antlr4ts/atn/ATNDeserializer";
File GetSemesterTimetable.test.ts
has 1661 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import CS4238Timetable from './fixtures/api-timetable/CS4238.json';
import MA2213Timetable from './fixtures/api-timetable/MA2213.json';
import CS2100Timetable from './fixtures/api-timetable/CS2100_2.json';
import CN4205ETimetable from './fixtures/api-timetable/CN4205E.json';
import CS1010XTimetable from './fixtures/api-timetable/CS1010X.json';
File CollateVenues.test.ts
has 586 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import GET1025 from './fixtures/nusmods-timetable/GET1025.json';
import GEK2041 from './fixtures/nusmods-timetable/GEK2041.json';
import PX2108 from './fixtures/nusmods-timetable/PX2108.json';
import CollateVenues, { extractVenueAvailability } from './CollateVenues';
File timetables.test.ts
has 570 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import NUSModerator from 'nusmoderator';
import _ from 'lodash';
import { parseISO } from 'date-fns';
import {
ColoredLesson,
File parseString.test.ts
has 543 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import parseString from './parseString';
import { mockLogger } from '../../utils/test-utils';
import { PrereqTree } from '../../types/modules';
/* eslint-disable max-len */
Function PlannerModule
has 165 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const PlannerModule = memo<Props>((props) => {
const [isEditingPlaceholder, setEditingPlaceholder] = useState(false);
const removeModule = () => props.removeModule(props.id);
File NusModsLexer.ts
has 413 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
// Generated from src/services/requisite-tree/antlr4/NusMods.g4 by ANTLR 4.9.0-SNAPSHOT
import { ATN } from "antlr4ts/atn/ATN";
import { ATNDeserializer } from "antlr4ts/atn/ATNDeserializer";
File planner.test.ts
has 409 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import { clone } from 'lodash';
import { getAcadYearModules, getPrereqModuleCode } from 'selectors/planner';
import { PlannerState } from 'types/reducers';
import { ModuleCode } from 'types/modules';
File timetables.ts
has 392 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import { AcadWeekInfo } from 'nusmoderator';
import {
castArray,
difference,
each,
Function ModuleFinderSidebar
has 135 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const ModuleFinderSidebar: React.FC = () => {
const [isMenuOpen, setMenuOpen] = useState(false);
const getSemesterTimetable = useSelector(getSemesterTimetableLessons);
const allModules = useSelector((state: StoreState) => state.moduleBank.modules);
Function MpeContainer
has 123 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const MpeContainer: React.FC = () => {
const [isGettingSSOLink, setIsGettingSSOLink] = useState(false);
const [isModalOpen, setIsModalOpen] = useState(false);
const [isLoggedIn, setIsLoggedIn] = useState(getLoginState(useLocation(), useHistory()));
Function KeyboardShortcuts
has 118 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const KeyboardShortcuts: React.FC = () => {
const [helpShown, setHelpShown] = useState(false);
const colorScheme = useColorScheme();
const closeModal = useCallback(() => setHelpShown(false), []);
Function scraper
has 101 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
async function scraper() {
const getDepartmentsResponse = await axios.post<ApiResponse<GetDepartmentsResponseData[]>>(
`${baseUrl}/config/get-acadorg`,
{
eff_status: 'A',
Function TimetableModulesTableComponent
has 100 lines of code (exceeds 25 allowed). Consider refactoring. Open
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;
File GlobalSearchContainer.test.tsx
has 327 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import { render } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { Provider } from 'react-redux';
import { MemoryRouter } from 'react-router-dom';
import produce from 'immer';
File TodayContainer.test.tsx
has 323 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import { flatten, size } from 'lodash';
import { shallow } from 'enzyme';
import * as weather from 'apis/weather';
import { waitFor } from 'test-utils/async';
NusModsParser
has 30 functions (exceeds 20 allowed). Consider refactoring. Open
Open
export class NusModsParser extends Parser {
public static readonly COMMA = 1;
public static readonly LPAREN = 2;
public static readonly RPAREN = 3;
public static readonly IF_IN = 4;
Function scraper
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
Open
async function scraper() {
const getDepartmentsResponse = await axios.post<ApiResponse<GetDepartmentsResponseData[]>>(
`${baseUrl}/config/get-acadorg`,
{
eff_status: 'A',
- 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
File ModulePageContent.tsx
has 314 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import { memo, useState } from 'react';
import classnames from 'classnames';
import ScrollSpy from 'react-scrollspy';
import { kebabCase, map, mapValues, values, sortBy } from 'lodash';
Function primitive
has 82 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public primitive(): PrimitiveContext {
let _localctx: PrimitiveContext = new PrimitiveContext(this._ctx, this.state);
this.enterRule(_localctx, 12, NusModsParser.RULE_primitive);
try {
this.state = 104;