Showing 212 of 556 total issues
Function setItem
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
function setItem(key: string, value: unknown) {
try {
getLocalStorage().setItem(key, isString(value) ? value : JSON.stringify(value));
} catch (e) {
// Calculate used size and attach it to the error report. This is diagnostics
- 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 getWeatherIcon
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
export default function getWeatherIcon(description: string) {
const cleanedDesc = description.toLowerCase().replace(/[^a-z ]+/g, '');
// Fair (Day), Fair (Night), Fair & Warm
if (cleanedDesc.includes('fair')) {
- 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 CustomModuleFormComponent
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
export const CustomModuleFormComponent: React.FC<Props> = (props) => {
// We use an uncontrolled form here because we don't want to update the
// module title and MCs live
const inputModuleCredit = React.createRef<HTMLInputElement>();
const inputTitle = React.createRef<HTMLInputElement>();
- 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 combineModules
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
export function combineModules(
semesters: SemesterModuleData[][],
aliases: { [moduleCode: string]: ModuleCode[] },
logger: Logger,
): ModuleWithoutTree[] {
- 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 MpeContainer
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
const MpeContainer: React.FC = () => {
const [isGettingSSOLink, setIsGettingSSOLink] = useState(false);
const [isModalOpen, setIsModalOpen] = useState(false);
const [isLoggedIn, setIsLoggedIn] = useState(getLoginState(useLocation(), useHistory()));
- 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 app
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
function app(state: AppState = defaultAppState(), action: Actions): AppState {
switch (action.type) {
case SELECT_SEMESTER:
return {
...state,
- 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 renderPlaceholderForm
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
const renderPlaceholderForm = () => {
const { placeholder, moduleCode, moduleTitle, semester } = props;
if (!placeholder) return null;
Function programs_values
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
public programs_values(): Programs_valuesContext {
let _localctx: Programs_valuesContext = new Programs_valuesContext(this._ctx, this.state);
this.enterRule(_localctx, 18, NusModsParser.RULE_programs_values);
let _la: number;
try {
Function course_items
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
public course_items(): Course_itemsContext {
let _localctx: Course_itemsContext = new Course_itemsContext(this._ctx, this.state);
this.enterRule(_localctx, 38, NusModsParser.RULE_course_items);
let _la: number;
try {
Function renderModuleActions
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
const renderModuleActions = (module: ModuleWithColor) => {
const hideBtnLabel = `${module.hiddenInTimetable ? 'Show' : 'Hide'} ${module.moduleCode}`;
const removeBtnLabel = `Remove ${module.moduleCode} from timetable`;
const { semester } = props;
Function requestMiddleware
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
() => (next) => (action) => {
if (!action.meta || !action.meta[API_REQUEST]) {
// Non-api request action
return next(action);
}
Function plan_types
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
public plan_types(): Plan_typesContext {
let _localctx: Plan_typesContext = new Plan_typesContext(this._ctx, this.state);
this.enterRule(_localctx, 20, NusModsParser.RULE_plan_types);
let _la: number;
try {
Function programs
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
public programs(): ProgramsContext {
let _localctx: ProgramsContext = new ProgramsContext(this._ctx, this.state);
this.enterRule(_localctx, 14, NusModsParser.RULE_programs);
let _la: number;
try {
Function run
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
async run(input: Input) {
this.logger.info(`Getting modules for ${this.academicYear} semester ${this.semester}`);
const term = getTermCode(this.semester, this.academicYear);
Function makeExportHandler
has 38 lines of code (exceeds 25 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) {
Function TimetableRow
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
const TimetableRow: React.FC<Props> = (props) => {
const { startingIndex, endingIndex, lessons, onModifyCell, verticalMode } = props;
const totalCols = endingIndex - startingIndex;
let lastStartIndex = startingIndex;
Function BetaToggle
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
const BetaToggle = memo<Props>((props) => {
const { betaTester, toggleStates } = props;
const hasTests = currentTests.length > 0;
// If the user isn't a beta tester already and there are no tests, then
Function binop
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
public binop(): BinopContext {
let _localctx: BinopContext = new BinopContext(this._ctx, this.state);
this.enterRule(_localctx, 6, NusModsParser.RULE_binop);
try {
this.state = 84;
Function GlobalSearchContainer
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
const GlobalSearchContainer: FC = () => {
const dispatch = useDispatch();
useEffect(() => {
dispatch(fetchVenueList());
}, [dispatch]);
Function subject_years
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
public subject_years(): Subject_yearsContext {
let _localctx: Subject_yearsContext = new Subject_yearsContext(this._ctx, this.state);
this.enterRule(_localctx, 26, NusModsParser.RULE_subject_years);
let _la: number;
try {