EscolaLMS/Front

View on GitHub

Showing 162 of 559 total issues

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

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

      export const PackageSidebarTags = () => {
        const { product } = useContext(EscolaLMSContext);
        const grouped = useMemo(
          () => groupProductablesByType(product?.value?.productables || []),
          [product?.value?.productables]
      Severity: Minor
      Found in src/components/Packages/Package/PackageSidebar/Tags/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 handleSubmit has 33 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            const handleSubmit = (): void => {
              if (!billingDetails.name) {
                toast(`${t("Cart.EmptyNameWarning")}`, "error");
                return;
              }
          Severity: Minor
          Found in src/components/Cart/CartContent/stripe.tsx - About 1 hr to fix

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

            const CartPage: React.FC<Props> = () => {
              const { config } = useContext(EscolaLMSContext);
              const stripePromise = (publishable_key: string) =>
                loadStripe(publishable_key);
              // eslint-disable-next-line @typescript-eslint/no-explicit-any
            Severity: Minor
            Found in src/pages/cart/index.tsx - About 1 hr to fix

              Function MySubscriptions has 32 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              const MySubscriptions = () => {
                const { t } = useTranslation();
                const {
                  subscriptions,
                  getActiveSubscription,
              Severity: Minor
              Found in src/pages/user/my-subscriptions.tsx - About 1 hr to fix

                Function useSubscriptions has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                Open

                const useSubscriptions = () => {
                  const {
                    fetchProducts,
                    fetchMyProducts,
                    products,
                Severity: Minor
                Found in src/hooks/useSubscriptions.ts - 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 CourseDetailsSidebarButtons has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                Open

                const CourseDetailsSidebarButtons: React.FC<Props> = ({
                  course,
                  userOwnThisCourse,
                  onRequestAccess,
                }) => {

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

                const TutorPage = () => {
                  const { id } = useParams<{ id: string }>();
                  const { t } = useTranslation();
                  const { tutor, fetchTutor, courses, fetchCourses } =
                    useContext(EscolaLMSContext);
                Severity: Minor
                Found in src/pages/tutors/tutor/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 RegisterPage has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                Open

                const RegisterPage = () => {
                  const { search } = useLocation();
                  const { user, socialAuthorize } = useContext(EscolaLMSContext);
                  const [view, setView] = useState<"" | "success" | "register">("");
                  const [modalVisible, setModalVisible] = useState(false);
                Severity: Minor
                Found in src/pages/register/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 StaticPage has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                Open

                const StaticPage = () => {
                  const { slug } = useParams<{ slug: string }>();
                  const { fetchPage, page, fetchPages, pages } = useContext(EscolaLMSContext);
                
                  const prevSlug = usePrevious(slug);
                Severity: Minor
                Found in src/pages/static-page/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 renderProperOptions has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    (option: OnboardingOption) => {
                      switch (step.type) {
                        case OnboardingStepType.radio:
                          return (
                            <Radio
                Severity: Minor
                Found in src/components/Onboarding/Step/index.tsx - About 1 hr to fix

                  Function useDeleteAccountModal has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  const useDeleteAccountModal = () => {
                    const [loading, setLoading] = useState(false);
                    const [showModal, setShowModal] = useState(false);
                    const { deleteAccount, logout } = useContext(EscolaLMSContext);
                    const history = useHistory();
                  Severity: Minor
                  Found in src/hooks/useDeleteAccount.ts - About 1 hr to fix

                    Function ResetPassword has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    const ResetPassword: React.FC = () => {
                      const { push } = useHistory();
                      const { search } = useLocation();
                      const email = search && search.split("&")[0].split("=")[1];
                      const token = search && search.split("&")[1].split("=")[1];
                    Severity: Minor
                    Found in src/pages/reset-password/index.tsx - About 1 hr to fix

                      Function CoursePageContentSkeleton has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      const CoursePageContentSkeleton = () => {
                        return (
                          <SkeletonWrapper>
                            <Skeleton width={"20px"} style={{ marginBottom: "5px" }} />
                            <Skeleton width={"40%"} height={37} style={{ marginBottom: "10px" }} />
                      Severity: Minor
                      Found in src/components/Skeletons/CoursePage/content.tsx - About 1 hr to fix

                        Function handleFetchQuestionnairesAnswers has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            (page: number) => {
                              if (questionId && courseId) {
                                setLoading(true);
                                fetchQuestionnairesAnswers(
                                  QuestionnaireModelType.COURSE,
                        Severity: Minor
                        Found in src/hooks/courses/useCourseAnswers.ts - About 1 hr to fix

                          Function getFormattedDifferenceRelativeToNow has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          export const getFormattedDifferenceRelativeToNow = (time: Date) => {
                            const daysDifference = time
                              ? differenceInDays(time.getTime(), new Date().getTime())
                              : null;
                            const hoursDifference = time
                          Severity: Minor
                          Found in src/utils/index.ts - About 1 hr to fix

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

                              const ConsultationHero: React.FC<ConsultationHeroProps> = (props) => {
                                const { consultation } = props;
                              
                                return (
                                  <Row align={"center"}>
                              Severity: Minor
                              Found in src/components/Consultations/Consultation/ConsultationHero.tsx - About 1 hr to fix
                                Severity
                                Category
                                Status
                                Source
                                Language