EscolaLMS/sdk

View on GitHub

Showing 334 of 334 total issues

File index.tsx has 1813 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 1720 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

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

          export const WebinarsContextProvider: FunctionComponent<
            PropsWithChildren<WebinarsContextProviderType>
          > = ({ children, defaults, apiUrl, ssrHydration }) => {
            const abortControllers = useRef<Record<string, AbortController | null>>({});
          
          
          Severity: Major
          Found in src/react/context/webinars.tsx and 2 other locations - About 2 days to fix
          src/react/context/consultations.tsx on lines 35..91
          src/react/context/courses.tsx on lines 36..87

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

          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

          export const CoursesContextProvider: FunctionComponent<
            PropsWithChildren<CoursesContextProviderType>
          > = ({ children, defaults, apiUrl, ssrHydration }) => {
            const abortControllers = useRef<Record<string, AbortController | null>>({});
          
          
          Severity: Major
          Found in src/react/context/courses.tsx and 2 other locations - About 2 days to fix
          src/react/context/consultations.tsx on lines 35..91
          src/react/context/webinars.tsx on lines 36..92

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

          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

          export const ConsultationsContextProvider: FunctionComponent<
            PropsWithChildren<ConsultationsContextProviderType>
          > = ({ children, defaults, apiUrl, ssrHydration }) => {
            const abortControllers = useRef<Record<string, AbortController | null>>({});
          
          
          Severity: Major
          Found in src/react/context/consultations.tsx and 2 other locations - About 2 days to fix
          src/react/context/courses.tsx on lines 36..87
          src/react/context/webinars.tsx on lines 36..92

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

          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 defaults.ts has 802 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

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

            export const TutorsContextProvider: FunctionComponent<
              PropsWithChildren<TutorsContextProviderType>
            > = ({ children, defaults, apiUrl, ssrHydration }) => {
              const abortControllers = useRef<Record<string, AbortController | null>>({});
            
            
            Severity: Major
            Found in src/react/context/tutors.tsx and 2 other locations - About 1 day to fix
            src/react/context/categories.tsx on lines 35..88
            src/react/context/tags.tsx on lines 35..88

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

            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

            export const TagsContextProvider: FunctionComponent<
              PropsWithChildren<TagsContextProviderType>
            > = ({ children, defaults, apiUrl, ssrHydration }) => {
              const abortControllers = useRef<Record<string, AbortController | null>>({});
            
            
            Severity: Major
            Found in src/react/context/tags.tsx and 2 other locations - About 1 day to fix
            src/react/context/categories.tsx on lines 35..88
            src/react/context/tutors.tsx on lines 35..86

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

            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

            export const CategoriesContextProvider: FunctionComponent<
              PropsWithChildren<CategoriesContextProviderType>
            > = ({ children, defaults, apiUrl, ssrHydration }) => {
              const abortControllers = useRef<Record<string, AbortController | null>>({});
            
            
            Severity: Major
            Found in src/react/context/categories.tsx and 2 other locations - About 1 day to fix
            src/react/context/tags.tsx on lines 35..88
            src/react/context/tutors.tsx on lines 35..86

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

            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 const H5pContextProvider: FunctionComponent<
              PropsWithChildren<H5pContextProviderType>
            > = ({ children, defaults, apiUrl, ssrHydration }) => {
              const abortControllers = useRef<Record<string, AbortController | null>>({});
            
            
            Severity: Major
            Found in src/react/context/h5p.tsx and 1 other location - About 1 day to fix
            src/react/context/page.tsx on lines 36..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 297.

            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 const PageContextProvider: FunctionComponent<
              PropsWithChildren<PageContextProviderType>
            > = ({ children, defaults, apiUrl, ssrHydration }) => {
              const abortControllers = useRef<Record<string, AbortController | null>>({});
            
            
            Severity: Major
            Found in src/react/context/page.tsx and 1 other location - About 1 day to fix
            src/react/context/h5p.tsx on lines 34..72

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

            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 const useCart = () => {
              const [cart, setCart] = useState<PogressState>({
                data: undefined,
                loaded: false,
                loading: false,
            Severity: Major
            Found in src/react/hooks/useCart.ts and 1 other location - About 1 day to fix
            src/react/hooks/useProgress.ts on lines 11..54

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

            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 const useProgress = () => {
              const [progress, setProgress] = useState<PogressState>({
                data: undefined,
                loaded: false,
                loading: false,
            Severity: Major
            Found in src/react/hooks/useProgress.ts and 1 other location - About 1 day to fix
            src/react/hooks/useCart.ts on lines 11..54

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

            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 types.ts has 568 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

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

                const updateProfile = useCallback(
                  (body: API.UpdateUserDetails) => {
                    setUser((prevState) => ({
                      ...prevState,
                      loading: true,
              Severity: Major
              Found in src/react/context/user.tsx and 1 other location - About 7 hrs to fix
              src/react/context/user.tsx on lines 246..276

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

              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

                const updateProfileEmail = useCallback(
                  (body: API.UpdateUserEmail) => {
                    setUser((prevState) => ({
                      ...prevState,
                      loading: true,
              Severity: Major
              Found in src/react/context/user.tsx and 1 other location - About 7 hrs to fix
              src/react/context/user.tsx on lines 214..244

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

              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

              Severity
              Category
              Status
              Source
              Language