EscolaLMS/Front

View on GitHub

Showing 559 of 559 total issues

Function Onboarding has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

const Onboarding = () => {
  const { settings, fetchSettings, updateProfile, fetchProfile, user } =
    useContext(EscolaLMSContext);
  const { t, i18n } = useTranslation();
  const history = useHistory();
Severity: Minor
Found in src/components/Onboarding/index.tsx - About 3 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 CoursePanelFinishPage has 80 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const CoursePanelFinishPage = () => {
  const [state, setState] = useState<State>({
    showModal: false,
    isAnyQuestionnaire: null,
    showCertificate: false,
Severity: Major
Found in src/components/Courses/Course/CoursePanelLayout/FinishPage/index.tsx - About 3 hrs to fix

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

        if (state.step < questionnaires.length - 1) {
          setState((prevState) => ({
            ...prevState,
            step: prevState.step + 1,
          }));
    src/components/Courses/Course/CoursePanelLayout/FinishPage/Rate/index.tsx on lines 45..58

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

    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 (state.step < questionnaires.length - 1) {
          setState((prevState) => ({
            ...prevState,
            step: prevState.step + 1,
          }));
    src/components/Profile/ProfileCourses/CourseCardActions/index.tsx on lines 99..112

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

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

    const EventInfo = () => {
      const { stationaryEvent } = useContext(EscolaLMSContext);
      const { t } = useTranslation();
    
      if (!stationaryEvent.value) {
    Severity: Major
    Found in src/components/Events/Event/EventInfo/index.tsx - About 3 hrs to fix

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

                        image={
                          <Link to={`/courses/${item.id}`}>
                            {item.image_path ? (
                              <ResponsiveImage
                                path={item.image_path}
      Severity: Major
      Found in src/components/Courses/CoursesSlider/index.tsx and 5 other locations - About 3 hrs to fix
      src/components/Courses/CoursesCollection/list.tsx on lines 73..85
      src/components/Courses/CoursesSlider/index.tsx on lines 105..117
      src/components/Courses/CoursesUserSlider/index.tsx on lines 65..77
      src/components/Courses/PromotedCoursesSection/index.tsx on lines 125..137
      src/components/Profile/ProfileCourses/components/CourseCardItem/index.tsx on lines 34..46

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

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

                        image={
                          <Link to={`/courses/${course.id}`}>
                            {course.image_path ? (
                              <ResponsiveImage
                                path={course.image_path}
      Severity: Major
      Found in src/components/Courses/PromotedCoursesSection/index.tsx and 5 other locations - About 3 hrs to fix
      src/components/Courses/CoursesCollection/list.tsx on lines 73..85
      src/components/Courses/CoursesSlider/index.tsx on lines 48..60
      src/components/Courses/CoursesSlider/index.tsx on lines 105..117
      src/components/Courses/CoursesUserSlider/index.tsx on lines 65..77
      src/components/Profile/ProfileCourses/components/CourseCardItem/index.tsx on lines 34..46

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

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

              image={
                <Link to={`/course/${course.id}`}>
                  {course.image_path ? (
                    <ResponsiveImage
                      path={course.image_path}
      src/components/Courses/CoursesCollection/list.tsx on lines 73..85
      src/components/Courses/CoursesSlider/index.tsx on lines 48..60
      src/components/Courses/CoursesSlider/index.tsx on lines 105..117
      src/components/Courses/CoursesUserSlider/index.tsx on lines 65..77
      src/components/Courses/PromotedCoursesSection/index.tsx on lines 125..137

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

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

                    image={
                      <Link to={`/courses/${item.id}`}>
                        {item.image_path ? (
                          <ResponsiveImage
                            path={item.image_path}
      Severity: Major
      Found in src/components/Courses/CoursesCollection/list.tsx and 5 other locations - About 3 hrs to fix
      src/components/Courses/CoursesSlider/index.tsx on lines 48..60
      src/components/Courses/CoursesSlider/index.tsx on lines 105..117
      src/components/Courses/CoursesUserSlider/index.tsx on lines 65..77
      src/components/Courses/PromotedCoursesSection/index.tsx on lines 125..137
      src/components/Profile/ProfileCourses/components/CourseCardItem/index.tsx on lines 34..46

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

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

                      image={
                        <Link to={`/courses/${item.id}`}>
                          {item.image_path ? (
                            <ResponsiveImage
                              path={item.image_path}
      Severity: Major
      Found in src/components/Courses/CoursesUserSlider/index.tsx and 5 other locations - About 3 hrs to fix
      src/components/Courses/CoursesCollection/list.tsx on lines 73..85
      src/components/Courses/CoursesSlider/index.tsx on lines 48..60
      src/components/Courses/CoursesSlider/index.tsx on lines 105..117
      src/components/Courses/PromotedCoursesSection/index.tsx on lines 125..137
      src/components/Profile/ProfileCourses/components/CourseCardItem/index.tsx on lines 34..46

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

      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 onClick = useCallback(async () => {
          if (consultation.consultation_term_id && selectedDate) {
            setLoading(true);
            const response = await bookConsultationTerm(
              consultation.consultation_term_id,
      src/components/Book/BookTermModal/ProposedTermsContent/index.tsx on lines 69..86

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

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

                      image={
                        <Link to={`/courses/${item.id}`}>
                          {item.image_path ? (
                            <ResponsiveImage
                              path={item.image_path}
      Severity: Major
      Found in src/components/Courses/CoursesSlider/index.tsx and 5 other locations - About 3 hrs to fix
      src/components/Courses/CoursesCollection/list.tsx on lines 73..85
      src/components/Courses/CoursesSlider/index.tsx on lines 48..60
      src/components/Courses/CoursesUserSlider/index.tsx on lines 65..77
      src/components/Courses/PromotedCoursesSection/index.tsx on lines 125..137
      src/components/Profile/ProfileCourses/components/CourseCardItem/index.tsx on lines 34..46

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

      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 onClick = useCallback(async () => {
          if (consultation.consultation_term_id && selectedTime) {
            setLoading(true);
            const response = await bookConsultationTerm(
              consultation.consultation_term_id,
      src/components/Book/BookTermModal/UserSelectDatePicker/index.tsx on lines 38..55

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

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

      const Footer = () => {
        const { settings, fetchPages, pages, user } = useContext(EscolaLMSContext);
        const { t, i18n } = useTranslation();
        useEffect(() => {
          fetchPages();
      Severity: Minor
      Found in src/components/_App/Footer/index.tsx - About 3 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 useSearchParams has 77 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export const useSearchParams = () => {
        const { search, pathname } = useLocation();
        const history = useHistory();
      
        const query = useMemo(() => new URLSearchParams(search), [search]);
      Severity: Major
      Found in src/hooks/useSearchParams.ts - About 3 hrs to fix

        Function ConsultationsCollection has 76 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        const ConsultationsCollection = () => {
          const { consultations } = useContext(ConsultationsContext);
          const { t } = useTranslation();
        
          const consultationsCategories = consultations?.list?.data?.map((item) =>
        Severity: Major
        Found in src/components/Consultations/List/ConsultationsCollection/index.tsx - About 3 hrs to fix

          Function PackageInfo has 76 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export const PackageInfo = () => {
            const { product } = useContext(EscolaLMSContext);
            const { t } = useTranslation();
          
            if (!product.value) {
          Severity: Major
          Found in src/components/Packages/Package/PackageInfo/index.tsx - About 3 hrs to fix

            Function ChatIcon has 75 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export const ChatIcon = () => {
              return (
                <svg
                  xmlns="http://www.w3.org/2000/svg"
                  width="31.296"
            Severity: Major
            Found in src/icons/index.tsx - About 3 hrs to fix

              Function Consultation has 75 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              const Consultation = () => {
                const { t } = useTranslation();
                const { id } = useParams<{ id: string }>();
                const { consultation, fetchConsultation, consultations } =
                  useContext(EscolaLMSContext);
              Severity: Major
              Found in src/components/Consultations/Consultation/index.tsx - About 3 hrs to fix

                Function TutorsPage has 74 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                const TutorsPage = () => {
                  const { tutors, fetchTutors } = useContext(EscolaLMSContext);
                
                  const { t } = useTranslation();
                  const theme = useTheme();
                Severity: Major
                Found in src/pages/tutors/index.tsx - About 2 hrs to fix
                  Severity
                  Category
                  Status
                  Source
                  Language