EscolaLMS/Front

View on GitHub

Showing 559 of 559 total issues

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

  const paginationMeta = useMemo(
    () =>
      filter === CourseStatus.AUTHORED
        ? myAuthoredCourses.list?.meta
        : paginatedProgress.list?.meta,
Severity: Major
Found in src/components/Profile/ProfileCourses/index.tsx and 1 other location - About 1 hr to fix
src/hooks/courses/useProfileCourses.ts on lines 29..35

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

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 useCart has 37 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/hooks/useCart.ts - About 1 hr to fix

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

        "AdditionalFields.Privacy Policy": (
          <Text size="14">
            {t("AcceptCheckbox")}{" "}
            <StyledLink to={routeRoutes.privacyPolicy}>
              {t("PrivacyPolicy")}
    Severity: Major
    Found in src/pages/register/index.tsx and 1 other location - About 1 hr to fix
    src/pages/register/index.tsx on lines 137..144

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

    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

        "AdditionalFields.Terms of Service": (
          <Text size="14">
            {t("AcceptCheckbox")}{" "}
            <StyledLink to={routeRoutes.privacyPolicy}>
              {t("TermsOfService")}
    Severity: Major
    Found in src/pages/register/index.tsx and 1 other location - About 1 hr to fix
    src/pages/register/index.tsx on lines 129..136

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

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

      const availableTopicsIds = useMemo(() => {
        const activeLessons = (currentCourseProgram?.lessons ?? []).filter(
          (l) =>
            l.active_from === null ||
            (l.active_from && isAfter(new Date(), new Date(l.active_from)))
    Severity: Minor
    Found in src/components/Courses/Course/Context/index.tsx - About 1 hr to fix

      Function Buttons has 36 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        const Buttons = useMemo(() => {
          if (userId && product.owned) {
            return <Text size="12">{t("PackagePage.ProductOwned")}</Text>;
          }
          if (productInCart) {
      Severity: Minor
      Found in src/components/Packages/Package/PackageSidebar/Buttons/index.tsx - About 1 hr to fix

        Function availableTopicsIds has 36 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          const availableTopicsIds = useMemo(() => {
            const activeLessons = (currentCourseProgram?.lessons ?? []).filter(
              (l) =>
                l.active_from === null ||
                (l.active_from && isAfter(new Date(), new Date(l.active_from)))
        Severity: Minor
        Found in src/components/Courses/Course/CourseSidebar/index.tsx - About 1 hr to fix

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

          const RateCourse: React.FC<Props> = ({
            course,
            courseId,
            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 ConsultationsProvider has 35 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            const ConsultationsProvider: React.FC<PropsWithChildren> = (props) => {
              const { fetchConsultations, consultations, fetchCategories } =
                useContext(EscolaLMSContext);
              const { children } = props;
              const { query, getQueryValueByName, getAllQueryValueByName, setPathname } =
            Severity: Minor
            Found in src/components/Consultations/List/ConsultationsProvider.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 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 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 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 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/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 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 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

                    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
                      Severity
                      Category
                      Status
                      Source
                      Language