digitalfabrik/integreat-app

View on GitHub

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 })
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 buildAll has 60 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 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 _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] = {}
      Severity: Major
      Found in shared/api/endpoints/testing/CategoriesMapModelBuilder.ts - About 2 hrs to fix

        Function navigateToDeepLink has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

        const navigateToDeepLink = <T extends RoutesType>({
          url,
          navigation,
          navigateTo,
          showSnackbar,
        Severity: Minor
        Found in native/src/hooks/useNavigateToDeepLink.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 MapView has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

        const MapView = ({
          boundingBox,
          features,
          selectedFeature,
          iconPosition,
        Severity: Minor
        Found in native/src/components/MapView.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 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)
        Severity: Minor
        Found in native/src/hooks/useLoadTuNews.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 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

        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()
        Severity: Major
        Found in web/src/components/MobileBanner.tsx - About 2 hrs to fix

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

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

                Function CityContentHeader has a Cognitive Complexity of 16 (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 LoadingErrorHandler has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                Open

                const LoadingErrorHandler = ({
                  children,
                  loading,
                  refresh,
                  error,
                Severity: Minor
                Found in native/src/routes/LoadingErrorHandler.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 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
                Severity: Major
                Found in native/src/utils/DatabaseConnector.ts - About 2 hrs to fix

                  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
                  
                  
                  Severity: Minor
                  Found in web/src/components/CityContentHeader.tsx - About 2 hrs to fix

                    Function CityContentToolbar has 50 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    const CityContentToolbar = (props: CityContentToolbarProps) => {
                      const { viewportSmall } = useWindowDimensions()
                      const {
                        feedbackTarget,
                        children,
                    Severity: Minor
                    Found in web/src/components/CityContentToolbar.tsx - About 2 hrs to fix

                      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
                          }
                      Severity: Minor
                      Found in translations/tools/manage.ts - About 1 hr to fix

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