VandyHacks/vaken

View on GitHub

Showing 187 of 200 total issues

Avoid too many return statements within this function.
Open

    return (
        <FloatingPopup borderRadius="1rem" height="100%" backgroundOpacity="1" padding="1.5rem">
            <TableContext.Provider value={{ state: tableState, update: updateTableState }}>
                <NfcTable hackersData={hackersData.hackers} eventsData={eventsCurrent} />
            </TableContext.Provider>
Severity: Major
Found in plugins/nfc/components/Nfc.tsx - About 30 mins to fix

Avoid too many return statements within this function.
Open

    return (
        <FloatingPopup borderRadius="1rem" height="100%" backgroundOpacity="1" padding="1.5rem">
            <TableContext.Provider value={{ state: tableState, update: updateTableState }}>
                <NfcTable hackersData={hackers.data?.hackers ?? []} eventsData={ongoingEvents ?? []} />
            </TableContext.Provider>
Severity: Major
Found in src/client/routes/nfc/Nfc.tsx - About 30 mins to fix

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

            newData = new Fuse(newData, {
                keys: ['email', 'firstName', 'lastName', 'school'] as (keyof QueriedHacker)[],
                ...fuseOpts,
            })
                .search(searchValue)
Severity: Minor
Found in plugins/nfc/components/NfcTable.tsx and 1 other location - About 30 mins to fix
src/client/routes/nfc/NfcTable.tsx on lines 145..150

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

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

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

            newData = new Fuse(newData, {
                keys: ['email', 'firstName', 'lastName', 'school'] as (keyof QueriedHacker)[],
                ...fuseOpts,
            })
                .search(searchValue)
Severity: Minor
Found in src/client/routes/nfc/NfcTable.tsx and 1 other location - About 30 mins to fix
plugins/nfc/components/NfcTable.tsx on lines 152..157

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

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

export const SponsorHackerView: FC = () => {
    const { loading, error, data } = useHackersQuery();
    const [tableState, updateTableState] = useImmer(defaultTableState);
    const sponsor = useMeSponsorQuery();
    const now = Date.now();
Severity: Minor
Found in src/client/routes/manage/SponsorHackerView.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

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

export async function addOrUpdateEvent(
    eventInput: EventUpdateInput,
    models: Models
): Promise<EventDbObject> {
    if (!eventInput.id && !eventInput.gcalID)
Severity: Minor
Found in src/server/events/index.ts - 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 updateEventsHandler has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

export async function updateEventsHandler(
    events: null | EventUpdate[],
    addOrUpdateEvent: AddOrUpdateEventMutationHookResult[0],
    removeAbsentEvents: RemoveAbsentEventsMutationHookResult[0]
): Promise<string[]> {
Severity: Minor
Found in src/client/routes/events/helpers.ts - 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 CheckInEvent has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

export const CheckInEvent: FC = () => {
    const events = useEventsForHackersQuery();
    const hacker = useMyEventStatusQuery();
    const [checkIn] = useCheckInUserToEventAndUpdateEventScoreMutation();
    const onCheckIn = useMemo(() => getOnCheckIn(checkIn), [checkIn]);
Severity: Minor
Found in src/client/routes/events/CheckInEvents.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

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

export const FileInput: FC<InputProps> = props => {
    const [file, setFile] = useState<File>();
    const [getSignedUploadUrl] = useSignedUploadUrlMutation();
    const [uploaded, setUploaded] = useState(false);
    const [loading, toggleLoading] = useState(false);
Severity: Minor
Found in src/client/components/Input/FileInput.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

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

const addHackers = async (): Promise<void> => {
    const models = await new DB().collections;
    console.log('Connected to DB');
    const newHackers: HackerDbObject[] = [];
    for (let i = 1; i <= NUM_HACKERS; i += 1) {
Severity: Minor
Found in scripts/populateDb.ts - 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

TODO found
Open

    // TODO(leonm1): Figure out why the _id field isn't actually an ObjectID

TODO found
Open

    // TODO: Add input validation for dietaryRestrictions. toEnum(DietaryRestriction)()
Severity: Minor
Found in src/server/resolvers/UserResolver.ts by fixme

TODO found
Open

    // TODO(leonm1/tangck): Fix queries to show real data. Should also clean up imports when done.

TODO found
Open

            // TODO: write decline email if you want

TODO found
Open

    // TODO: Check permissions of current user's company against

TODO found
Open

        // TODO: These are not typechecked currently :/

TODO found
Open

        // TODO(#473): Use graphql for this fetch to take advantage of

TODO found
Open

    // TODO(mattleon): This requires hitting the DB like 5 times rip
Severity: Minor
Found in plugins/nfc/helpers.ts by fixme

TODO found
Open

    // TODO: Improve the quality of this resolver by removing this hack.

TODO found
Open

        // TODO: Add input validation for these fields.
Severity
Category
Status
Source
Language