digitalfabrik/integreat-app

View on GitHub

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 }

Severity: Minor
Found in web/src/components/FailureSwitcher.tsx - About 1 hr to fix

    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,
    Severity: Minor
    Found in native/src/utils/DatabaseConnector.ts - About 1 hr to fix

      Function MapView has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

        (
          {
            features,
            selectFeature,
            changeSnapPoint,
      Severity: Minor
      Found in web/src/components/MapView.tsx - About 1 hr to fix

      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()
      Severity: Minor
      Found in web/src/routes/LocalNewsPage.tsx - About 1 hr to fix

      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,
      Severity: Minor
      Found in native/src/utils/DatabaseConnector.ts - About 1 hr to fix

        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()
        Severity: Minor
        Found in native/src/components/PinchPanImage.tsx - About 1 hr to fix

          Function CityContentLayout has 37 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          const CityContentLayout = (props: CityContentLayoutProps): ReactElement => {
            const { viewportSmall } = useWindowDimensions()
          
            const {
              children,
          Severity: Minor
          Found in web/src/components/CityContentLayout.tsx - About 1 hr to fix

            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
            Severity: Minor
            Found in native/src/components/ExportEventButton.tsx - About 1 hr to fix

              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)
              
              
              Severity: Minor
              Found in native/src/utils/openExternalUrl.ts - About 1 hr to fix

                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)
                Severity: Minor
                Found in web/src/components/MalteHelpForm.tsx - About 1 hr to fix

                  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 }
                  
                  
                  Severity: Minor
                  Found in native/src/hooks/useLoadCityContent.ts - About 1 hr to fix

                  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)
                  
                  
                  Severity: Minor
                  Found in web/src/utils/BrowserLanguageDetector.ts - About 1 hr to fix

                  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,
                  Severity: Minor
                  Found in web/src/components/PoisDesktop.tsx - About 1 hr to fix

                  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,
                  Severity: Minor
                  Found in native/src/hooks/useNavigateToLink.ts - About 1 hr to fix

                    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(
                    Severity: Minor
                    Found in native/src/utils/DatabaseConnector.ts - About 1 hr to fix

                      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
                      Severity: Minor
                      Found in web/src/components/JsonLdEvent.tsx - About 1 hr to fix

                        Function fixBounds has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          private fixBounds(
                            viewWidth: number,
                            viewHeight: number,
                            realImageWidth: number,
                            realImageHeight: number,
                        Severity: Minor
                        Found in native/src/components/PinchPanImage.tsx - About 1 hr to fix

                          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
                          
                          
                          Severity: Minor
                          Found in native/src/routes/Consent.tsx - About 1 hr to fix

                            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
                            Severity: Minor
                            Found in shared/routes/pathname.ts - About 1 hr to fix

                            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 &&
                            Severity: Minor
                            Found in shared/api/endpoints/createTrackingEndpoint.ts - About 1 hr to fix

                            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

                            Severity
                            Category
                            Status
                            Source
                            Language