RyanofWoods/rails-react-swedish-birds

View on GitHub

Showing 17 of 45 total issues

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

const SpeciesListHeader: React.FC = () => {
  const columnOptions: ColumnOption[] = [
    {
      column: 'seen',
      classes: 'species-date'
Severity: Minor
Found in app/javascript/react_app/components/species/species_list_header.tsx - About 1 hr to fix

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

    const Checkbox: React.FC<CheckboxProps> = (props) => {
      const [animateClass, setAnimateClass] = useState(false)
      const [fadeClass, setFadeClass] = useState(false)
      const [didMount, setDidMount] = useState(false)
      const [showCheckbox, setShowCheckbox] = useState(true)
    Severity: Minor
    Found in app/javascript/react_app/components/species/checkbox.tsx - About 1 hr to fix

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

      const ObservationModal: React.FC<ObservationModalProps> = ({ close, species, observation, userSettings }) => {
        const today = new Date().toLocaleDateString('en-CA')
        const seen = observation != null
        const dispatch = useAppDispatch()
      
      
      Severity: Minor
      Found in app/javascript/react_app/components/species/observation_modal.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 populationInfo has 36 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      const populationInfo = (species: Species): string => {
        const text = []
        switch (species.populationCategory) {
          case 1:
            text.push('Est. observations above 1,000,000')
      Severity: Minor
      Found in app/javascript/react_app/helpers/population.ts - About 1 hr to fix

        Function Navbar has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        const Navbar = (): JSX.Element => {
          const isUserLoggedIn = useAppSelector(state => state.userData.isLoggedIn)
          let authenticationLink: string
          let authenticationLinkMethod: string
          let authenticationText: string
        Severity: Minor
        Found in app/javascript/react_app/components/shared/navbar.tsx - About 1 hr to fix

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

          const DetailsModal: React.FC<DetailsModalProps> = ({ close, species, observation, userSettings }) => {
            const [showObservationModal, setShowObservationModal] = useState(false)
            const seen = observation != null
            const toggleObservationModal = (): void => {
              setShowObservationModal((prevState) => !prevState)
          Severity: Minor
          Found in app/javascript/react_app/components/species/details_modal.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 client has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export async function client<T> (method: RequestType, endpoint: string, data: Data = {}): Promise<Response<T>> {
            const { body, ...customConfig } = data
            const headers = { 'Content-Type': 'application/json' }
          
            const config: Config = {
          Severity: Minor
          Found in app/javascript/react_app/api/client.ts - About 1 hr to fix

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

              const observationDetails = (): JSX.Element | undefined => {
                if (seen) {
                  let dateText
                  const { note, observedAt } = observation
                  const noteText = (note === null) ? 'No note added' : note
            Severity: Minor
            Found in app/javascript/react_app/components/species/details_modal.tsx - About 1 hr to fix

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

                extraReducers: (builder) => {
                  builder.addCase(fetchSpecies.fulfilled, (state, { payload }) => {
                    state.species = payload.species
                    refilterSpecies(state)
                  })
              Severity: Minor
              Found in app/javascript/react_app/features/speciesSlice.ts - About 1 hr to fix

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

                const migrationText = (species: Species): string => {
                  const text = []
                  if (species.details.includes('Hs ')) {
                    text.push('Breeding non-migratory species')
                  }
                Severity: Minor
                Found in app/javascript/react_app/helpers/population.ts - About 1 hr to fix

                  Function migrationText has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                  const migrationText = (species: Species): string => {
                    const text = []
                    if (species.details.includes('Hs ')) {
                      text.push('Breeding non-migratory species')
                    }
                  Severity: Minor
                  Found in app/javascript/react_app/helpers/population.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 CheckboxAndDate has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                  const CheckboxAndDate: React.FC<CheckboxAndDateProps> = ({ species, observation, handleChange }) => {
                    const seen = observation !== undefined
                    const [showDate, setShowDate] = useState(seen)
                  
                    const speciesDateStyled = (): JSX.Element | null => {
                  Severity: Minor
                  Found in app/javascript/react_app/components/species/checkbox_and_date.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

                  Avoid too many return statements within this function.
                  Open

                      return true
                  Severity: Major
                  Found in app/javascript/react_app/helpers/filter_species.ts - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                          if (speci.orderScientificName !== orderScientificNameScope) return false
                    Severity: Major
                    Found in app/javascript/react_app/helpers/filter_species.ts - About 30 mins to fix

                      Function SpeciesCard has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                      const SpeciesCard: React.FC<SpeciesProps> = ({ species, observation, userSettings, isUserLoggedIn }) => {
                        const dispatch = useAppDispatch()
                        const [showSeenModal, setShowSeenModal] = useState(false)
                        const [showDetailsModal, setShowDetailsModal] = useState(false)
                        const [showInfoBox, setShowInfoBox] = useState(false)
                      Severity: Minor
                      Found in app/javascript/react_app/components/species/species_card.tsx - About 25 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

                      Method update has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                        def update
                          return unknown_species unless @species
                      
                          return no_observation unless @observation
                      
                      
                      Severity: Minor
                      Found in app/controllers/api/observations_controller.rb - About 25 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 Checkbox has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                      const Checkbox: React.FC<CheckboxProps> = (props) => {
                        const [animateClass, setAnimateClass] = useState(false)
                        const [fadeClass, setFadeClass] = useState(false)
                        const [didMount, setDidMount] = useState(false)
                        const [showCheckbox, setShowCheckbox] = useState(true)
                      Severity: Minor
                      Found in app/javascript/react_app/components/species/checkbox.tsx - About 25 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