EscolaLMS/sdk

View on GitHub

Showing 334 of 334 total issues

Avoid too many return statements within this function.
Open

      return null;
Severity: Major
Found in src/react/context/index.tsx - About 30 mins to fix

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

          } else {
            if (Array.isArray(flatTopics) && flatTopics[currentTopicIndex - 1]) {
              return flatTopics[currentTopicIndex - 1] || null;
            }
          }
    Severity: Minor
    Found in src/react/context/index.tsx and 1 other location - About 30 mins to fix
    src/react/context/index.tsx on lines 1758..1762

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

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

      fetchWebinars: (
        filter: API.WebinarParams
      ) => Promise<API.DefaultMetaResponse<API.Webinar>>;
    Severity: Major
    Found in src/react/context/types.ts and 14 other locations - About 30 mins to fix
    src/react/context/types.ts on lines 108..110
    src/react/context/types.ts on lines 111..113
    src/react/context/types.ts on lines 156..158
    src/react/context/types.ts on lines 191..193
    src/react/context/types.ts on lines 260..262
    src/react/context/types.ts on lines 263..265
    src/react/context/types.ts on lines 274..276
    src/react/context/types.ts on lines 442..444
    src/react/context/types.ts on lines 445..447
    src/react/context/types.ts on lines 449..451
    src/react/context/types.ts on lines 459..461
    src/react/context/types.ts on lines 462..464
    src/react/context/types.ts on lines 510..512
    src/react/context/types.ts on lines 513..515

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

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

      fetchTasks: (
        filter: API.TaskParams
      ) => Promise<API.DefaultMetaResponse<API.Task>>;
    Severity: Major
    Found in src/react/context/types.ts and 14 other locations - About 30 mins to fix
    src/react/context/types.ts on lines 108..110
    src/react/context/types.ts on lines 111..113
    src/react/context/types.ts on lines 156..158
    src/react/context/types.ts on lines 191..193
    src/react/context/types.ts on lines 260..262
    src/react/context/types.ts on lines 263..265
    src/react/context/types.ts on lines 274..276
    src/react/context/types.ts on lines 350..352
    src/react/context/types.ts on lines 445..447
    src/react/context/types.ts on lines 449..451
    src/react/context/types.ts on lines 459..461
    src/react/context/types.ts on lines 462..464
    src/react/context/types.ts on lines 510..512
    src/react/context/types.ts on lines 513..515

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

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

      fetchCourseAccess: (
        filter?: API.CourseAccessEnquiryListParams
      ) => Promise<API.DefaultMetaResponse<API.CourseAccessEnquiry>>;
    Severity: Major
    Found in src/react/context/types.ts and 14 other locations - About 30 mins to fix
    src/react/context/types.ts on lines 108..110
    src/react/context/types.ts on lines 111..113
    src/react/context/types.ts on lines 156..158
    src/react/context/types.ts on lines 191..193
    src/react/context/types.ts on lines 260..262
    src/react/context/types.ts on lines 263..265
    src/react/context/types.ts on lines 274..276
    src/react/context/types.ts on lines 350..352
    src/react/context/types.ts on lines 442..444
    src/react/context/types.ts on lines 449..451
    src/react/context/types.ts on lines 459..461
    src/react/context/types.ts on lines 462..464
    src/react/context/types.ts on lines 510..512
    src/react/context/types.ts on lines 513..515

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

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

      fetchConsultationAccess: (
        filter?: API.CourseAccessEnquiryListParams
      ) => Promise<API.DefaultMetaResponse<API.ConsultationsAccessEnquiry>>;
    Severity: Major
    Found in src/react/context/types.ts and 14 other locations - About 30 mins to fix
    src/react/context/types.ts on lines 108..110
    src/react/context/types.ts on lines 111..113
    src/react/context/types.ts on lines 156..158
    src/react/context/types.ts on lines 191..193
    src/react/context/types.ts on lines 260..262
    src/react/context/types.ts on lines 263..265
    src/react/context/types.ts on lines 274..276
    src/react/context/types.ts on lines 350..352
    src/react/context/types.ts on lines 442..444
    src/react/context/types.ts on lines 445..447
    src/react/context/types.ts on lines 449..451
    src/react/context/types.ts on lines 462..464
    src/react/context/types.ts on lines 510..512
    src/react/context/types.ts on lines 513..515

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

    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

          if (next) {
            if (Array.isArray(flatTopics) && flatTopics[currentTopicIndex + 1]) {
              return flatTopics[currentTopicIndex + 1] || null;
            }
          } else {
    Severity: Minor
    Found in src/react/context/index.tsx and 1 other location - About 30 mins to fix
    src/react/context/index.tsx on lines 1762..1766

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

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

      addConsultationAccess: (
        data: API.ConsultationsAccessEnquiryCreateRequest
      ) => Promise<API.DefaultResponse<API.ConsultationsAccessEnquiry>>;
    Severity: Major
    Found in src/react/context/types.ts and 14 other locations - About 30 mins to fix
    src/react/context/types.ts on lines 108..110
    src/react/context/types.ts on lines 111..113
    src/react/context/types.ts on lines 156..158
    src/react/context/types.ts on lines 191..193
    src/react/context/types.ts on lines 260..262
    src/react/context/types.ts on lines 263..265
    src/react/context/types.ts on lines 274..276
    src/react/context/types.ts on lines 350..352
    src/react/context/types.ts on lines 442..444
    src/react/context/types.ts on lines 445..447
    src/react/context/types.ts on lines 449..451
    src/react/context/types.ts on lines 459..461
    src/react/context/types.ts on lines 510..512
    src/react/context/types.ts on lines 513..515

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

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

      updateProfileEmail: (
        data: API.UpdateUserEmail
      ) => Promise<API.DefaultResponse<API.UserAsProfile>>;
    Severity: Major
    Found in src/react/context/types.ts and 14 other locations - About 30 mins to fix
    src/react/context/types.ts on lines 108..110
    src/react/context/types.ts on lines 111..113
    src/react/context/types.ts on lines 156..158
    src/react/context/types.ts on lines 191..193
    src/react/context/types.ts on lines 260..262
    src/react/context/types.ts on lines 274..276
    src/react/context/types.ts on lines 350..352
    src/react/context/types.ts on lines 442..444
    src/react/context/types.ts on lines 445..447
    src/react/context/types.ts on lines 449..451
    src/react/context/types.ts on lines 459..461
    src/react/context/types.ts on lines 462..464
    src/react/context/types.ts on lines 510..512
    src/react/context/types.ts on lines 513..515

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

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

      fetchNotifications: (
        filter?: API.PaginationParams
      ) => Promise<API.DefaultMetaResponse<API.Notification>>;
    Severity: Major
    Found in src/react/context/types.ts and 14 other locations - About 30 mins to fix
    src/react/context/types.ts on lines 108..110
    src/react/context/types.ts on lines 111..113
    src/react/context/types.ts on lines 156..158
    src/react/context/types.ts on lines 191..193
    src/react/context/types.ts on lines 260..262
    src/react/context/types.ts on lines 263..265
    src/react/context/types.ts on lines 350..352
    src/react/context/types.ts on lines 442..444
    src/react/context/types.ts on lines 445..447
    src/react/context/types.ts on lines 449..451
    src/react/context/types.ts on lines 459..461
    src/react/context/types.ts on lines 462..464
    src/react/context/types.ts on lines 510..512
    src/react/context/types.ts on lines 513..515

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

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

      fetchBookmarkNotes: (
        filter?: API.BookmarkNoteParams
      ) => Promise<API.DefaultMetaResponse<API.BookmarkNote>>;
    Severity: Major
    Found in src/react/context/types.ts and 14 other locations - About 30 mins to fix
    src/react/context/types.ts on lines 108..110
    src/react/context/types.ts on lines 111..113
    src/react/context/types.ts on lines 156..158
    src/react/context/types.ts on lines 191..193
    src/react/context/types.ts on lines 260..262
    src/react/context/types.ts on lines 263..265
    src/react/context/types.ts on lines 274..276
    src/react/context/types.ts on lines 350..352
    src/react/context/types.ts on lines 442..444
    src/react/context/types.ts on lines 445..447
    src/react/context/types.ts on lines 449..451
    src/react/context/types.ts on lines 459..461
    src/react/context/types.ts on lines 462..464
    src/react/context/types.ts on lines 513..515

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

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

      createBookmarkNote: (
        body: API.CreateBookmarkNote
      ) => Promise<API.DefaultResponse<API.BookmarkNote>>;
    Severity: Major
    Found in src/react/context/types.ts and 14 other locations - About 30 mins to fix
    src/react/context/types.ts on lines 108..110
    src/react/context/types.ts on lines 111..113
    src/react/context/types.ts on lines 156..158
    src/react/context/types.ts on lines 191..193
    src/react/context/types.ts on lines 260..262
    src/react/context/types.ts on lines 263..265
    src/react/context/types.ts on lines 274..276
    src/react/context/types.ts on lines 350..352
    src/react/context/types.ts on lines 442..444
    src/react/context/types.ts on lines 445..447
    src/react/context/types.ts on lines 449..451
    src/react/context/types.ts on lines 459..461
    src/react/context/types.ts on lines 462..464
    src/react/context/types.ts on lines 510..512

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

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

    export function useLocalStorage<T>(
      storeKey: string,
      key: string,
      initialValue: T,
      ssrHydration: boolean = false
    Severity: Minor
    Found in src/react/hooks/useLocalStorage.ts - About 25 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 TasksContextProvider has a Cognitive Complexity of 6 (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/tasks.tsx - About 25 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

    Severity
    Category
    Status
    Source
    Language