digitalfabrik/integreat-app

View on GitHub

Showing 189 of 190 total issues

Function fetchAsync has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

  func fetchAsync(sourceUrl: String, targetFilePath: String, collector: FetchResultCollector) {
    let targetFileURL = URL(fileURLWithPath: targetFilePath)
    
    let fileManager = FileManager.default
    
Severity: Minor
Found in native/ios/Integreat/fetcher/FetcherModule.swift - 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

Function Intro has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

const Intro = ({ route, navigation }: IntroProps): ReactElement => {
  const { updateSettings } = useContext(AppContext)
  const [currentSlide, setCurrentSlide] = useState(0)
  const { width } = useWindowDimensions()
  const { t } = useTranslation<['intro', 'settings']>(['intro', 'settings'])
Severity: Minor
Found in native/src/routes/Intro.tsx - 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

Function useUserLocation has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

const useUserLocation = ({ requestPermissionInitially }: UseUserLocationProps): UseUserLocationReturn => {
  const [locationState, setLocationState] = useState<LocationStateType>(initialState)
  const showSnackbar = useSnackbar()
  const { t } = useTranslation()

Severity: Minor
Found in native/src/hooks/useUserLocation.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

Function queryStringFromRouteInformation has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

export const queryStringFromRouteInformation = (
  routeInformation: NonNullableRouteInformationType,
): string | undefined => {
  const queryParams = []
  if (routeInformation.route === POIS_ROUTE) {
Severity: Minor
Found in shared/routes/query.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

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

const loadWithCache = async <T extends object>({
  cityCode,
  languageCode,
  isAvailable,
  getFromDataContainer,
Severity: Minor
Found in native/src/hooks/useLoadWithCache.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

Function SettingItem has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const SettingItem = (props: SettingItemProps): ReactElement => {
  const { title, description, onPress, value, hasBadge, hasSwitch, bigTitle, role } = props
  const { t } = useTranslation('settings')

  return (
Severity: Minor
Found in native/src/components/SettingItem.tsx - About 1 hr to fix

    Function buildConfigAssets has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export const buildConfigAssets = (): AssetsType => {
      const assetsName = buildConfig().assets
    
      if (assetsName === INTEGREAT_ASSETS) {
        return {
    Severity: Minor
    Found in native/src/constants/buildConfig.ts - About 1 hr to fix

      Function LanguageSelector has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      const LanguageSelector = (props: LanguageSelectorProps): ReactElement => {
        const { isHeaderActionItem, languageChangePaths, languageCode, inKebabMenu = false, closeSidebar } = props
        const activeItemCode = languageCode
        const { t } = useTranslation('layout')
      
      
      Severity: Minor
      Found in web/src/components/LanguageSelector.tsx - About 1 hr to fix

        Function formatDevelopmentNotes has 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        const formatDevelopmentNotes = (params: { notes: NoteType[]; language: string; platforms: string[] }) => {
          const { notes, language, platforms } = params
          const emptyNotesMap = {
            common: [] as NoteType[],
            android: [] as NoteType[],
        Severity: Minor
        Found in tools/manage-metadata.ts - About 1 hr to fix

          Function handleSubmit has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            const handleSubmit = () => {
              setSendingStatus('sending')
          
              const request = async () => {
                const feedbackEndpoint = createFeedbackEndpoint(await determineApiUrl())
          Severity: Minor
          Found in native/src/components/FeedbackContainer.tsx - About 1 hr to fix

            Function toICal has 29 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              toICal(baseUrl: string, appName: string, recurring: boolean): string {
                const { title, location, path, date, excerpt, lastUpdate } = this
                const url = `${baseUrl}${path}`
                const uid = v5(`${url}/${formatDateICal(lastUpdate)}`, v5.URL)
                const timezone = date.startDate.zone.name
            Severity: Minor
            Found in shared/api/models/EventModel.ts - About 1 hr to fix

              Function storeCategories has 29 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                async storeCategories(categoriesMap: CategoriesMapModel, context: DatabaseContext): Promise<void> {
                  const categoryModels = categoriesMap.toArray()
                  const jsonModels = categoryModels.map(
                    (category: CategoryModel): ContentCategoryJsonType => ({
                      root: category.isRoot(),
              Severity: Minor
              Found in native/src/utils/DatabaseConnector.ts - About 1 hr to fix

                Function CityNotCooperating has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                const CityNotCooperating = (): ReactElement | null => {
                  const { t } = useTranslation('cityNotCooperating')
                  const [isCopied, setIsCopied] = useState<boolean>(false)
                  const template = buildConfig().featureFlags.cityNotCooperatingTemplate
                  const CityNotCooperatingIcon = buildConfigAssets().CityNotCooperatingIcon
                Severity: Minor
                Found in native/src/routes/CityNotCooperating.tsx - About 1 hr to fix

                  Function checkCalendarsAndExportEvent has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    const checkCalendarsAndExportEvent = async (): Promise<void> => {
                      const iosPermission = [PERMISSIONS.IOS.CALENDARS]
                      const androidPermissions = [PERMISSIONS.ANDROID.READ_CALENDAR, PERMISSIONS.ANDROID.WRITE_CALENDAR]
                      const permission = await requestMultiple(Platform.OS === 'ios' ? iosPermission : androidPermissions)
                      const permissionDenied = Object.values(permission).some(permission => ['limited', 'blocked'].includes(permission))
                  Severity: Minor
                  Found in native/src/components/ExportEventButton.tsx - About 1 hr to fix

                    Function pathnameFromRouteInformation has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    export const pathnameFromRouteInformation = (routeInformation: NonNullableRouteInformationType): string => {
                      if (
                        routeInformation.route === JPAL_TRACKING_ROUTE ||
                        routeInformation.route === LICENSES_ROUTE ||
                        routeInformation.route === CONSENT_ROUTE
                    Severity: Minor
                    Found in shared/routes/pathname.ts - About 1 hr to fix

                      Function log has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      export const log = async (message: string, level: SeverityLevel = 'debug'): Promise<void> => {
                        try {
                          const Sentry = await loadSentry()
                          if (sentryEnabled()) {
                            Sentry.addBreadcrumb({ message, level })
                      Severity: Minor
                      Found in web/src/utils/sentry.ts - About 1 hr to fix

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

                          new EndpointBuilder<ParamsType, ChatMessageModel>(CHAT_ENDPOINT_NAME)
                            .withParamsToUrlMapper(
                              (params: ParamsType): string =>
                                `${baseUrl}/api/${API_VERSION}/${params.city}/${params.language}/${CHAT_ENDPOINT_NAME}/${params.deviceId}/`,
                            )
                        Severity: Major
                        Found in shared/api/endpoints/createSendChatMessageEndpoint.ts and 1 other location - About 1 hr to fix
                        shared/api/endpoints/createChatMessagesEndpoint.ts on lines 15..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 57.

                        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

                          new EndpointBuilder<ParamsType, Array<ChatMessageModel>>(CHAT_ENDPOINT_NAME)
                            .withParamsToUrlMapper(
                              (params: ParamsType): string =>
                                `${baseUrl}/api/${API_VERSION}/${params.city}/${params.language}/${CHAT_ENDPOINT_NAME}/${params.deviceId}/`,
                            )
                        Severity: Major
                        Found in shared/api/endpoints/createChatMessagesEndpoint.ts and 1 other location - About 1 hr to fix
                        shared/api/endpoints/createSendChatMessageEndpoint.ts on lines 16..20

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

                        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 moveReleaseNotes has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                        Open

                        const moveReleaseNotes = async ({ newVersionName, deliverinoPrivateKey, owner, repo, branch }: Options) => {
                          const appOctokit = await authenticate({ deliverinoPrivateKey, owner, repo })
                          const {
                            data: { commit },
                          } = await appOctokit.repos.getBranch({ owner, repo, branch })
                        Severity: Minor
                        Found in tools/move-release-notes.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

                        Function MobileBanner has a Cognitive Complexity of 10 (exceeds 5 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: Minor
                        Found in web/src/components/MobileBanner.tsx - 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

                        Severity
                        Category
                        Status
                        Source
                        Language