EscolaLMS/sdk

View on GitHub

Showing 59 of 336 total issues

Function CourseAccessContextProvider has a Cognitive Complexity of 13 (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/course_access.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 useCart has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const useCart = () => {
  const [cart, setCart] = useState<PogressState>({
    data: undefined,
    loaded: false,
    loading: false,
Severity: Minor
Found in src/react/hooks/useCart.ts - About 1 hr to fix

    Function useProgress has 39 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export const useProgress = () => {
      const [progress, setProgress] = useState<PogressState>({
        data: undefined,
        loaded: false,
        loading: false,
    Severity: Minor
    Found in src/react/hooks/useProgress.ts - About 1 hr to fix

      Consider simplifying this complex logical expression.
      Open

              if (
                (!hasParent &&
                  statementCategory &&
                  !statementCategory[0]?.id.includes(questionSet)) ||
                (statementCategory &&
      Severity: Critical
      Found in src/react/context/index.tsx - About 1 hr to fix

        Function removeFromCart has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            (itemId: number) => {
              if (!token) {
                return Promise.reject("noToken");
              }
              setCart((prevState) => ({
        Severity: Minor
        Found in src/react/context/cart.tsx - About 1 hr to fix

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

              (id: string) => {
                return token
                  ? readNotification
                      .bind(null, apiUrl)(id, token)
                      .then((response) => {
          Severity: Minor
          Found in src/react/context/notifications.tsx - About 1 hr to fix

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

              const progressMap = useMemo(() => {
                const defaultMap: {
                  coursesProcProgress: Record<number, number>;
                  finishedTopics: number[];
                } = {
            Severity: Minor
            Found in src/react/context/index.tsx - About 1 hr to fix

              Function changeTermDate has 7 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                apiUrl: string,
                termId: number,
                newDate: string,
                term: string,
                token: string,
              Severity: Major
              Found in src/services/consultations.ts - About 50 mins to fix

                Function ConsultationAccessContextProvider has a Cognitive Complexity of 8 (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/consultations_access.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 subscriptionPayWithP24 has 6 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                  apiUrl: string,
                  subId: number,
                  email: string,
                  return_url: string,
                  token: string,
                Severity: Minor
                Found in src/services/cart.ts - About 45 mins to fix

                  Function approveConsultation has 6 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                    apiUrl: string,
                    token: string,
                    id: number,
                    term: string,
                    userId?: number,
                  Severity: Minor
                  Found in src/services/consultations.ts - About 45 mins to fix

                    Function questionnaireAnswer has 6 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                      apiUrl: string,
                      token: string,
                      model: string,
                      modelID: number,
                      id: number,
                    Severity: Minor
                    Found in src/services/questionnaire.ts - About 45 mins to fix

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

                      > = ({ children, defaults, apiUrl, ssrHydration }) => {
                        const abortControllers = useRef<Record<string, AbortController | null>>({});
                        const { token } = useContext(UserContext);
                      
                        const [cart, setCart] = useLocalStorage<ContextStateValue<API.Cart>>(
                      Severity: Minor
                      Found in src/react/context/cart.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 rejectConsultation has 6 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                        apiUrl: string,
                        token: string,
                        id: number,
                        term: string,
                        userId?: number,
                      Severity: Minor
                      Found in src/services/consultations.ts - About 45 mins to fix

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

                        export const sortProgram: SortProgram = (lessons) => {
                          return [...lessons]
                            .sort((lessonA, lessonB) =>
                              typeof lessonA.order === "number" && typeof lessonB.order === "number"
                                ? lessonA.order - lessonB.order
                        Severity: Minor
                        Found in src/react/context/index.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 BookmarkNotesContextProvider has a Cognitive Complexity of 8 (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/bookmark_notes.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 updateTask has 5 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                          apiUrl: string,
                          token: string,
                          id: number,
                          body: EscolaLms.Tasks.Http.Requests.UpdateTaskRequest,
                          options?: RequestOptionsInit
                        Severity: Minor
                        Found in src/services/tasks.ts - About 35 mins to fix

                          Function sendProgress has 5 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                            apiUrl: string,
                            courseId: number,
                            data: API.CourseProgressItemElement[],
                            token: string,
                            options?: RequestOptionsInit
                          Severity: Minor
                          Found in src/services/courses.ts - About 35 mins to fix

                            Function getQuestionnaire has 5 arguments (exceeds 4 allowed). Consider refactoring.
                            Open

                              apiUrl: string,
                              token: string,
                              modelTypeTitle: string,
                              modelID: number,
                              id: number
                            Severity: Minor
                            Found in src/services/questionnaire.ts - About 35 mins to fix

                              Function updateTask has 5 arguments (exceeds 4 allowed). Consider refactoring.
                              Open

                                apiUrl: string,
                                token: string,
                                id: number,
                                body: EscolaLms.Tasks.Http.Requests.UpdateTaskRequest,
                                options?: RequestOptionsInit
                              Severity: Minor
                              Found in src/services/task_notes.ts - About 35 mins to fix
                                Severity
                                Category
                                Status
                                Source
                                Language