digitalfabrik/integreat-app

View on GitHub

Showing 193 of 194 total issues

Function render has 75 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  render(): ReactElement | null {
    const { uri } = this.props
    const { imageDimensions, viewDimensions, interactive } = this.state

    if (!imageDimensions || !viewDimensions) {
Severity: Major
Found in native/src/components/PinchPanImage.tsx - About 3 hrs to fix

    Function InfiniteScrollList has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

    const InfiniteScrollList = <T,>({
      loadPage,
      noItemsMessage,
      renderItem,
      defaultPage,
    Severity: Minor
    Found in web/src/components/InfiniteScrollList.tsx - About 2 hrs 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

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

        if (requestOptions.method === 'POST' && typeof requestOptions.body === 'string') {
          stringifiedFormData = ` and the body ${requestOptions.body}`
        } else if (requestOptions.method === 'POST') {
          stringifiedFormData = ` and the formData ${JSON.stringify(requestOptions.body)}`
        }
    Severity: Major
    Found in shared/api/errors/ResponseError.ts and 1 other location - About 2 hrs to fix
    shared/api/errors/FetchError.ts on lines 37..41

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 93.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

        if (requestOptions.method === 'POST' && typeof requestOptions.body === 'string') {
          stringifiedFormData = ` and the body ${requestOptions.body}`
        } else if (requestOptions.method === 'POST') {
          stringifiedFormData = ` and the formData ${JSON.stringify(requestOptions.body)}`
        }
    Severity: Major
    Found in shared/api/errors/FetchError.ts and 1 other location - About 2 hrs to fix
    shared/api/errors/ResponseError.ts on lines 37..41

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 93.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

    const walkDir = (dir: string, callback: (filePath: string) => void): void => {
      fs.readdirSync(dir).forEach(f => {
        const filePath = path.join(dir, f)
        const isDirectory = fs.statSync(filePath).isDirectory()
        if (isDirectory) {
    Severity: Major
    Found in native/jest.setup.ts and 1 other location - About 2 hrs to fix
    web/jest.setup.ts on lines 13..23

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 93.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

    const walkDir = (dir: string, callback: (dir: string) => void) => {
      fs.readdirSync(dir).forEach(f => {
        const filePath = path.join(dir, f)
        const isDirectory = fs.statSync(filePath).isDirectory()
        if (isDirectory) {
    Severity: Major
    Found in web/jest.setup.ts and 1 other location - About 2 hrs to fix
    native/jest.setup.ts on lines 27..37

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 93.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Function MalteHelpForm has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Confirmed

    const MalteHelpForm = ({ pageTitle, languageCode, cityCode, helpButtonOffer }: MalteHelpFormProps): ReactElement => {
      const { t } = useTranslation('malteHelpForm')
      const [sendingStatus, setSendingStatus] = useState<SendingStatusType>('idle')
      const [submitted, setSubmitted] = useState(false)
      const [contactChannel, setContactChannel] = useState<ContactChannel>('email')
    Severity: Minor
    Found in web/src/components/MalteHelpForm.tsx - About 2 hrs 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 SwitchCmsUrlIcon has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

    const SwitchCmsUrlIcon = ({ clearResourcesAndCache }: LandingIconProps): ReactElement => {
      const [clickCount, setClickCount] = useState(0)
      const [clickStart, setClickStart] = useState<null | DateTime>(null)
      const { settings, updateSettings } = useAppContext()
      const { cmsUrl, switchCmsUrl } = buildConfig()
    Severity: Minor
    Found in native/src/components/SwitchCmsUrlIcon.tsx - About 2 hrs 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 Pois has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

    const Pois = ({ pois: allPois, userLocation, city, languageCode, pageTitle }: PoiProps): ReactElement | null => {
      const [currentlyOpenFilter, setCurrentlyOpenFilter] = useState(false)
      const [showFilterSelection, setShowFilterSelection] = useState(false)
      const [queryParams, setQueryParams] = useSearchParams()
      const { multipoi, poiCategoryId, zoom } = parseQueryParams(queryParams)
    Severity: Minor
    Found in web/src/components/Pois.tsx - About 2 hrs 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 getNavigationItems has 62 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
        const isOffersVisible = offersEnabled
    Severity: Major
    Found in web/src/components/CityContentHeader.tsx - About 2 hrs to fix

      File PinchPanImage.tsx has 269 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import React, { ReactElement } from 'react'
      import { Animated, Image, ImageErrorEventData, NativeSyntheticEvent } from 'react-native'
      import {
        PanGestureHandler,
        PinchGestureHandler,
      Severity: Minor
      Found in native/src/components/PinchPanImage.tsx - About 2 hrs to fix

        Identical blocks of code found in 2 locations. Consider refactoring.
        Open

        walkDir(mocksPath, name => {
          mockPathEndings.forEach(ending => {
            if (name.endsWith(ending)) {
              jest.unmock(name.substring(mocksPath.length, name.length - ending.length))
            }
        Severity: Major
        Found in web/jest.setup.ts and 1 other location - About 2 hrs to fix
        native/jest.setup.ts on lines 44..50

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 84.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Identical blocks of code found in 2 locations. Consider refactoring.
        Open

        walkDir(mocksPath, name => {
          mockPathEndings.forEach(ending => {
            if (name.endsWith(ending)) {
              jest.unmock(name.substring(mocksPath.length, name.length - ending.length))
            }
        Severity: Major
        Found in native/jest.setup.ts and 1 other location - About 2 hrs to fix
        web/jest.setup.ts on lines 29..35

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 84.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Function CityContentHeader has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

        const CityContentHeader = ({
          cityModel,
          languageCode,
          languageChangePaths,
          route,
        Severity: Minor
        Found in web/src/components/CityContentHeader.tsx - About 2 hrs 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 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 })
        Severity: Minor
        Found in web/src/CityContentSwitcher.tsx - About 2 hrs 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 _addChildren has 59 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] = {}
        Severity: Major
        Found in shared/api/endpoints/testing/CategoriesMapModelBuilder.ts - About 2 hrs to fix

          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 &&
          Severity: Major
          Found in shared/api/endpoints/createTrackingEndpoint.ts - About 2 hrs to fix

            Function buildAll has 58 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              buildAll(): {
                path: string
                event: EventModel
                resources: PageResourceCacheStateType
              }[] {
            Severity: Major
            Found in shared/api/endpoints/testing/EventModelBuilder.ts - About 2 hrs to fix

              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,
              Severity: Minor
              Found in native/src/hooks/useNavigate.ts - About 2 hrs 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 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> }> => {
              Severity: Minor
              Found in web/src/utils/retryImport.ts - About 2 hrs 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