Showing 212 of 556 total issues
Function theme
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
function theme(state: ThemeState = defaultThemeState, action: Actions): ThemeState {
function setTheme(newTheme: string): ThemeState {
// Update theme analytics info
withTracker((tracker) => tracker.setCustomDimension(DIMENSIONS.theme, newTheme));
Function walkTree
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
function walkTree(fragment: PrereqTree): PrereqTree[] {
if (typeof fragment === 'string') {
// Parse a module code requirement as an nOf fragment.
return walkTree({ nOf: [1, [fragment]] });
}
Function formatNumericWeeks
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function formatNumericWeeks(unprocessedWeeks: NumericWeeks): string | null {
// Ensure list of weeks are unique
const weeks = unprocessedWeeks.filter(
(value, index) => unprocessedWeeks.indexOf(value) === index,
);
Function authenticate
has 29 lines of code (exceeds 25 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);
}
Function make
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
function make(props: Partial<Props> = {}) {
const selectModuleColor = jest.fn();
const onRemoveModule = jest.fn();
const hideLessonInTimetable = jest.fn();
const showLessonInTimetable = jest.fn();
Function getVersionMapping
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
function getVersionMapping(browserCode, versionString) {
const versions = _.get(browserslist, ['data', browserCode, 'versions']);
if (!versions) {
return undefined;
}
Function callApi
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function callApi<Data>(endpoint: string, params: ApiParams): Promise<Data> {
// 1. Construct request URL
const url = new URL(endpoint, config.baseUrl);
let response;
Function calculateWeekRange
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function calculateWeekRange(
lesson: RawLesson,
_semester: Semester,
weekRange: WeekRange,
): EventOption {
Function registerServiceWorker
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
export default function registerServiceWorker(store: Store<any, any>) {
const { serviceWorker } = navigator;
if (!serviceWorker) {
return;
}
Function mapAttributes
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function mapAttributes(
attributes: ModuleAttributeEntry[],
logger: Logger,
): NUSModuleAttributes | undefined {
const nusAttributes: NUSModuleAttributes = {};
Function downloadIssues
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function downloadIssues() {
// eslint-disable-next-line import/no-dynamic-require, global-require
let venues = require(VENUES_PATH);
const res = await axios.get(ISSUES_URL, {
Function DayHeader
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
const DayHeader: React.FC<Props> = (props) => {
const { forecast } = props;
const Icon = forecast ? getWeatherIcon(forecast) : null;
const dates = castArray(props.date);
Function BeforeLessonCard
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
const BeforeLessonCard: React.FC<Props> = (props) => {
const { nextLesson, currentTime, marker } = props;
const nextLessonDate = getStartTimeAsDate(nextLesson);
const hoursTillNextLesson = differenceInHours(nextLessonDate, props.currentTime);
Function getVersionMapping
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
function getVersionMapping(browserCode, versionString) {
const versions = _.get(browserslist, ['data', browserCode, 'versions']);
if (!versions) {
return undefined;
}
- 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 ModulesSelect
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
const ModulesSelect: FC<Props> = ({
moduleCount,
placeholder,
disabled,
getFilteredModules,
- 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 push
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
push(path: string | LocationDescriptorObject, state?: HistoryLocationState) {
// Do not navigate if the path object matches
const nextPath = typeof path === 'string' ? path : createPath(path);
if (nextPath === createPath(this.history.location)) return;
- 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 GlobalSearchContainer
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
const GlobalSearchContainer: FC = () => {
const dispatch = useDispatch();
useEffect(() => {
dispatch(fetchVenueList());
}, [dispatch]);
- 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 computeUndoStacks
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
export function computeUndoStacks<T extends { undoHistory: UndoHistoryState<T> }>(
state: UndoHistoryState<T> = {
past: [],
present: undefined, // Don't pretend to know the present
future: [],
- 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 formatNumericWeeks
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
export function formatNumericWeeks(unprocessedWeeks: NumericWeeks): string | null {
// Ensure list of weeks are unique
const weeks = unprocessedWeeks.filter(
(value, index) => unprocessedWeeks.indexOf(value) === index,
);
- 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 conflictToText
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
export function conflictToText(rootConflict: PrereqTree): string {
function walkSubtree(conflict: PrereqTree): string {
const text = walkTree(conflict);
if (typeof conflict === 'string') return text;
return `(${text})`;
- 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"