EscolaLMS/sdk

View on GitHub

Showing 59 of 336 total issues

File index.tsx has 1831 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import React, {
  FunctionComponent,
  useCallback,
  useState,
  useEffect,
Severity: Major
Found in src/react/context/index.tsx - About 4 days to fix

    File api.ts has 1723 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import { API } from "..";
    
    type Nullable<T> = T | null | undefined;
    
    export enum TopicType {
    Severity: Major
    Found in src/types/api.ts - About 4 days to fix

      Function EscolaLMSContextProviderInner has a Cognitive Complexity of 125 (exceeds 5 allowed). Consider refactoring.
      Open

      > = ({
        children,
        apiUrl,
        defaults,
        imagePrefix = `${apiUrl}/storage/imgcache`,
      Severity: Minor
      Found in src/react/context/index.tsx - About 2 days 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

      defaultApiConfig has 129 functions (exceeds 20 allowed). Consider refactoring.
      Open

      export const defaultApiConfig: EscolaLMSContextConfig = {
        apiUrl: "",
        myCourses: {
          loading: false,
          value: [],
      Severity: Major
      Found in src/react/context/defaults.ts - About 2 days to fix

        defaultReadConfig has 129 functions (exceeds 20 allowed). Consider refactoring.
        Open

        export const defaultReadConfig: EscolaLMSContextConfig = {
          apiUrl: "",
        
          getImagePrefix: () => "",
          getImageSvgPrefix: () => "",
        Severity: Major
        Found in src/react/context/defaults.ts - About 2 days to fix

          File defaults.ts has 828 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import * as API from "./../../types/api";
          
          import { EscolaLMSContextConfig } from "./types";
          
          export const blackList: API.IEvent[] = [
          Severity: Major
          Found in src/react/context/defaults.ts - About 1 day to fix

            File types.ts has 575 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            import { RequestOptionsInit } from "umi-request";
            import * as API from "./../../types/api";
            
            export interface ContextState<T> {
              loading: boolean;
            Severity: Major
            Found in src/react/context/types.ts - About 1 day to fix

              Function fetchDataType has a Cognitive Complexity of 50 (exceeds 5 allowed). Consider refactoring.
              Open

              export async function fetchDataType<T>(params: fetchDataType<T>) {
                const { setState, fetchAction, mode, controller, controllers, onError } =
                  params;
              
                if (mode === "paginated") {
              Severity: Minor
              Found in src/react/context/states.ts - About 7 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 fetchDataType has 157 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export async function fetchDataType<T>(params: fetchDataType<T>) {
                const { setState, fetchAction, mode, controller, controllers, onError } =
                  params;
              
                if (mode === "paginated") {
              Severity: Major
              Found in src/react/context/states.ts - About 6 hrs to fix

                File user.tsx has 402 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                import {
                  createContext,
                  FunctionComponent,
                  PropsWithChildren,
                  useCallback,
                Severity: Minor
                Found in src/react/context/user.tsx - About 5 hrs to fix

                  Function UserContextProvider has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
                  Open

                  > = ({ children, defaults, apiUrl, ssrHydration }) => {
                    const abortControllers = useRef<Record<string, AbortController | null>>({});
                  
                    useEffect(() => {
                      if (defaults) {
                  Severity: Minor
                  Found in src/react/context/user.tsx - 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

                  Function h5pProgress has 79 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      (courseId: string, topicId: number, statement: API.IStatement) => {
                        const statementId = statement?.verb?.id;
                        const statementCategory = statement?.context?.contextActivities?.category;
                        const result: API.IResult | undefined = statement?.result;
                        const hasParent =
                  Severity: Major
                  Found in src/react/context/index.tsx - About 3 hrs to fix

                    Function NotificationsContextProvider has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                    Open

                    > = ({ children, defaults, apiUrl, ssrHydration }) => {
                      const abortControllers = useRef<Record<string, AbortController | null>>({});
                    
                      const { token } = useContext(UserContext);
                    
                    
                    Severity: Minor
                    Found in src/react/context/notifications.tsx - About 2 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 fetchProgram has 65 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        (id: number) => {
                          setProgram((prevState) => ({
                            ...prevState,
                            loading: true,
                            byId: prevState.byId
                    Severity: Major
                    Found in src/react/context/index.tsx - About 2 hrs to fix

                      Function fetchCourse has 63 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          (id: number) => {
                            setCourse((prevState) => ({
                              ...prevState,
                              loading: true,
                              byId: prevState.byId
                      Severity: Major
                      Found in src/react/context/index.tsx - About 2 hrs to fix

                        Function fetchCourseProgress has 59 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            (id: number) => {
                              if (!token) {
                                return Promise.reject("noToken");
                              }
                              setCourseProgressDetails((prevState) => ({
                        Severity: Major
                        Found in src/react/context/index.tsx - About 2 hrs to fix

                          Function sendProgress has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              (courseId: number, data: API.CourseProgressItemElement[]) => {
                                return token
                                  ? postSendProgress
                                      .bind(null, apiUrl)(courseId, data, token)
                                      .then((res) => {
                          Severity: Minor
                          Found in src/react/context/index.tsx - About 1 hr to fix

                            Function Image has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                            Open

                              (
                                { path, size, srcSizes, alt = "LMS Image", format = "webp", ...props },
                                imgRef
                              ) => {
                                const [cached, setCached] = useState(false);
                            Severity: Minor
                            Found in src/react/components/Image/index.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 TaskContextProvider has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                            Open

                            > = ({ children, defaults, apiUrl, ssrHydration }) => {
                              const { token } = useContext(UserContext);
                            
                              const abortControllers = useRef<Record<string, AbortController | null>>({});
                            
                            
                            Severity: Minor
                            Found in src/react/context/task.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 readAllNotifications has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              const readAllNotifications = useCallback(() => {
                                return token
                                  ? postReadAll
                                      .bind(
                                        null,
                            Severity: Minor
                            Found in src/react/context/notifications.tsx - About 1 hr to fix
                              Severity
                              Category
                              Status
                              Source
                              Language