digitalfabrik/integreat-app

View on GitHub

Showing 189 of 190 total issues

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

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

          <Row>
            <SubTitle>{t('poiCategories')}</SubTitle>
            <SortingHint>{t('alphabetLetters')}</SortingHint>
          </Row>
Severity: Minor
Found in web/src/components/PoiFilters.tsx and 1 other location - About 45 mins to fix
native/src/components/PoiFiltersModal.tsx on lines 116..119

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

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

          <Row>
            <SubTitle>{t('poiCategories')}</SubTitle>
            <SortingHint>{t('alphabetLetters')}</SortingHint>
          </Row>
Severity: Minor
Found in native/src/components/PoiFiltersModal.tsx and 1 other location - About 45 mins to fix
web/src/components/PoiFilters.tsx on lines 106..109

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

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

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

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

      font-family: ${props =>
        props.isCurrentDay ? props.theme.fonts.native.contentFontBold : props.theme.fonts.native.contentFontRegular};
    Severity: Minor
    Found in native/src/components/OpeningEntry.tsx and 1 other location - About 35 mins to fix
    native/src/components/OpeningEntry.tsx on lines 31..32

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

    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

      font-family: ${props =>
        props.isCurrentDay ? props.theme.fonts.native.contentFontBold : props.theme.fonts.native.contentFontRegular};
    Severity: Minor
    Found in native/src/components/OpeningEntry.tsx and 1 other location - About 35 mins to fix
    native/src/components/OpeningEntry.tsx on lines 25..26

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

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

    Severity
    Category
    Status
    Source
    Language