VandyHacks/vaken

View on GitHub
src/server/nfc/index.ts

Summary

Maintainability
D
2 days
Test Coverage
B
85%

Function checkInUserToEvent has 47 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 src/server/nfc/index.ts - About 1 hr to fix

Function removeUserFromEvent has 34 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 src/server/nfc/index.ts - About 1 hr to fix

TODO found
Open

// TODO: (kenli/timliang) Expand functions for Organizers, Mentors collections
Severity: Minor
Found in src/server/nfc/index.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 src/server/nfc/index.ts and 1 other location - About 1 day to fix
plugins/nfc/helpers.ts on lines 51..82

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 src/server/nfc/index.ts and 1 other location - About 3 hrs to fix
plugins/nfc/helpers.ts on lines 160..163

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 src/server/nfc/index.ts and 1 other location - About 2 hrs to fix
plugins/nfc/helpers.ts on lines 165..168

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 src/server/nfc/index.ts and 1 other location - About 1 hr to fix
plugins/nfc/helpers.ts on lines 9..17

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 src/server/nfc/index.ts and 1 other location - About 1 hr to fix
plugins/nfc/helpers.ts on lines 40..45

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 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 src/server/nfc/index.ts and 1 other location - About 35 mins to fix
plugins/nfc/helpers.ts on lines 47..49

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