digitalfabrik/integreat-app

View on GitHub

Showing 156 of 190 total issues

Function Navigator has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

const Navigator = (): ReactElement | null => {
  const showSnackbar = useSnackbar()
  const { settings, cityCode, changeCityCode, languageCode, updateSettings } = useAppContext()
  const navigation = useNavigation<NavigationProps<RoutesType>>()
  const [initialRoute, setInitialRoute] = useState<InitialRouteType>(null)
Severity: Minor
Found in native/src/Navigator.tsx - About 45 mins 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 openExternalUrl has a Cognitive Complexity of 8 (exceeds 5 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 45 mins 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 writeJsonFromCsv has a Cognitive Complexity of 8 (exceeds 5 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 45 mins 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 SearchPage has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

const SearchPage = ({ city, cityCode, languageCode, pathname }: CityRouteProps): ReactElement | null => {
  const query = new URLSearchParams(useLocation().search).get('query') ?? ''
  const [filterText, setFilterText] = useState<string>(query)
  const { t } = useTranslation('search')
  const navigate = useNavigate()
Severity: Minor
Found in web/src/routes/SearchPage.tsx - About 45 mins 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 PoisMobile has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

const PoisMobile = ({
  toolbar,
  data,
  userLocation,
  slug,
Severity: Minor
Found in web/src/components/PoisMobile.tsx - About 45 mins 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 getExcerpt has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

const getExcerpt = (text: string, { query, maxChars, replaceLineBreaks }: ExcerptOptions): string => {
  const normalizedText = normalizeString(text)

  if (!query) {
    return truncate(text, { maxChars, replaceLineBreaks })
Severity: Minor
Found in shared/utils/getExcerpt.ts - About 45 mins 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 RootSwitcher has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

const RootSwitcher = ({ setContentLanguage }: RootSwitcherProps): ReactElement => {
  const { i18n } = useTranslation()
  const { fixedCity, cityNotCooperating, jpalTracking } = buildConfig().featureFlags
  const { routeParam0, routeParam1, '*': splat } = useMatch('/:routeParam0/:routeParam1/*')?.params ?? {}
  useScrollToTop()
Severity: Minor
Found in web/src/RootSwitcher.tsx - About 45 mins 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

Consider simplifying this complex logical expression.
Open

  if (!category || !parents || !categories) {
    // This adds support for the old paths of categories by redirecting to the new path
    // The children endpoint always returns the category with the new path at the first position in the response
    const newSlugCategory = categories?.[0]
    if (newSlugCategory) {
Severity: Major
Found in web/src/routes/CategoriesPage.tsx - About 40 mins to fix

    Function FailureSwitcher has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    const FailureSwitcher = ({ error }: FailureSwitcherProps): ReactElement => {
      const { t } = useTranslation('error')
    
      useEffect(() => {
        reportError(error)
    Severity: Minor
    Found in web/src/components/FailureSwitcher.tsx - About 35 mins 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 getFeedbackType has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    const getFeedbackType = (routeType: FeedbackRouteType, slug?: string): FeedbackType => {
      switch (routeType) {
        case EVENTS_ROUTE:
          return slug ? FeedbackType.event : FeedbackType.events
    
    
    Severity: Minor
    Found in shared/api/endpoints/createFeedbackEndpoint.ts - About 35 mins 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 formatNotes has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    const formatNotes = (params: {
      notes: NoteType[]
      language: string
      production: boolean
      platformName?: string
    Severity: Minor
    Found in tools/manage-metadata.ts - About 35 mins 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 TuNewsDetailPage has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    const TuNewsDetailPage = ({ city, pathname, cityCode, languageCode }: CityRouteProps): ReactElement | null => {
      // This component is only opened when there is a news ID in the route
      // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
      const newsId = useParams().newsId!
      const navigate = useNavigate()
    Severity: Minor
    Found in web/src/routes/TuNewsDetailPage.tsx - About 35 mins 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 loadBuildConfigAsKeyValue has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    const loadBuildConfigAsKeyValue = (buildConfigName: string, platform: PlatformType, spaces = true, quotes = false) => {
      const buildConfig = loadBuildConfig(buildConfigName, platform)
      if (!buildConfig) {
        throw Error(`No build config with the name ${buildConfigName} and the platform ${platform} found`)
      }
    Severity: Minor
    Found in build-configs/tools/manage.ts - About 35 mins 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 createSettingsSections has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    const createSettingsSections = ({
      setSetting,
      t,
      languageCode,
      cityCode,
    Severity: Minor
    Found in native/src/utils/createSettingsSections.ts - About 35 mins 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 loadResourceCache has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    const loadResourceCache = async ({
      cityCode,
      languageCode,
      categories,
      events,
    Severity: Minor
    Found in native/src/utils/loadResourceCache.ts - About 35 mins 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 CategoriesContainer has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    const CategoriesContainer = ({ navigation, route }: CategoriesContainerProps): ReactElement => {
      const { cityCode, languageCode } = useCityAppContext()
      const deviceWidth = useWindowDimensions().width
      const resourceCache = useResourceCache({ cityCode, languageCode })
      const { navigateTo } = useNavigate()
    Severity: Minor
    Found in native/src/routes/CategoriesContainer.tsx - About 35 mins 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 MalteHelpFormOffer has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    const MalteHelpFormOffer = ({
      categoryPageTitle,
      url,
      cityCode,
      malteHelpFormOffer,
    Severity: Minor
    Found in native/src/components/MalteHelpFormOffer.tsx - About 35 mins 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 ChatController has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    const ChatController = ({ city, language }: ChatControllerProps): ReactElement => {
      const [sendingStatus, setSendingStatus] = useState<SendingStatusType>('idle')
      const { value: deviceId } = useLocalStorage({
        key: `${LOCAL_STORAGE_ITEM_CHAT_MESSAGES}-${city}`,
        initialValue: window.crypto.randomUUID(),
    Severity: Minor
    Found in web/src/components/ChatController.tsx - About 35 mins 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 NavigationBarScrollContainer has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    const NavigationBarScrollContainer = ({ children, activeIndex }: NavigationBarScrollContainerProps): ReactElement => {
      const { width } = useWindowDimensions()
      const [scrollPosition, setScrollPosition] = useState<number>(0)
      const scrollToActiveItem = useCallback(
        (ref: RefObject<HTMLDivElement>) => {
    Severity: Minor
    Found in web/src/components/NavigationBarScrollContainer.tsx - About 35 mins 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

    Avoid too many return statements within this function.
    Open

      return constructPathname([LANDING_ROUTE, routeInformation.languageCode])
    Severity: Major
    Found in shared/routes/pathname.ts - About 30 mins to fix
      Severity
      Category
      Status
      Source
      Language