digitalfabrik/integreat-app

View on GitHub

Showing 189 of 190 total issues

Function loadWithCache has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

const loadWithCache = async ({
  showSnackbar,
  forceUpdate = false,
}: {
  forceUpdate?: boolean
Severity: Minor
Found in native/src/hooks/useLoadCities.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

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

  useEffect(() => {
    const layoutElement = document.getElementById(LAYOUT_ELEMENT_ID)
    layoutElement?.setAttribute('aria-hidden', 'true')

    return () => layoutElement?.setAttribute('aria-hidden', 'false')
Severity: Major
Found in web/src/components/ChatModal.tsx and 1 other location - About 1 hr to fix
web/src/components/Modal.tsx on lines 59..64

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 56.

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

  useEffect(() => {
    const layoutElement = document.getElementById(LAYOUT_ELEMENT_ID)
    layoutElement?.setAttribute('aria-hidden', 'true')

    return () => layoutElement?.setAttribute('aria-hidden', 'false')
Severity: Major
Found in web/src/components/Modal.tsx and 1 other location - About 1 hr to fix
web/src/components/ChatModal.tsx on lines 61..66

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 56.

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 writeMetadata has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const writeMetadata = (appName: string, storeName: string, overrideVersionName?: string) => {
  if (storeName !== 'appstore' && storeName !== 'playstore') {
    throw new Error(`Invalid store name ${storeName} passed!`)
  }

Severity: Minor
Found in tools/manage-metadata.ts - About 1 hr to fix

    Function onShare has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      const onShare = async () => {
        if (!shareUrl) {
          // The share option should only be shown if there is a shareUrl
          return
        }
    Severity: Minor
    Found in native/src/components/Header.tsx - About 1 hr to fix

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

      const useLoadFromEndpoint = <T extends object, P>(
        createEndpoint: (baseUrl: string) => Endpoint<P, T>,
        baseUrl: string | (() => Promise<string>),
        params: P,
      ): Return<T> =>
      Severity: Major
      Found in shared/api/endpoints/hooks/useLoadFromEndpoint.ts and 1 other location - About 1 hr to fix
      shared/api/endpoints/hooks/useLoadFromEndpoint.ts on lines 6..19

      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 55.

      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

      export const loadFromEndpoint = async <T extends object, P>(
        createEndpoint: (baseUrl: string) => Endpoint<P, T>,
        baseUrl: string | (() => Promise<string>),
        params: P,
      ): Promise<T> => {
      Severity: Major
      Found in shared/api/endpoints/hooks/useLoadFromEndpoint.ts and 1 other location - About 1 hr to fix
      shared/api/endpoints/hooks/useLoadFromEndpoint.ts on lines 21..33

      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 55.

      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 loadEvents has a Cognitive Complexity of 9 (exceeds 5 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
      Severity: Minor
      Found in native/src/utils/DatabaseConnector.ts - About 55 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 PoisPage has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

      const PoisPage = ({ cityCode, languageCode, city, pathname }: CityRouteProps): ReactElement | null => {
        const params = useParams()
        const slug = params.slug ? normalizePath(params.slug) : undefined
        const { t } = useTranslation('pois')
      
      
      Severity: Minor
      Found in web/src/routes/PoisPage.tsx - About 55 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 DashboardNavigationTiles has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

      const DashboardNavigationTiles = ({
        cityModel,
        languageCode,
        navigateTo,
      }: DashboardNavigationTilesProps): ReactElement => {
      Severity: Minor
      Found in native/src/components/DashboardNavigationTiles.tsx - About 55 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 Settings has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

      const Settings = ({ navigation }: SettingsProps): ReactElement => {
        const { settings, updateSettings } = useAppContext()
        const { cityCode, languageCode } = useContext(AppContext)
        const showSnackbar = useSnackbar()
        const { t } = useTranslation('settings')
      Severity: Minor
      Found in native/src/routes/Settings.tsx - About 55 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 parseReleaseNotes has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

      const parseReleaseNotes = ({ source, ios, android, web, production, language, appName }: ParseOptions): string => {
        const platforms: string[] = [
          android ? PLATFORM_ANDROID : undefined,
          ios ? PLATFORM_IOS : undefined,
          web ? PLATFORM_WEB : undefined,
      Severity: Minor
      Found in tools/manage-metadata.ts - About 55 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 useOnClickOutside has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

      const useOnClickOutside = (ref: { current: HTMLElement | null }, callback: () => void): void => {
        useEffect(() => {
          const isOutside = (target: EventTarget | null) =>
            target instanceof Node && ref.current && !ref.current.contains(target)
      
      
      Severity: Minor
      Found in web/src/hooks/useOnClickOutside.ts - About 55 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 TuNewsPage has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

      const TuNewsPage = ({ cityCode, languageCode, city }: CityRouteProps): ReactElement | null => {
        const { t } = useTranslation('news')
        const { viewportSmall } = useWindowDimensions()
      
        const { data: tuNewsLanguages, error } = useLoadFromEndpoint(
      Severity: Minor
      Found in web/src/routes/TuNewsPage.tsx - About 55 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 PoiDetails has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

      const PoiDetails = ({ poi, distance, toolbar }: PoiDetailsProps): ReactElement => {
        const navigate = useNavigate()
        const { viewportSmall } = useWindowDimensions()
        const theme = useTheme()
        const { t } = useTranslation('pois')
      Severity: Minor
      Found in web/src/components/PoiDetails.tsx - About 55 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 submitMalteHelpForm has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

      const submitMalteHelpForm = async ({
        pageTitle,
        url,
        cityCode,
        malteHelpFormOffer,
      Severity: Minor
      Found in shared/api/endpoints/submitMalteHelpForm.ts - About 55 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 request has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

        async request(params: P, overrideUrl?: string): Promise<Payload<T>> {
          if (this.errorOverride) {
            throw this.errorOverride
          }
      
      
      Severity: Minor
      Found in shared/api/Endpoint.ts - About 55 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 Header has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      export const Header = ({
        actionItems = [],
        kebabItems = [],
        logoHref,
        navigationItems = [],
      Severity: Minor
      Found in web/src/components/Header.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 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

      Severity
      Category
      Status
      Source
      Language