baublet/w8mngr

View on GitHub

Showing 137 of 365 total issues

Function AddableFood has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

export function AddableFood({
  day,
  selected,
  setSelected,
  food,
Severity: Minor
Found in client/components/Foods/AddableFood.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 authenticate has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

export async function authenticate(
  request: Request,
  context: Context
): Promise<AuthenticationResult | undefined> {
  const authToken: string | undefined = request.cookies?.w8mngrAuth;
Severity: Minor
Found in api/dataServices/user/authenticate.ts - 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 requestDidStart has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

      requestDidStart: async () => {
        return {
          willSendResponse: async (requestContext) => {
            const { context } =
              requestContext as GraphQLRequestContext<Context>;
Severity: Minor
Found in api/graphql.ts - 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 PageHeading has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function PageHeading(props: PageHeadingProps) {
  return (
    <div className="flex gap-4 items-center">
      {props.icon && (
        <div
Severity: Minor
Found in client/components/Type/PageHeading.tsx - About 1 hr to fix

    Function popular has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export async function popular(context: Context): Promise<Activity[]> {
      const userId = context.getCurrentUserId(true);
      const activityLogQueryFactory = await getActivityLogQuery(context);
      const popularQuery = activityLogQueryFactory();
      const popularActivityIds: { activityId: string }[] = await popularQuery
    Severity: Minor
    Found in api/dataServices/activity/popular.ts - About 1 hr to fix

      Function seedFoods has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      async function seedFoods() {
        console.log("Seeding legacy food entries into the new food entries table");
      
        let hasMore = true;
        let offset = 0;
      Severity: Minor
      Found in scripts/seedAlgoliaData.ts - About 1 hr to fix

        Function allowedElements has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          const allowedElements = React.useMemo<string[]>(() => {
            return props.textOnly
              ? []
              : [
                  "h1",
        Severity: Minor
        Found in client/components/Markdown/Markdown.tsx - About 1 hr to fix

          Function saveActivityLog has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export const saveActivityLog: MutationResolvers["saveActivityLog"] = async (
            parent,
            args,
            context
          ) => {
          Severity: Minor
          Found in api/resolvers/mutations/saveActivityLog.ts - About 1 hr to fix

            Function saveActivityEntries has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

            async function saveActivityEntries() {
              console.log("Seeding activity entries");
              let total = 0;
            
              function randomRepsAndWork(type: Activity["type"]): {
            Severity: Minor
            Found in scripts/seedData.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 orZero has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

            function orZero(value: any): number {
              if (typeof value === "number") return value;
              if (typeof value === "string") {
                const num = parseInt(value, 10);
                if (num < 0) {
            Severity: Minor
            Found in api/helpers/buildConnectionResolver/buildConnectionResolver.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 FoodMeasurementsForm has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

            export function FoodMeasurementsForm({
              initialData = [],
              onChange,
            }: {
              initialData?: Maybe<FormMeasurementInput[]>;
            Severity: Minor
            Found in client/components/Foods/FoodMeasurementsForm.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 runHandlerIfKeyMatches has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

            function runHandlerIfKeyMatches(
              userKey: "up" | "down" | "left" | "right" | "enter" | "esc",
              event: KeyboardEvent,
              handler: (event: KeyboardEvent) => void
            ) {
            Severity: Minor
            Found in client/helpers/useKeyPressHandler.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 FoodsListItem has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

            export function FoodsListItem({
              id,
              name,
              description,
              previewImageUrl,
            Severity: Minor
            Found in client/components/Foods/FoodListItem.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 foodLogLocalStorage has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

            export function foodLogLocalStorage() {
              const getItems = () => {
                const storedItems = window.localStorage.getItem("foodLogEntries");
                if (storedItems) {
                  try {
            Severity: Minor
            Found in client/helpers/foodLogLocalStorage.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 saveMutation has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

            export async function saveMutation(
              context: Context,
              {
                input,
                userId,
            Severity: Minor
            Found in api/dataServices/activityLog/saveMutation.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 numberToContextualUnit has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

            export async function numberToContextualUnit(
              context: Context,
              {
                work,
                activityType,
            Severity: Minor
            Found in api/helpers/numberToContextualUnit.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 WeightLog has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

            export function WeightLog() {
              const { day } = useParams<{ day?: string }>();
              const dayString = React.useMemo(() => {
                if (!day) {
                  return dayStringFromDate(new Date());
            Severity: Minor
            Found in client/components/WeightLog/WeightLog.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

            Avoid too many return statements within this function.
            Open

                  return undefined;
            Severity: Major
            Found in client/components/Forms/Upload.tsx - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                if (userKey === "left" && eventKey !== "ArrowLeft") return;
              Severity: Major
              Found in client/helpers/useKeyPressHandler.ts - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                  return 0;
                Severity: Major
                Found in api/helpers/buildConnectionResolver/buildConnectionResolver.ts - About 30 mins to fix
                  Severity
                  Category
                  Status
                  Source
                  Language