baublet/w8mngr

View on GitHub

Showing 365 of 365 total issues

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

  return !sent ? (
    <Form loading={loading} onSubmit={submit} className="flex flex-col gap-4">
      <PageHeading>Request Password Reset Link</PageHeading>
      <p className="text-sm opacity-75">
        Need to reset your password? We can email you a one-click link to reset
Severity: Major
Found in client/components/ForgotPasswordForm.tsx and 1 other location - About 1 day to fix
client/components/MagicEmailLinkForm.tsx on lines 37..73

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

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

  return !sent ? (
    <Form loading={loading} onSubmit={submit} className="flex flex-col gap-4">
      <PageHeading>Request Login Link</PageHeading>
      <p className="text-sm opacity-75">
        Tired of waiting? We can email you a one-click login link that takes you
Severity: Major
Found in client/components/MagicEmailLinkForm.tsx and 1 other location - About 1 day to fix
client/components/ForgotPasswordForm.tsx on lines 35..71

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

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 UserPreferences has 246 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function UserPreferences() {
  const { data } = useGetCurrentUserQuery();
  const [loading, setLoading] = React.useState(true);
  const [, setUserPreferences] = React.useState<PreferencesForm>({
    birthday: "",
Severity: Major
Found in client/pages/UserPreferences.tsx - About 1 day to fix

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

    export function getDateRangeWithDefault(args?: {
      from?: Maybe<Date>;
      to?: Maybe<Date>;
    }) {
      let from = args?.from;
    Severity: Major
    Found in api/helpers/getDateRangeWithDefault.ts and 1 other location - About 7 hrs to fix
    api/dataServices/foodLog/stats.ts on lines 142..162

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

    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

    function getDateRangeWithDefault(args?: {
      from?: Maybe<Date>;
      to?: Maybe<Date>;
    }) {
      let from = args?.from;
    Severity: Major
    Found in api/dataServices/foodLog/stats.ts and 1 other location - About 7 hrs to fix
    api/helpers/getDateRangeWithDefault.ts on lines 7..27

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

    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

    File Upload.tsx has 484 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import cx from "classnames";
    import React from "react";
    
    import { filterFalsyKeys } from "../../../shared";
    import {
    Severity: Minor
    Found in client/components/Forms/Upload.tsx - About 7 hrs to fix

      Function buildConnectionResolver has 183 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export async function buildConnectionResolver<TEntity, TNode = TEntity>(
        query: QueryBuilder,
        args: {
          before?: string | null;
          last?: number | null;
      Severity: Major
      Found in api/helpers/buildConnectionResolver/buildConnectionResolver.ts - About 7 hrs to fix

        Function Routes has 177 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export function Routes() {
          useVerifyEmail();
          return (
            <div className="relative">
              <div className="toast">
        Severity: Major
        Found in client/Routes.tsx - About 7 hrs to fix

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

              await expect(connection.edges()).resolves.toEqual([
                {
                  cursor: "eyJpZCI6MSwiY3Vyc29yRGF0YSI6eyJpZCI6WyJhc2MiLDFdfX0=",
                  entity: expect.objectContaining({ id: 1 }),
                  node: { age: 26, id: 1, name: "Amy" },
          api/helpers/buildConnectionResolver/buildConnectionResolver.test.ts on lines 181..197
          api/helpers/buildConnectionResolver/buildConnectionResolver.test.ts on lines 217..236
          api/helpers/buildConnectionResolver/buildConnectionResolver.test.ts on lines 256..275

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

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

              await expect(connection.edges()).resolves.toEqual([
                {
                  cursor:
                    "eyJpZCI6NCwiY3Vyc29yRGF0YSI6eyJhZ2UiOlsiZGVzYyIsMjNdLCJuYW1lIjpbImFzYyIsIkRhbmllbGxlIl19fQ==",
                  entity: expect.objectContaining({ id: 4 }),
          api/helpers/buildConnectionResolver/buildConnectionResolver.test.ts on lines 109..125
          api/helpers/buildConnectionResolver/buildConnectionResolver.test.ts on lines 181..197
          api/helpers/buildConnectionResolver/buildConnectionResolver.test.ts on lines 217..236

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

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

              await expect(connection.edges()).resolves.toEqual([
                {
                  cursor:
                    "eyJpZCI6MSwiY3Vyc29yRGF0YSI6eyJhZ2UiOlsiZGVzYyIsMjZdLCJuYW1lIjpbImFzYyIsIkFteSJdfX0=",
                  entity: expect.objectContaining({ id: 1 }),
          api/helpers/buildConnectionResolver/buildConnectionResolver.test.ts on lines 109..125
          api/helpers/buildConnectionResolver/buildConnectionResolver.test.ts on lines 181..197
          api/helpers/buildConnectionResolver/buildConnectionResolver.test.ts on lines 256..275

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

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

              await expect(connection.edges()).resolves.toEqual([
                {
                  cursor: "eyJpZCI6NCwiY3Vyc29yRGF0YSI6eyJpZCI6WyJhc2MiLDRdfX0=",
                  entity: expect.objectContaining({ id: 4 }),
                  node: { age: 23, id: 4, name: "Danielle" },
          api/helpers/buildConnectionResolver/buildConnectionResolver.test.ts on lines 109..125
          api/helpers/buildConnectionResolver/buildConnectionResolver.test.ts on lines 217..236
          api/helpers/buildConnectionResolver/buildConnectionResolver.test.ts on lines 256..275

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

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

          export function AddableFoodMeasurements({
            food,
            saveSelectedFood,
          }: {
            saveSelectedFood: (input: FoodLogInput) => void;
          Severity: Minor
          Found in client/components/Foods/AddableFoodMeasurements.tsx - About 6 hrs 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 up has 143 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export async function up(knex: Knex): Promise<void> {
            await withSchema(knex).createTable("user", function (table) {
              table.text("id").notNullable().primary();
              table.string("preferredName");
              table.string("legacyPreferences").nullable();
          Severity: Major
          Found in migrations/20211120170020_InitialMigration.ts - About 5 hrs to fix

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

                (messageToAdd: React.ReactNode | Error, options: ToastOptions = {}) => {
                  const { timeoutMs = 0 } = options;
                  const id = `${Date.now()}-${Math.random()}`;
                  setMessages((message) => {
                    return [
            Severity: Major
            Found in client/helpers/useToast.tsx and 1 other location - About 5 hrs to fix
            client/helpers/useToast.tsx on lines 36..50

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

            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

                (messageToAdd: React.ReactNode, options: ToastOptions = {}) => {
                  const { timeoutMs = 4000 } = options;
                  const id = `${Date.now()}-${Math.random()}`;
                  setMessages((message) => {
                    return [
            Severity: Major
            Found in client/helpers/useToast.tsx and 1 other location - About 5 hrs to fix
            client/helpers/useToast.tsx on lines 55..69

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

            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

                          <IsLoggedIn>
                            <div className="flex flex-col gap-2">
                              <GhostInvertedButton
                                size="extra-large"
                                leftIcon={<HealthCircleIcon />}
            Severity: Major
            Found in client/pages/Home.tsx and 1 other location - About 5 hrs to fix
            client/pages/Home.tsx on lines 75..96

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

            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

                          <IsLoggedOut>
                            <div className="flex flex-col gap-2">
                              <GhostInvertedButton
                                size="extra-large"
                                leftIcon={<HealthCircleIcon />}
            Severity: Major
            Found in client/pages/Home.tsx and 1 other location - About 5 hrs to fix
            client/pages/Home.tsx on lines 53..74

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

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

            export async function buildConnectionResolver<TEntity, TNode = TEntity>(
              query: QueryBuilder,
              args: {
                before?: string | null;
                last?: number | null;
            Severity: Minor
            Found in api/helpers/buildConnectionResolver/buildConnectionResolver.ts - About 5 hrs 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

            File ScannerResults.tsx has 385 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            import React from "react";
            import cx from "classnames";
            
            import {
              GetCurrentUserFoodLogDocument,
            Severity: Minor
            Found in client/components/BarcodeScanner/ScannerResults.tsx - About 5 hrs to fix
              Severity
              Category
              Status
              Source
              Language