digitalfabrik/integreat-app

View on GitHub

Showing 156 of 190 total issues

Function storePois has 44 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  async storePois(pois: Array<PoiModel>, context: DatabaseContext): Promise<void> {
    const jsonModels = pois.map(
      (poi: PoiModel): ContentPoiJsonType => ({
        path: poi.path,
        title: poi.title,
Severity: Minor
Found in native/src/utils/DatabaseConnector.ts - About 1 hr to fix

    Function App has 44 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    const App = (): ReactElement => {
      const [routeIndex, setRouteIndex] = useState<number>(0)
    
      useSendOfflineJpalSignals()
    
    
    Severity: Minor
    Found in native/src/App.tsx - About 1 hr to fix

      Function loadEvents has 44 lines of code (exceeds 25 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 1 hr to fix

        Function constructor has 44 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          constructor() {
            this._databaseConnector = new DatabaseConnector()
            this.caches = {
              pois: new Cache<Array<PoiModel>>(
                this._databaseConnector,
        Severity: Minor
        Found in native/src/utils/DefaultDataContainer.ts - About 1 hr to fix

          Function AppContextProvider has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

          const AppContextProvider = ({ children }: AppContextProviderProps): ReactElement | null => {
            const [settings, setSettings] = useState<SettingsType | null>(null)
            const cityCode = settings?.selectedCity
            const languageCode = settings?.contentLanguage
            const { i18n } = useTranslation()
          Severity: Minor
          Found in native/src/contexts/AppContextProvider.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 EventsPage has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

          const EventsPage = ({ city, pathname, languageCode, cityCode }: CityRouteProps): ReactElement | null => {
            const previousPathname = usePreviousProp({ prop: pathname })
            const { eventId } = useParams()
            const { t } = useTranslation('events')
            const navigate = useNavigate()
          Severity: Minor
          Found in web/src/routes/EventsPage.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 createConfig has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

          const createConfig = (
            env: {
              config_name?: string
              dev_server?: boolean
              bundle_analyzer?: boolean
          Severity: Minor
          Found in web/tools/webpack.config.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 fetchAsync has 42 lines of code (exceeds 25 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

            Function getFailureProps has 42 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              const getFailureProps = (error: Error): { goToPath?: string; goToMessage?: string; errorMessage: string } => {
                if (error instanceof NotFoundError && error.city !== undefined && error.language !== undefined) {
                  const { city, language } = error
                  const params = { cityCode: city, languageCode: language }
            
            
            Severity: Minor
            Found in web/src/components/FailureSwitcher.tsx - About 1 hr to fix

              Function storeEvents has 41 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                async storeEvents(events: Array<EventModel>, context: DatabaseContext): Promise<void> {
                  const jsonModels = events.map(
                    (event: EventModel): ContentEventJsonType => ({
                      path: event.path,
                      title: event.title,
              Severity: Minor
              Found in native/src/utils/DatabaseConnector.ts - About 1 hr to fix

                Function MapView has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                Open

                  (
                    {
                      features,
                      selectFeature,
                      changeSnapPoint,
                Severity: Minor
                Found in web/src/components/MapView.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 LocalNewsPage has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                Open

                const LocalNewsPage = ({ city, pathname, languageCode, cityCode }: CityRouteProps): ReactElement | null => {
                  const previousPathname = usePreviousProp({ prop: pathname })
                  const { newsId } = useParams()
                  const { t } = useTranslation('news')
                  const navigate = useNavigate()
                Severity: Minor
                Found in web/src/routes/LocalNewsPage.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 mapEventsJson has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                      json.map(jsonObject => {
                        const jsonDate = jsonObject.date
                        return new EventModel({
                          path: jsonObject.path,
                          title: jsonObject.title,
                Severity: Minor
                Found in native/src/utils/DatabaseConnector.ts - About 1 hr to fix

                  Function constructor has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    constructor(props: PinchPanImageProps) {
                      super(props)
                      this.state = { interactive: true }
                  
                      this.pinchHandler = React.createRef()
                  Severity: Minor
                  Found in native/src/components/PinchPanImage.tsx - About 1 hr to fix

                    Function CityContentLayout has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    const CityContentLayout = (props: CityContentLayoutProps): ReactElement => {
                      const { viewportSmall } = useWindowDimensions()
                    
                      const {
                        children,
                    Severity: Minor
                    Found in web/src/components/CityContentLayout.tsx - About 1 hr to fix

                      Function exportEventToCalendar has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        const exportEventToCalendar = async (calendarId: string, exportAll: boolean): Promise<void> => {
                          // Luxon ISO dates have the time zone offset but Android calendar needs them in UTC
                          let startDate = event.date.startDate.toUTC().toISO()
                          let endDate = event.date.endDate.toUTC().toISO()
                          const allDay = event.date.allDay
                      Severity: Minor
                      Found in native/src/components/ExportEventButton.tsx - About 1 hr to fix

                        Function openExternalUrl has 36 lines of code (exceeds 25 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 1 hr to fix

                          Function submitHandler has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            const submitHandler = async (event: SyntheticEvent<HTMLFormElement>) => {
                              const form = event.currentTarget
                              if (!form.checkValidity()) {
                                event.stopPropagation()
                                scrollToFirstError(form)
                          Severity: Minor
                          Found in web/src/components/MalteHelpForm.tsx - About 1 hr to fix

                            Function useLoadCityContent has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                            Open

                            const useLoadCityContent = ({ cityCode, languageCode, refreshLocalNews }: Params): CityContentReturn => {
                              const showSnackbar = useSnackbar()
                              const previousLanguageCode = usePreviousProp({ prop: languageCode })
                              const params = { cityCode, languageCode, showSnackbar }
                            
                            
                            Severity: Minor
                            Found in native/src/hooks/useLoadCityContent.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 detect has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                            Open

                              detect: () => {
                                const bcp47Tags: string[] = []
                            
                                const localStorageLanguage = safeLocalStorage.getItem(I18N_LANGUAGE_KEY)
                            
                            
                            Severity: Minor
                            Found in web/src/utils/BrowserLanguageDetector.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

                            Severity
                            Category
                            Status
                            Source
                            Language