Showing 78 of 148 total issues

File tripitem.stories.jsx has 573 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import React from 'react'
import { storiesOf } from '@storybook/react'
import { View } from 'react-native'

import { TripItem } from '../js/views/station/TripItemV2.jsx'
Severity: Major
Found in stories/tripitem.stories.jsx - About 1 day to fix

    Function render has 194 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      render() {
        const { desktopLayout, stations, currentCity } = this.state
        let twitterAcc
        if (currentCity.prefix === 'nz-akl') {
          twitterAcc = (
    Severity: Major
    Found in js/views/root/Content.jsx - About 7 hrs to fix

      Function render has 125 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        render() {
          let loading
          let content
      
          const { trips, error, html, routes } = this.state
      Severity: Major
      Found in js/views/station/Station.jsx - About 5 hrs to fix

        Function Settings has 112 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        const Settings = () => {
          const [credits, setCredits] = useState(false)
          return (
            <View style={styles.wrapper}>
              <Header title={t('settings.title')} />
        Severity: Major
        Found in js/views/pages/Settings.jsx - About 4 hrs to fix

          Function getIconName has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
          Open

          export const getIconName = (region, routeType, context, stopName) => {
            if (region === 'au-syd') {
              // TODO!
              return 'normal-default'
            }
          Severity: Minor
          Found in js/views/maps/util.jsx - About 4 hrs 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 render has 100 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            render() {
              const { match } = this.props
              const { loading, error, errorMessage, lineMetadata, showAll } = this.state
          
              let content = null
          Severity: Major
          Found in js/views/lines/LinePicker.jsx - About 4 hrs to fix

            File Index.jsx has 331 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            import React from 'react'
            import PropTypes from 'prop-types'
            import { withRouter } from 'react-router-dom'
            
            import { vars } from '../../styles.js'
            Severity: Minor
            Found in js/views/shell/Index.jsx - About 3 hrs to fix

              File Station.jsx has 317 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              import React, { Component } from 'react'
              import PropTypes from 'prop-types'
              import { withRouter } from 'react-router'
              import { View, StyleSheet } from 'react-native'
              
              
              Severity: Minor
              Found in js/views/station/Station.jsx - About 3 hrs to fix

                Function render has 87 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  render() {
                    if (deferredPrompt !== null) {
                      return null
                    }
                    const userAgent = window.navigator.userAgent.toLowerCase()
                Severity: Major
                Found in js/views/root/Pin.jsx - About 3 hrs to fix

                  Function Feedback has 81 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  const Feedback = () => {
                    const [contact, setContact] = useState('')
                    const [message, setMessage] = useState('')
                    const [loading, setLoading] = useState(false)
                    const [submitted, setSubmitted] = useState(false)
                  Severity: Major
                  Found in js/views/pages/Feedback.jsx - About 3 hrs to fix

                    Function render has 80 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      render() {
                        const { region } = this.props.match.params
                        const stop = this.props.match.params.station
                        const regionStop = `${region}|${stop}`
                    
                    
                    Severity: Major
                    Found in js/views/station/Save.jsx - About 3 hrs to fix

                      Function render has 75 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        render() {
                          let subtitleStyle
                      
                          let subtitleElement
                      
                      
                      Severity: Major
                      Found in js/views/reusable/Header.jsx - About 3 hrs to fix

                        File LineStopsRoute.jsx has 290 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

                        import React, { useState } from 'react'
                        import { Text, View, StyleSheet, TouchableOpacity } from 'react-native'
                        
                        import { vars } from '../../../styles.js'
                        import UiStore from '../../../stores/UiStore.js'
                        Severity: Minor
                        Found in js/views/lines/stops/LineStopsRoute.jsx - About 2 hrs to fix

                          Function render has 73 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            render() {
                              const { loading, error, groups, icons, meta, groupShow } = this.state
                              return (
                                <View style={styles.wrapper}>
                                  <Header title={t('lines.title')} subtitle={meta.longName || ''} />
                          Severity: Major
                          Found in js/views/lines/LineList.jsx - About 2 hrs to fix

                            Function getNextText has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
                            Open

                            const getNextText = (times, hideVerb = false, amphersand = 'also') => {
                              const time = times[0]
                              const time2 = times[1]
                            
                              let combinedMinutes = false
                            Severity: Minor
                            Found in js/views/station/TripItemV2.jsx - About 2 hrs 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

                            File TripItemV2.jsx has 283 lines of code (exceeds 250 allowed). Consider refactoring.
                            Open

                            import React from 'react'
                            import { View, Text, StyleSheet, TouchableOpacity } from 'react-native-web'
                            import { vars } from '../../styles.js'
                            import { getTime } from '../../helpers/date.js'
                            
                            
                            Severity: Minor
                            Found in js/views/station/TripItemV2.jsx - About 2 hrs to fix

                              Function add has 69 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                add(type, data, props = {}) {
                                  const map = UiStore.state.basemap
                                  if (type === 'geojson') {
                                    map.addSource(this.id, {
                                      type: 'geojson',
                              Severity: Major
                              Found in js/views/maps/MapboxLayer.jsx - About 2 hrs to fix

                                Function Guidebook has 60 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                const Guidebook = () => {
                                  const location = useLocation()
                                  const [html, setHtml] = useState('')
                                  const [cityName, setCityName] = useState('')
                                  const [error, setError] = useState('')
                                Severity: Major
                                Found in js/views/pages/Guidebook.jsx - About 2 hrs to fix

                                  Function fetchPage has 60 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                  const fetchPage = async location => {
                                    const url = `${guidebookEndpoint}/${location.substring('/guide/'.length)}`
                                  
                                    if (!navigator.onLine) {
                                      const err = new Error()
                                  Severity: Major
                                  Found in js/views/pages/Guidebook.jsx - About 2 hrs to fix

                                    Function render has 58 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                      render() {
                                        const { match } = this.props
                                        const {
                                          error,
                                          errorMessage,
                                    Severity: Major
                                    Found in js/views/lines/Line.jsx - About 2 hrs to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language