Showing 156 of 190 total issues
Function CityContentSwitcher
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
const CityContentSwitcher = ({ languageCode }: CityContentSwitcherProps): ReactElement => {
// This component is only opened when there is a cityCode in the route
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const cityCode = useParams().cityCode!
const { data: city, error, loading } = useLoadFromEndpoint(createCityEndpoint, cmsApiBaseUrl, { city: cityCode })
- 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 buildAll
has 60 lines of code (exceeds 25 allowed). Consider refactoring. Open
buildAll(): {
path: string
event: EventModel
resources: PageResourceCacheStateType
}[] {
Function createTrackingEndpoint
has 59 lines of code (exceeds 25 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 &&
Function _addChildren
has 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
_addChildren(category: CategoryModel, depth: number): void {
this._categories.push(category)
if (depth === 0) {
this._resourceCache[category.path] = {}
Function navigateToDeepLink
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
const navigateToDeepLink = <T extends RoutesType>({
url,
navigation,
navigateTo,
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 MapView
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
const MapView = ({
boundingBox,
features,
selectedFeature,
iconPosition,
- 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 useLoadTuNews
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
const useLoadTuNews = ({ language }: ParamsType): TuNewsReturnType => {
const [page, setPage] = useState<number>(FIRST_PAGE_INDEX)
const [data, setData] = useState<TunewsModel[] | null>(null)
const [availableLanguages, setAvailableLanguages] = useState<LanguageModel[] | null>(null)
const [error, setError] = useState<Error | null>(null)
- 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 navigate
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
const navigate = <T extends RoutesType>(
routeInformation: RouteInformationType,
navigation: NavigationProps<T>,
appCityCode: string | null,
appLanguageCode: string,
- 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 retry
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
const retry = async <T>(
componentImport: () => Promise<{ default: ComponentType<T> }>,
retriesLeft = DEFAULT_RETRIES,
interval = DEFAULT_INTERVAL,
): Promise<{ default: ComponentType<T> }> => {
- 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 MobileBanner
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
export const MobileBanner = (): ReactElement | null => {
const { value, updateLocalStorageItem } = useLocalStorage<string | null>({ key: 'showBanner', initialValue: null })
const isVisible = !value || DateTime.fromISO(value).plus({ months: 3 }) < DateTime.now()
const [isInstalled] = useState<boolean>(false) // This is always false because we can't know if app is installed or not before running the deep-link
const { icons, appName, apps, hostName } = buildConfig()
Function request
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
async request(params: P, overrideUrl?: string): Promise<Payload<T>> {
if (this.errorOverride) {
throw this.errorOverride
}
Method fetchAsync
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
private fun fetchAsync(sourceUrl: String, targetFilePath: String, callback: FetchedCallback) {
val targetFile = File(targetFilePath)
if (targetFile.exists()) {
callback.alreadyExists(sourceUrl, targetFile)
return
Function request
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
const request = async (signal: SignalType) => {
const pageType = signal.name === OPEN_PAGE_SIGNAL_NAME ? signal.pageType : undefined
const signalUrl =
signal.name !== SEND_FEEDBACK_SIGNAL_NAME &&
signal.name !== RESUME_SIGNAL_NAME &&
Function CityContentHeader
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
const CityContentHeader = ({
cityModel,
languageCode,
languageChangePaths,
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 LoadingErrorHandler
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
const LoadingErrorHandler = ({
children,
loading,
refresh,
error,
- 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 loadPois
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
async loadPois(context: DatabaseContext): Promise<Array<PoiModel>> {
const path = this.getContentPath('pois', context)
const mapPoisJson = (json: ContentPoiJsonType[]) =>
json.map(jsonObject => {
const jsonLocation = jsonObject.location
Function getNavigationItems
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
const getNavigationItems = (): Array<ReactElement> => {
const isNewsVisible = buildConfig().featureFlags.newsStream && (localNewsEnabled || tunewsEnabled)
const isEventsVisible = eventsEnabled
const isPoisVisible = buildConfig().featureFlags.pois && poisEnabled
Function CityContentToolbar
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
const CityContentToolbar = (props: CityContentToolbarProps) => {
const { viewportSmall } = useWindowDimensions()
const {
feedbackTarget,
children,
Function writeJsonFromCsv
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
const writeJsonFromCsv = (translations: string, toPath: string, sourceLanguage: string) => {
fs.readdir(translations, (err, files) => {
if (err) {
throw err
}
Function mapPoisJson
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
json.map(jsonObject => {
const jsonLocation = jsonObject.location
return new PoiModel({
path: jsonObject.path,
title: jsonObject.title,