VandyHacks/vaken

View on GitHub

Showing 187 of 200 total issues

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

Function CreateTier has 42 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const CreateTier: React.FC = () => {
    const [tierName, setTierName] = useState('');
    const [permissions, setPermissions] = useState(['']);
    const [createTierMsg, setCreateTierMsg] = useState('');

Severity: Minor
Found in src/client/routes/manage/CreateSponsor.tsx - About 1 hr to fix

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

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

export const Nfc: FunctionComponent = (): JSX.Element => {
    const [tableState, updateTableState] = useImmer(defaultTableState);
    const hackers = useHackersQuery();
    const events = useEventsQuery();
    const loggedInUser = useMeSponsorQuery();
Severity: Minor
Found in src/client/routes/nfc/Nfc.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

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

export const Row: TableRowRenderer = (props): React.ReactNode => {
    const { rowData } = props;

    return defaultTableRowRenderer({
        ...props,
Severity: Major
Found in plugins/nfc/components/Row.tsx and 1 other location - About 1 hr to fix
src/client/routes/nfc/Row.tsx on lines 5..12

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

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 const Row: TableRowRenderer = (props): React.ReactNode => {
    const { rowData } = props;

    return defaultTableRowRenderer({
        ...props,
Severity: Major
Found in src/client/routes/nfc/Row.tsx and 1 other location - About 1 hr to fix
plugins/nfc/components/Row.tsx on lines 5..12

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

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 37 lines of code (exceeds 25 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 1 hr to fix

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

    const EventOptions: { label: string; value: string }[] = eventsData.map(event => {
        return {
            label: event.name,
            value: event.id,
        };
Severity: Major
Found in src/client/routes/nfc/NfcTable.tsx and 1 other location - About 1 hr to fix
plugins/nfc/components/NfcTable.tsx on lines 115..120

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

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

    const EventOptions: { label: string; value: string }[] = eventsData.map(event => {
        return {
            label: event.name,
            value: event.id,
        };
Severity: Major
Found in plugins/nfc/components/NfcTable.tsx and 1 other location - About 1 hr to fix
src/client/routes/nfc/NfcTable.tsx on lines 107..112

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

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 addHackers has 36 lines of code (exceeds 25 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 1 hr to fix

Function Nfc has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

export const Nfc: FunctionComponent = (): JSX.Element => {
    const hackers = useHackersQuery();
    const hackersLoading = hackers.loading;
    const hackersError = hackers.error;
    const hackersData = hackers.data;
Severity: Minor
Found in plugins/nfc/components/Nfc.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 JoinTeam has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const JoinTeam: FC = () => {
    const [searchValue, setSearchValue] = useState('');
    const [errorMsg, setErrorMsg] = useState('');
    const [joinTeam] = useJoinTeamMutation({ variables: { input: { name: searchValue } } });

Severity: Minor
Found in src/client/routes/team/JoinTeam.tsx - About 1 hr to fix

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

    const { value, ok, lastErrorObject } = await models.Logins.findOneAndUpdate(
        constraint,
        { $set: { userType: UserType.Organizer } },
        { returnOriginal: false }
    );
Severity: Major
Found in scripts/makeOrganizer.ts and 1 other location - About 1 hr to fix
scripts/makeVolunteer.ts on lines 21..25

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

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

    const { value, ok, lastErrorObject } = await models.Logins.findOneAndUpdate(
        constraint,
        { $set: { userType: UserType.Volunteer } },
        { returnOriginal: false }
    );
Severity: Major
Found in scripts/makeVolunteer.ts and 1 other location - About 1 hr to fix
scripts/makeOrganizer.ts on lines 19..23

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

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

Function Nfc has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const Nfc: FunctionComponent = (): JSX.Element => {
    const [tableState, updateTableState] = useImmer(defaultTableState);
    const hackers = useHackersQuery();
    const events = useEventsQuery();
    const loggedInUser = useMeSponsorQuery();
Severity: Minor
Found in src/client/routes/nfc/Nfc.tsx - About 1 hr to fix

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

export const Application: FunctionComponent = (): JSX.Element => {
    const { update: setActionButton } = useContext(ActionButtonContext);
    const [openSection, setOpenSection] = useState('');
    const [input, setInput] = useImmer<{ answer: string; question: string }[]>([]);
    const [loaded, setLoaded] = useState(false);
Severity: Minor
Found in src/client/routes/application/Application.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 assignEventToCompany has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export async function assignEventToCompany(
    eventID: string,
    companyID: string,
    models: Models
): Promise<EventDbObject> {
Severity: Minor
Found in src/server/events/index.ts - About 1 hr to fix

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

export const CompaniesQueryMock: MockedResponse<CompaniesQueryResult['data']> = {
    request: {
        query: CompaniesDocument,
    },
    result: {
Severity: Major
Found in src/client/routes/manage/sponsor.graphql.mocks.ts and 2 other locations - About 1 hr to fix
src/client/routes/events/events.graphql.mocks.ts on lines 17..26
src/client/routes/manage/sponsor.graphql.mocks.ts on lines 28..37

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

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

Severity
Category
Status
Source
Language