EscolaLMS/Front

View on GitHub

Showing 162 of 559 total issues

Function topicRender has 55 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  const topicRender = useMemo(() => {
    if (topic && topic.topicable_type) {
      switch (topic.topicable_type) {
        case TopicType.H5P:
          // @ts-ignore
Severity: Major
Found in src/components/Courses/Course/CourseProgramPreview/index.tsx - About 2 hrs to fix

    Function MyWebinarsPage has 55 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    const MyWebinarsPage = () => {
      const { userWebinars, fetchUserWebinars } = useContext(EscolaLMSContext);
      const { t } = useTranslation();
    
      useEffect(() => {
    Severity: Major
    Found in src/pages/user/MyWebinars/index.tsx - About 2 hrs to fix

      Function OrdersSkeleton has 53 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      const OrdersSkeleton = () => {
        const id = useId();
        return (
          <>
            <div>
      Severity: Major
      Found in src/components/Skeletons/Orders/index.tsx - About 2 hrs to fix

        Function useProfileCourses has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

        const useProfileCourses = (filter = CourseStatus.ALL) => {
          const {
            fetchMyAuthoredCourses,
            myAuthoredCourses,
            fetchPaginatedProgress,
        Severity: Minor
        Found in src/hooks/courses/useProfileCourses.ts - About 2 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

        Function useChatLogic has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

        const useChatLogic = (lessonID: number, token: string | null | undefined) => {
          if (!token) throw new Error("Token is required");
        
          const [chatState, setChatState] = useState<State>(INITIAL_STATE);
          const { t } = useTranslation();
        Severity: Minor
        Found in src/hooks/chat/useChatLogic.ts - About 2 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

        Function useNotifications has 52 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export const useNotifications = () => {
          const [list, setList] = useState<Notification[]>([]);
          const {
            fetchNotifications,
            notifications,
        Severity: Major
        Found in src/hooks/useNotification.ts - About 2 hrs to fix

          Function ButtonsNav has 51 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export const ButtonsNav = () => {
            const {
              completeCurrentTopic,
              currentTopic,
              finishedTopicsIds,
          Severity: Major
          Found in src/components/Courses/Course/CoursePanelLayout/ButtonsNav/index.tsx - About 2 hrs to fix

            File index.tsx has 251 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            import React, {
              useCallback,
              useContext,
              useEffect,
              useMemo,

              Function Login has 50 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              const Login = () => {
                const { search, state } = useLocation<{ referrer?: string }>();
                const { user, socialAuthorize } = useContext(EscolaLMSContext);
                const [view, setView] = useState<
                  "login" | "forgotPassword" | "register" | "success"
              Severity: Minor
              Found in src/pages/login/index.tsx - About 2 hrs to fix

                Function EmailActivation has 50 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  const EmailActivation = () => {
                    const { config } = useContext(EscolaLMSContext);
                
                    const accountActivationByAdmin =
                      config?.value?.escola_auth?.account_must_be_enabled_by_admin ===
                Severity: Minor
                Found in src/pages/register/index.tsx - About 2 hrs to fix

                  Function MyProfile has 47 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  const MyProfile = () => {
                    const { t } = useTranslation();
                    const { isTutor } = useRoles();
                    const { query, setQueryParam } = useSearchParams();
                  
                  
                  Severity: Minor
                  Found in src/pages/user/MyProfile/index.tsx - About 1 hr to fix

                    Function PackageSidebar has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    export const PackageSidebar = () => {
                      const { product } = useContext(EscolaLMSContext);
                      const { t } = useTranslation();
                      const productValue = product.value;
                    
                    
                    Severity: Minor
                    Found in src/components/Packages/Package/PackageSidebar/index.tsx - About 1 hr to fix

                      Function ThemeCustomizer has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      export const ThemeCustomizer = (theme: Record<string, DefaultTheme>) => {
                        const [, setTheme] = useLocalTheme({
                          ...defaultTheme,
                          theme: "contrastTheme",
                        });
                      Severity: Minor
                      Found in src/components/_App/ThemeCustomizer/ThemeCustomizer.tsx - About 1 hr to fix

                        Function ConsultationsHeaderFilters has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        const ConsultationsHeaderFilters = () => {
                          const {
                            setPathname,
                            setQueryParam,
                            setQueryArrayParam,

                          Function useCourseProgress has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

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

                            Function EventDetailsSidebar has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                            Open

                            const EventDetailsSidebar: React.FC<{ event: API.StationaryEvent }> = ({
                              event,
                            }) => {
                              const [buttonStatus, setButtonStatus] = useState<ButtonStatus>(
                                ButtonStatus.DEFAULT
                            Severity: Minor
                            Found in src/components/Events/Event/EventDetailsSidebar/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 WebinarsContainerItems has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            const WebinarsContainerItems = () => {
                              const { params, setParams, webinars } = useContext(WebinarsContext);
                              const loading = webinars?.loading;
                              const meta = webinars?.list?.meta;
                              const theme = useTheme();
                            Severity: Minor
                            Found in src/components/Webinars/List/WebinarsContainer/Items/index.tsx - About 1 hr to fix

                              Function EventsContainerItems has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              const EventsContainerItems = () => {
                                const { params, setParams, events } = useContext(EventsContext);
                                const eventLoading = events?.loading;
                                const eventsMeta = events?.list?.meta;
                                const theme = useTheme();
                              Severity: Minor
                              Found in src/components/Events/List/EventsContainer/Items/index.tsx - About 1 hr to fix

                                Function PackagesContainerItems has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                const PackagesContainerItems = () => {
                                  const { params, setParams, packages } = useContext(PackagesContext);
                                  const packagesLoading = packages?.loading;
                                  const packagesMeta = packages?.list?.meta;
                                  const theme = useTheme();
                                Severity: Minor
                                Found in src/components/Packages/List/PackagesContainer/Items/index.tsx - About 1 hr to fix

                                  Function useFirebase has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                  export const useFirebase = () => {
                                    const { token } = useContext(EscolaLMSContext);
                                  
                                    const requestPermissions = async () => {
                                      const result = await FirebaseMessaging.requestPermissions();
                                  Severity: Minor
                                  Found in src/hooks/useFirebase.ts - About 1 hr to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language