VandyHacks/vaken

View on GitHub

Showing 187 of 200 total issues

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

                <SearchBox
                    width="100%"
                    value={sponsorName}
                    placeholder="Sponsor's Name"
                    onChange={e => setSponsorName(e.target.value)}
Severity: Major
Found in src/client/routes/manage/CreateSponsor.tsx and 3 other locations - About 50 mins to fix
src/client/routes/manage/CreateSponsor.tsx on lines 71..77
src/client/routes/manage/CreateSponsor.tsx on lines 126..132
src/client/routes/manage/CreateSponsor.tsx on lines 184..190

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

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 option2Ref = useCallback((node): void => {
        if (node !== null) {
            setOption2Width(node.getBoundingClientRect().width);
        }
    }, []);
Severity: Major
Found in src/client/components/Buttons/RadioSlider.tsx and 2 other locations - About 50 mins to fix
src/client/components/Buttons/RadioSlider.tsx on lines 75..79
src/client/components/Buttons/RadioSlider.tsx on lines 85..89

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

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 option1Ref = useCallback((node): void => {
        if (node !== null) {
            setOption1Width(node.getBoundingClientRect().width);
        }
    }, []);
Severity: Major
Found in src/client/components/Buttons/RadioSlider.tsx and 2 other locations - About 50 mins to fix
src/client/components/Buttons/RadioSlider.tsx on lines 80..84
src/client/components/Buttons/RadioSlider.tsx on lines 85..89

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

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 option3Ref = useCallback((node): void => {
        if (node !== null) {
            setOption3Width(node.getBoundingClientRect().width);
        }
    }, []);
Severity: Major
Found in src/client/components/Buttons/RadioSlider.tsx and 2 other locations - About 50 mins to fix
src/client/components/Buttons/RadioSlider.tsx on lines 75..79
src/client/components/Buttons/RadioSlider.tsx on lines 80..84

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

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

const CreateSponsor: React.FunctionComponent = (): JSX.Element => {
    const [sponsorEmail, setSponsorEmail] = useState('');
    const [sponsorName, setSponsorName] = useState('');
    const [companyId, setCompanyId] = useState('');
    const [createSponsorMsg, setCreateSponsorMsg] = useState('');
Severity: Minor
Found in src/client/routes/manage/CreateSponsor.tsx - About 45 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 constructor has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    constructor() {
        this.schema = schema;
        this.resolvers = {
            _Plugin__Event: {
                attendees: async event => (await event).attendees || [],
Severity: Minor
Found in plugins/nfc/server.ts - About 45 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 onTableColumnSelect has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

const onTableColumnSelect = (
    ctx: TableCtxI,
    index: number
): ((s: ValueType<Option, true>) => void) => {
    // Dependency injection
Severity: Minor
Found in src/client/routes/manage/HackerTable.tsx - About 45 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 ResumeLink has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

export const ResumeLink: FC<ResumeLinkProps> = (props: { id: string }) => {
    const { id } = props;
    const { data, loading, error } = useDetailedHackerQuery({ variables: { id } });
    const [linkLoc, setLinkLoc] = useState('');
    const fileReadUrlQuery = useSignedReadUrlQuery({
Severity: Minor
Found in src/client/routes/manage/ResumeLink.tsx - About 45 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

Consider simplifying this complex logical expression.
Open

        if (
            word.length !== 0 &&
            !hacker.firstName.toLowerCase().includes(word) &&
            !hacker.lastName.toLowerCase().includes(word) &&
            !hacker.email.toLowerCase().includes(word) &&
Severity: Major
Found in plugins/nfc/components/helpers.ts - About 40 mins to fix

Consider simplifying this complex logical expression.
Open

        if (
            word.length !== 0 &&
            !hacker.firstName.toLowerCase().includes(word) &&
            !hacker.lastName.toLowerCase().includes(word) &&
            !hacker.email.toLowerCase().includes(word) &&
Severity: Major
Found in src/client/routes/nfc/helpers.ts - About 40 mins to fix

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

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

Function assignEventToCompany has a Cognitive Complexity of 7 (exceeds 5 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 35 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 HackerView has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

export const HackerView: FC<HackerViewProps> = props => {
    const { match } = props;
    const { data, loading, error } = useDetailedHackerQuery({ variables: { id: match.params.id } });
    const fileReadUrlQuery = useSignedReadUrlQuery({
        variables: { input: (data && data.hacker.id) || '' },
Severity: Minor
Found in src/client/routes/manage/HackerView.tsx - About 35 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 transformCalEventToDBUpdate has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

export const transformCalEventToDBUpdate = (event: SimplifiedVEvent): EventUpdate => {
    if (!event.start && !event.end) {
        throw new TypeError('Calendar event did not contain start or end timestamp');
    }
    // Either start or end may be undefined, but not both due to guard above.
Severity: Minor
Found in src/server/events/index.ts - About 35 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 generateRowClassName has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

) => (arg: { index: number }) => string = (data, topUserMatch) => ({ index }) => {
    if (data[index] && data[index].id === topUserMatch) return 'selected';

    if (index < 0) return 'headerRow';

Severity: Minor
Found in src/client/routes/nfc/helpers.ts - About 35 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 generateRowClassName has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

) => (arg: { index: number }) => string = (data, topUserMatch) => ({ index }) => {
    if (data[index] && data[index].id === topUserMatch) return 'selected';

    if (index < 0) return 'headerRow';

Severity: Minor
Found in plugins/nfc/components/helpers.ts - About 35 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

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

    if (!args.length || args.length > 2 || !EmailValidator.validate(args[0])) printUsage();
Severity: Minor
Found in scripts/makeVolunteer.ts and 1 other location - About 35 mins to fix
scripts/makeOrganizer.ts on lines 45..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 46.

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

    if (!args.length || args.length > 2 || !EmailValidator.validate(args[0])) printUsage();
Severity: Minor
Found in scripts/makeOrganizer.ts and 1 other location - About 35 mins to fix
scripts/makeVolunteer.ts on lines 35..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 46.

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

Avoid too many return statements within this function.
Open

        return <p>You dont have permissions to scan NFCs</p>;
Severity: Major
Found in plugins/nfc/components/Nfc.tsx - About 30 mins to fix
Severity
Category
Status
Source
Language