EscolaLMS/Front

View on GitHub

Showing 585 of 585 total issues

Function RateCourse has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

const RateCourse: React.FC<Props> = ({
  entityModel,
  entityId,
  visible,
  questionnaire,
Severity: Minor
Found in src/components/Courses/RateCourse/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 PackageSidebarButtons has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

export const PackageSidebarButtons = ({ product }: Props) => {
  const { cart, addToCart, user } = useContext(EscolaLMSContext);
  const { t } = useTranslation();
  const { push } = useHistory();
  const userId = user.value?.id;
Severity: Minor
Found in src/components/Packages/Package/PackageSidebar/Buttons/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 fetchPageNumbers has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  const fetchPageNumbers = () => {
    /**
     * totalNumbers: the total page numbers to show on the control
     * totalBlocks: totalNumbers + 2 to cover for the left(<) and right(>) controls
     */
Severity: Minor
Found in src/components/Common/Pagination/index.tsx - About 1 hr to fix

    Function EventTutor has 35 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    const EventTutor = () => {
      const { stationaryEvent } = useContext(EscolaLMSContext);
      const { t } = useTranslation();
    
      const authors = stationaryEvent.value?.product?.authors;
    Severity: Minor
    Found in src/components/Events/Event/EventTutor/index.tsx - About 1 hr to fix

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

      export const WebinarSidebarStyles = styled.div`
        width: 100%;
        left: 0;
        position: ${isMobile ? "fixed" : "sticky"};
        top: ${isMobile ? "unset" : "130px"};
      src/components/DetailsSidebarContainer/styles.tsx on lines 4..12
      src/components/Events/Event/EventSidebar/EventSidebarStyles.ts on lines 4..12

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

      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 DetailsSidebarStyles = styled.div`
        width: 100%;
        left: 0;
        position: ${isMobile ? "fixed" : "sticky"};
        top: ${isMobile ? "unset" : "130px"};
      Severity: Major
      Found in src/components/DetailsSidebarContainer/styles.tsx and 2 other locations - About 1 hr to fix
      src/components/Events/Event/EventSidebar/EventSidebarStyles.ts on lines 4..12
      src/components/Webinars/Webinar/WebinarSidebar/WebinarSidebarStyles.tsx on lines 4..12

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

      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 EventSidebarStyles = styled.div`
        width: 100%;
        left: 0;
        position: ${isMobile ? "fixed" : "sticky"};
        top: ${isMobile ? "unset" : "130px"};
      src/components/DetailsSidebarContainer/styles.tsx on lines 4..12
      src/components/Webinars/Webinar/WebinarSidebar/WebinarSidebarStyles.tsx on lines 4..12

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

      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

          return (
            progress &&
            progress.value &&
            progress.value.find(
              (courseProgress: API.CourseProgressItem) =>
      Severity: Major
      Found in src/hooks/courses/useCourseBreakPoint.ts and 1 other location - About 1 hr to fix
      src/components/Courses/Course/CourseSidebar/index.tsx on lines 91..98

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

      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

          return (
            progress &&
            progress.value &&
            progress.value.find(
              (courseProgress: API.CourseProgressItem) =>
      Severity: Major
      Found in src/components/Courses/Course/CourseSidebar/index.tsx and 1 other location - About 1 hr to fix
      src/hooks/courses/useCourseBreakPoint.ts on lines 26..33

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

      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 CartSuccess has 34 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      const CartSuccess = () => {
        const { t } = useTranslation();
      
        const { fetchProgress } = useContext(EscolaLMSContext);
      
      
      Severity: Minor
      Found in src/components/Cart/CartSuccess/index.tsx - About 1 hr to fix

        Function Sidebar has 34 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        const Sidebar = () => {
          const { t } = useTranslation();
          const { settings, courses, fetchCourses } = useContext(EscolaLMSContext);
        
          useEffect(() => {
        Severity: Minor
        Found in src/components/TermsOfService/Sidebar.tsx - About 1 hr to fix

          Function GoTop has 34 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          const GoTop = () => {
            const [isVisible, setIsVisible] = useState(false);
          
            useEffect(() => {
              document.addEventListener("scroll", () => {
          Severity: Minor
          Found in src/components/_App/GoTop/index.tsx - About 1 hr to fix

            Function handleSendAnswer has 34 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                async (rate: number, note?: string) => {
                  if (questionnaire.questions) {
                    setState((prevState) => ({
                      ...prevState,
                      loading: true,
            Severity: Minor
            Found in src/components/Courses/RateCourse/index.tsx - About 1 hr to fix

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

                const {
                  entities,
                  loading,
                  prevCategories,
                  handleSortChange,
              Severity: Major
              Found in src/components/Courses/CoursesCollection/index.tsx and 1 other location - About 1 hr to fix
              src/components/Consultations/List/ConsultationsContainer/index.tsx on lines 20..31

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

              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 {
                  entities,
                  loading,
                  prevCategories,
                  handleSortChange,
              src/components/Courses/CoursesCollection/index.tsx on lines 27..38

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

              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

                          avatar={{
                            alt: `${user.first_name} ${user.last_name}`,
                            src: `${API_URL}/api/images/img?path=${user.path_avatar}` || "",
                          }}
              Severity: Major
              Found in src/components/TutorsSection/index.tsx and 1 other location - About 1 hr to fix
              src/components/Events/Event/EventTutor/index.tsx on lines 29..33

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

              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

                            avatar={{
                              alt: `${author.first_name} ${author.last_name}`,
                              src:
                                `${API_URL}/api/images/img?path=${author.path_avatar}` || "",
                            }}
              Severity: Major
              Found in src/components/Events/Event/EventTutor/index.tsx and 1 other location - About 1 hr to fix
              src/components/TutorsSection/index.tsx on lines 37..40

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

              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

              Consider simplifying this complex logical expression.
              Open

                  if (
                    slug &&
                    !page.loading &&
                    ((!page.value && !page.error) ||
                      (page.value && page.value?.slug !== slug) ||
              Severity: Critical
              Found in src/pages/static-page/index.tsx - About 1 hr to fix

                Function App has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                const App = () => {
                  const { fetchSettings, settings, fetchNotifications, fetchConfig } =
                    useContext(EscolaLMSContext);
                
                  useEffect(() => {
                Severity: Minor
                Found in src/App.tsx - About 1 hr to fix

                  Function handleRecordingStatusChanged has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      async (
                        api: IJitsiMeetExternalApi,
                        getDataUrl: () => Promise<string | null>,
                        status: {
                          on: boolean;
                    Severity
                    Category
                    Status
                    Source
                    Language