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'
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)
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()
- Read upRead up
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')
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
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)
- Read upRead up
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 = {
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
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)
})
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')
}
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')
}
- Read upRead up
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 => {
- Read upRead up
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
Avoid too many return
statements within this function. Open
if (speci.orderScientificName !== orderScientificNameScope) return false
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)
- Read upRead up
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
- Read upRead up
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)
- Read upRead up
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"