VandyHacks/vaken

View on GitHub
plugins/nfc/helpers.ts

Summary

Maintainability
D
2 days
Test Coverage

Function removeUserFromEvent has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export async function removeUserFromEvent(
    userID: string,
    eventID: string,
    models: Models
): Promise<UserDbInterface> {
Severity: Minor
Found in plugins/nfc/helpers.ts - About 1 hr to fix

Function checkInUserToEvent has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export async function checkInUserToEvent(
    userID: string,
    eventID: string,
    models: Models
): Promise<UserDbInterface> {
Severity: Minor
Found in plugins/nfc/helpers.ts - About 1 hr to fix

TODO found
Open

// TODO: (kenli/timliang) Expand functions for Organizers, Mentors collections
Severity: Minor
Found in plugins/nfc/helpers.ts by fixme

TODO found
Open

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

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

export async function registerNFCUIDWithUser(
    nfcID: string,
    userID: string,
    models: Models
): Promise<UserDbInterface> {
Severity: Major
Found in plugins/nfc/helpers.ts and 1 other location - About 1 day to fix
src/server/nfc/index.ts on lines 37..68

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

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

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

export async function getEventsAttended(userID: string, models: Models): Promise<string[]> {
    const user = await models.Hackers.findOne({ _id: new ObjectID(userID) });
    return user != null && user.eventsAttended != null ? user.eventsAttended : [];
}
Severity: Major
Found in plugins/nfc/helpers.ts and 1 other location - About 3 hrs to fix
src/server/nfc/index.ts on lines 172..175

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

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

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

export async function getAttendees(eventID: string, models: Models): Promise<string[]> {
    const event = await models.Events.findOne({ _id: new ObjectID(eventID) });
    return event != null ? event.attendees : [];
}
Severity: Major
Found in plugins/nfc/helpers.ts and 1 other location - About 2 hrs to fix
src/server/nfc/index.ts on lines 177..180

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

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

export async function checkIfNFCUIDExisted(
    nfcID: string,
    models: Models
): Promise<HackerDbObject | null> {
    const hacker = await models.Hackers.findOne({
Severity: Major
Found in plugins/nfc/helpers.ts and 1 other location - About 1 hr to fix
src/server/nfc/index.ts on lines 8..16

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

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

export async function getUser(nfcID: string, models: Models): Promise<HackerDbObject | null> {
    const user = await models.Hackers.findOne({
        'secondaryIds.0': nfcID,
    });
    return user;
Severity: Major
Found in plugins/nfc/helpers.ts and 1 other location - About 1 hr to fix
src/server/nfc/index.ts on lines 26..31

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

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 3 locations. Consider refactoring.
Open

    const retEvent = await models.Events.findOneAndUpdate(
        { _id: eventObjectID },
        {
            $addToSet: { attendees: userObjectID.toHexString() },
        },
Severity: Major
Found in plugins/nfc/helpers.ts and 2 other locations - About 55 mins to fix
plugins/nfc/helpers.ts on lines 143..151
src/server/events/index.ts on lines 225..233

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

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 3 locations. Consider refactoring.
Open

    const retUsr = await models.Hackers.findOneAndUpdate(
        { _id: userObjectID },
        {
            $addToSet: {
                eventsAttended: eventObjectID.toHexString(),
Severity: Major
Found in plugins/nfc/helpers.ts and 2 other locations - About 55 mins to fix
plugins/nfc/helpers.ts on lines 136..142
src/server/events/index.ts on lines 225..233

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

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

export async function isNFCUIDAvailable(nfcID: string, models: Models): Promise<boolean> {
    return (await getUser(nfcID, models)) == null;
}
Severity: Minor
Found in plugins/nfc/helpers.ts and 1 other location - About 35 mins to fix
src/server/nfc/index.ts on lines 33..35

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

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

There are no issues that match your filters.

Category
Status