WikiEducationFoundation/WikiEduDashboard

View on GitHub

Showing 1,672 of 1,672 total issues

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

const updateImpactStatsPromise = async (impactStats) => {
  const body = {
    impactStats: impactStats,
  };
  const response = await request('/settings/update_impact_stats', {
Severity: Major
Found in app/assets/javascripts/actions/settings_actions.js and 1 other location - About 4 hrs to fix
app/assets/javascripts/actions/settings_actions.js on lines 498..513

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

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

        <div className="form-group">
          <label>
            First and last name
            <span className="form-required-indicator">*</span>
          </label>
Severity: Major
Found in app/assets/javascripts/components/onboarding/form.jsx and 1 other location - About 4 hrs to fix
app/assets/javascripts/components/onboarding/form.jsx on lines 112..127

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

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

        <div className="form-group">
          <label>
            Email <span className="form-required-indicator">*</span>
          </label>
          <input
Severity: Major
Found in app/assets/javascripts/components/onboarding/form.jsx and 1 other location - About 4 hrs to fix
app/assets/javascripts/components/onboarding/form.jsx on lines 94..111

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

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

const PetScanScoping = () => {
  const [inputValue, setInputValue] = React.useState('');
  const petscanIDs = useSelector(state => state.scopingMethods.petscan.psids);
  const dispatch = useDispatch();
  const home_wiki = useSelector(state => state.course.home_wiki);

    File course_approval.jsx has 339 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import React, { useEffect, useState } from 'react';
    
    import { connect } from 'react-redux';
    import { difference, uniq } from 'lodash-es';
    
    
    Severity: Minor
    Found in app/assets/javascripts/components/course/course_approval.jsx - About 4 hrs to fix

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

                      {!wikiEd && (
                        <span id="span_wikied">
                          <li>
                            <CustomLink to="https://meta.wikimedia.org/wiki/Programs_%26_Events_Dashboard" name={I18n.t('application.documentation')} target="_blank" />
                          </li>
      Severity: Major
      Found in app/assets/javascripts/components/nav/hamburger_menu.jsx and 1 other location - About 4 hrs to fix
      app/assets/javascripts/components/nav/nav.jsx on lines 113..122

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

      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

                      {!wikiEd && (
                        <span id="span_wikied">
                          <li>
                            <CustomLink to="https://meta.wikimedia.org/wiki/Special:MyLanguage/Programs_%26_Events_Dashboard" name={I18n.t('application.documentation')} target="_blank" />
                          </li>
      Severity: Major
      Found in app/assets/javascripts/components/nav/nav.jsx and 1 other location - About 4 hrs to fix
      app/assets/javascripts/components/nav/hamburger_menu.jsx on lines 55..64

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

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

      const Course = withRouter((props) => {
        useEffect(() => {
          // Fetch all the data needed to render a course page
          const courseSlug = getCourseSlug();
          props.fetchCourse(courseSlug);
      Severity: Major
      Found in app/assets/javascripts/components/course/course.jsx - About 4 hrs to fix

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

          return (
            <div
              onMouseEnter={() => setConfirmingDelete(true)} // Show blue icon on hover
              onMouseLeave={() => setConfirmingDelete(false)} // Show grey icon when not hovered
              onClick={confirmDeletion} // Trigger the delete action
        app/assets/javascripts/components/nav/news/create_news/options/post_news.jsx on lines 23..34

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

        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 (
            <div
              onMouseEnter={() => setPostNewsIcon(true)} // Show blue icon on hover
              onMouseLeave={() => setPostNewsIcon(false)} // Show grey icon when not hovered
              onClick={handlePostNews} // Trigger the post news action
        app/assets/javascripts/components/nav/news/news_content/options/confirm_delete_news.jsx on lines 17..28

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

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

        const Panel = (props) => {
          const persistState = () => {
              const step = props.step.toLowerCase().split(' ').slice(0, 2);
              step[1] = +step[1] + 1; // Keeping the step in line with the UI
              window.history.pushState(
        Severity: Major
        Found in app/assets/javascripts/components/wizard/panel.jsx - About 4 hrs to fix

          Function OnboardingSupplementary has 101 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export const OnboardingSupplementary = (props) => {
            const formRef = useRef(null);
            const navigate = useNavigate();
            const [state, setState] = useState({
              heardFrom: '',
          Severity: Major
          Found in app/assets/javascripts/components/onboarding/supplementary.jsx - About 4 hrs to fix

            Function onreadystatechange has 100 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            document.onreadystatechange = () => {
              if (document.readyState === 'complete') {
                // Find tables with rows with data-link attribute, then make them clickable
                document.querySelector('tr[data-link]')?.addEventListener('click', (e) => {
                  // skip if a button was clicked (used for other actions)
            Severity: Major
            Found in app/assets/javascripts/utils/course.js - About 4 hrs to fix

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

                return (
                  <div className="form-group">
                    <label id="course_level-label" htmlFor="course_level">Course level:</label>
                    <Select
                      id="course_level"
              app/assets/javascripts/components/course_creator/course_format_selector.jsx on lines 20..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 115.

              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 (
                  <div className="form-group">
                    <label id="course_format-label" htmlFor="course_format">Course format:</label>
                    <Select
                      id="course_format"
              app/assets/javascripts/components/course_creator/course_level_selector.jsx on lines 19..32

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

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

                  const updateAlerts = () => {
                    const newAlerts = [];
              
                    // //////////////////////////////////
                    // Admin / Instructor notifications /
              Severity: Major
              Found in app/assets/javascripts/components/course/course_alerts.jsx - About 3 hrs to fix

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

                    if (partitioned.modules.length) {
                      modules.push(<TrainingModules
                        all_modules={props.all_training_modules}
                        block_modules={partitioned.modules}
                        block={block}
                app/assets/javascripts/components/timeline/TrainingModules/TrainingModulesViewMode.jsx on lines 36..47
                app/assets/javascripts/components/timeline/TrainingModules/TrainingModulesViewMode.jsx on lines 49..60

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

                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

                    if (partitioned.discussions.length) {
                      modules.push(<TrainingModules
                        all_modules={props.all_training_modules}
                        block_modules={partitioned.discussions}
                        block={block}
                app/assets/javascripts/components/timeline/TrainingModules/TrainingModulesViewMode.jsx on lines 23..34
                app/assets/javascripts/components/timeline/TrainingModules/TrainingModulesViewMode.jsx on lines 36..47

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

                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

                    if (partitioned.exercises.length) {
                      modules.push(<TrainingModules
                        all_modules={props.all_training_modules}
                        block_modules={partitioned.exercises}
                        block={block}
                app/assets/javascripts/components/timeline/TrainingModules/TrainingModulesViewMode.jsx on lines 23..34
                app/assets/javascripts/components/timeline/TrainingModules/TrainingModulesViewMode.jsx on lines 49..60

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

                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 Row = ({ link, title }) => (
                  <tr className="training-module">
                    <td className="block__training-modules-table__module-name">{ title }</td>
                    <td className="block__training-modules-table__module-link">
                      <a href={link} target="_blank">
                Severity: Major
                Found in app/assets/javascripts/components/resources/templates.jsx and 1 other location - About 3 hrs to fix
                app/assets/javascripts/components/resources/videos.jsx on lines 8..18

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

                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

                Severity
                Category
                Status
                Source
                Language