Showing 156 of 190 total issues
Function storePois
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
async storePois(pois: Array<PoiModel>, context: DatabaseContext): Promise<void> {
const jsonModels = pois.map(
(poi: PoiModel): ContentPoiJsonType => ({
path: poi.path,
title: poi.title,
Function App
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
const App = (): ReactElement => {
const [routeIndex, setRouteIndex] = useState<number>(0)
useSendOfflineJpalSignals()
Function loadEvents
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
async loadEvents(context: DatabaseContext): Promise<Array<EventModel>> {
const path = this.getContentPath('events', context)
const mapEventsJson = (json: ContentEventJsonType[]) =>
json.map(jsonObject => {
const jsonDate = jsonObject.date
Function constructor
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
constructor() {
this._databaseConnector = new DatabaseConnector()
this.caches = {
pois: new Cache<Array<PoiModel>>(
this._databaseConnector,
Function AppContextProvider
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
const AppContextProvider = ({ children }: AppContextProviderProps): ReactElement | null => {
const [settings, setSettings] = useState<SettingsType | null>(null)
const cityCode = settings?.selectedCity
const languageCode = settings?.contentLanguage
const { i18n } = useTranslation()
- 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 EventsPage
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
const EventsPage = ({ city, pathname, languageCode, cityCode }: CityRouteProps): ReactElement | null => {
const previousPathname = usePreviousProp({ prop: pathname })
const { eventId } = useParams()
const { t } = useTranslation('events')
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 createConfig
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
const createConfig = (
env: {
config_name?: string
dev_server?: boolean
bundle_analyzer?: boolean
- 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 fetchAsync
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
func fetchAsync(sourceUrl: String, targetFilePath: String, collector: FetchResultCollector) {
let targetFileURL = URL(fileURLWithPath: targetFilePath)
let fileManager = FileManager.default
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"