Showing 189 of 190 total issues
Function getFailureProps
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
const getFailureProps = (error: Error): { goToPath?: string; goToMessage?: string; errorMessage: string } => {
if (error instanceof NotFoundError && error.city !== undefined && error.language !== undefined) {
const { city, language } = error
const params = { cityCode: city, languageCode: language }
Function storeEvents
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
async storeEvents(events: Array<EventModel>, context: DatabaseContext): Promise<void> {
const jsonModels = events.map(
(event: EventModel): ContentEventJsonType => ({
path: event.path,
title: event.title,
Function MapView
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
(
{
features,
selectFeature,
changeSnapPoint,
- 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 LocalNewsPage
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
const LocalNewsPage = ({ city, pathname, languageCode, cityCode }: CityRouteProps): ReactElement | null => {
const previousPathname = usePreviousProp({ prop: pathname })
const { newsId } = useParams()
const { t } = useTranslation('news')
const navigate = useNavigate()
- 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 mapEventsJson
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
json.map(jsonObject => {
const jsonDate = jsonObject.date
return new EventModel({
path: jsonObject.path,
title: jsonObject.title,
Function constructor
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
constructor(props: PinchPanImageProps) {
super(props)
this.state = { interactive: true }
this.pinchHandler = React.createRef()
Function CityContentLayout
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
const CityContentLayout = (props: CityContentLayoutProps): ReactElement => {
const { viewportSmall } = useWindowDimensions()
const {
children,
Function exportEventToCalendar
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
const exportEventToCalendar = async (calendarId: string, exportAll: boolean): Promise<void> => {
// Luxon ISO dates have the time zone offset but Android calendar needs them in UTC
let startDate = event.date.startDate.toUTC().toISO()
let endDate = event.date.endDate.toUTC().toISO()
const allDay = event.date.allDay
Function openExternalUrl
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
const openExternalUrl = async (rawUrl: string, showSnackbar: (snackbar: SnackbarType) => void): Promise<void> => {
const encodedUrl = encodeURI(rawUrl)
const { protocol } = new URL(encodedUrl)
const internalLinkRegexp = new RegExp(buildConfig().internalLinksHijackPattern)
Function submitHandler
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
const submitHandler = async (event: SyntheticEvent<HTMLFormElement>) => {
const form = event.currentTarget
if (!form.checkValidity()) {
event.stopPropagation()
scrollToFirstError(form)
Function useLoadCityContent
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
const useLoadCityContent = ({ cityCode, languageCode, refreshLocalNews }: Params): CityContentReturn => {
const showSnackbar = useSnackbar()
const previousLanguageCode = usePreviousProp({ prop: languageCode })
const params = { cityCode, languageCode, showSnackbar }
- 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 detect
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
detect: () => {
const bcp47Tags: string[] = []
const localStorageLanguage = safeLocalStorage.getItem(I18N_LANGUAGE_KEY)
- 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 PoisDesktop
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
const PoisDesktop = ({
panelHeights,
toolbar,
data,
userLocation,
- 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 navigateToLink
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
const navigateToLink = <T extends RoutesType>(
url: string,
navigation: NavigationProps<T>,
languageCode: string,
navigateTo: (routeInformation: RouteInformationType) => void,
Function loadCategories
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
async loadCategories(context: DatabaseContext): Promise<CategoriesMapModel> {
const path = this.getContentPath('categories', context)
const mapCategoriesJson = (json: ContentCategoryJsonType[]) =>
new CategoriesMapModel(
json.map(
Function createJsonLd
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
export const createJsonLd = (event: EventModel): WithContext<Event> | null => {
if (!event.location) {
return null
}
const date = event.date
Function fixBounds
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
private fixBounds(
viewWidth: number,
viewHeight: number,
realImageWidth: number,
realImageHeight: number,
Function Consent
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
const Consent = (): ReactElement | null => {
const { settings, updateSettings } = useAppContext()
const { t } = useTranslation('consent')
const { externalSourcePermissions } = settings
Function pathnameFromRouteInformation
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
export const pathnameFromRouteInformation = (routeInformation: NonNullableRouteInformationType): string => {
if (
routeInformation.route === JPAL_TRACKING_ROUTE ||
routeInformation.route === LICENSES_ROUTE ||
routeInformation.route === CONSENT_ROUTE
- 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 createTrackingEndpoint
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
const createTrackingEndpoint = (url: string = JPAL_TRACKING_ENDPOINT_URL): TrackingEndpointType => {
const request = async (signal: SignalType) => {
const pageType = signal.name === OPEN_PAGE_SIGNAL_NAME ? signal.pageType : undefined
const signalUrl =
signal.name !== SEND_FEEDBACK_SIGNAL_NAME &&
- 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"