WikiEducationFoundation/WikiEduDashboard

View on GitHub

Showing 1,672 of 1,672 total issues

Function FinalArticleChecklist has 67 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const FinalArticleChecklist = () => {
  const checklistItems = [
    { key: '1', label: "The title is short and simple. It doesn't look like an essay, or ask a question." },
    { key: '2', label: 'The first sentence is direct and useful; it clearly defines the subject, with the topic of the article in bold.' },
    { key: '3', label: 'The lead section is a clear summary, not an introduction or argument. A reader could stop at the end of the lead and have a good overview of the most important aspects of the topic.' },
Severity: Major
Found in app/assets/javascripts/components/common/final_article_checklist.jsx - About 2 hrs to fix

    DiffViewer has 24 functions (exceeds 20 allowed). Consider refactoring.
    Open

    const DiffViewer = createReactClass({
      displayName: 'DiffViewer',
    
      // Diff viewer takes a main (final) revision, and optionally a first revision.
      // If a first revision is supplied, it fetches a diff from the parent of the
    Severity: Minor
    Found in app/assets/javascripts/components/revisions/diff_viewer.jsx - About 2 hrs to fix

      Class DashboardPresenter has 24 methods (exceeds 20 allowed). Consider refactoring.
      Open

      class DashboardPresenter
        include Rails.application.routes.url_helpers
      
        attr_reader :courses, :current, :past, :submitted, :strictly_current, :current_user
      
      
      Severity: Minor
      Found in app/presenters/dashboard_presenter.rb - About 2 hrs to fix

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

                <div className="nav__item" id="dyk-link">
                  <p>
                    <NavLink
                      to="/recent-activity/dyk" className={({ isActive }) => (isActive ? 'active' : '')}
                    >
        app/assets/javascripts/components/activity/recent_activity_handler.jsx on lines 23..29
        app/assets/javascripts/components/activity/recent_activity_handler.jsx on lines 31..37

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

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

        export const addCampaign = (courseId, campaignId) => (dispatch) => {
          return (
            addCampaignsPromise(courseId, campaignId)
              .then((data) => {
                dispatch({
        Severity: Major
        Found in app/assets/javascripts/actions/campaign_actions.js and 3 other locations - About 2 hrs to fix
        app/assets/javascripts/actions/campaign_actions.js on lines 46..57
        app/assets/javascripts/actions/tag_actions.js on lines 60..71
        app/assets/javascripts/actions/tag_actions.js on lines 87..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 88.

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

        export const removeTag = (courseId, tag) => (dispatch) => {
          return (
            removeTagPromise(courseId, tag)
              .then((data) => {
                dispatch({
        Severity: Major
        Found in app/assets/javascripts/actions/tag_actions.js and 3 other locations - About 2 hrs to fix
        app/assets/javascripts/actions/campaign_actions.js on lines 46..57
        app/assets/javascripts/actions/campaign_actions.js on lines 73..84
        app/assets/javascripts/actions/tag_actions.js on lines 60..71

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

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

        export const removeCampaign = (courseId, campaignId) => (dispatch) => {
          return (
            removeCampaignsPromise(courseId, campaignId)
              .then((data) => {
                dispatch({
        Severity: Major
        Found in app/assets/javascripts/actions/campaign_actions.js and 3 other locations - About 2 hrs to fix
        app/assets/javascripts/actions/campaign_actions.js on lines 73..84
        app/assets/javascripts/actions/tag_actions.js on lines 60..71
        app/assets/javascripts/actions/tag_actions.js on lines 87..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 88.

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

        export const addTag = (courseId, tag) => (dispatch) => {
          return (
            addTagPromise(courseId, tag)
              .then((data) => {
                dispatch({
        Severity: Major
        Found in app/assets/javascripts/actions/tag_actions.js and 3 other locations - About 2 hrs to fix
        app/assets/javascripts/actions/campaign_actions.js on lines 46..57
        app/assets/javascripts/actions/campaign_actions.js on lines 73..84
        app/assets/javascripts/actions/tag_actions.js on lines 87..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 88.

        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

                <div className="nav__item" id="recent-edits-link">
                  <p>
                    <NavLink to="/recent-activity/recent-edits" className={({ isActive }) => (isActive ? 'active' : '')}>
                      {I18n.t('recent_activity.recent_edits')}
                    </NavLink>
        app/assets/javascripts/components/activity/recent_activity_handler.jsx on lines 13..21
        app/assets/javascripts/components/activity/recent_activity_handler.jsx on lines 31..37

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

        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

                <div className="nav__item" id="recent-uploads-link">
                  <p>
                    <NavLink to="/recent-activity/recent-uploads" className={({ isActive }) => (isActive ? 'active' : '')}>
                      {I18n.t('recent_activity.recent_uploads')}
                    </NavLink>
        app/assets/javascripts/components/activity/recent_activity_handler.jsx on lines 13..21
        app/assets/javascripts/components/activity/recent_activity_handler.jsx on lines 23..29

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

        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

          users_array = users_array.map((user) => {
            const [first_name, ...rest] = (user.real_name?.trim().toLowerCase() || '').split(' ');
            return { ...user, first_name, last_name: rest.join(' ') };
          });
        Severity: Major
        Found in test/reducers/users.spec.js and 1 other location - About 2 hrs to fix
        test/reducers/users.spec.js on lines 56..59

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

        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

          users_array = users_array.map((user) => {
            const [first_name, ...rest] = (user.real_name?.trim().toLowerCase() || '').split(' ');
            return { ...user, first_name, last_name: rest.join(' ') };
          });
        Severity: Major
        Found in test/reducers/users.spec.js and 1 other location - About 2 hrs to fix
        test/reducers/users.spec.js on lines 71..74

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

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

            const panels = this.props.panels.map((panel, i) => {
              const active = this.props.activePanelIndex === i;
              const stepNumber = i + 1;
              let outOf;
              if (i > 1) {
        Severity: Major
        Found in app/assets/javascripts/components/wizard/wizard.jsx - About 2 hrs to fix

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

          const removeTicket = (tickets, id) => {
            const ticket = tickets.find(tick => tick.id === id);
            const index = tickets.indexOf(ticket);
          
            return [
          Severity: Major
          Found in app/assets/javascripts/reducers/tickets.js and 1 other location - About 2 hrs to fix
          app/assets/javascripts/reducers/tickets.js on lines 58..65

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

          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 removeNote = (notes, id) => {
            const note = notes.find(item => item.id === id);
            const index = notes.indexOf(note);
            return [
              ...notes.slice(0, index),
          Severity: Major
          Found in app/assets/javascripts/reducers/tickets.js and 1 other location - About 2 hrs to fix
          app/assets/javascripts/reducers/tickets.js on lines 48..56

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

          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

          export default function badWorkAlert(state = initialState, action) {
            switch (action.type) {
              case BAD_WORK_ALERT_SUBMITTED:
                return { ...state, submitting: true };
              case BAD_WORK_ALERT_CREATED:
          Severity: Major
          Found in app/assets/javascripts/reducers/bad_work_alert.js and 1 other location - About 2 hrs to fix
          app/assets/javascripts/reducers/need_help_alert.js on lines 5..16

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

          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

          export default function needHelpAlert(state = initialState, action) {
            switch (action.type) {
              case NEED_HELP_ALERT_SUBMITTED:
                return { ...state, submitting: true };
              case NEED_HELP_ALERT_CREATED:
          Severity: Major
          Found in app/assets/javascripts/reducers/need_help_alert.js and 1 other location - About 2 hrs to fix
          app/assets/javascripts/reducers/bad_work_alert.js on lines 5..16

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

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

          const Assignment = (props) => {
              if (!props.course.home_wiki) { return <div />; }
              const article = props.article || CourseUtils.articleFromAssignment(props.assignmentGroup[0], props.course.home_wiki);
              if (!article.formatted_title) {
                article.formatted_title = CourseUtils.formattedArticleTitle(article, props.course.home_wiki, props.wikidataLabel);
          Severity: Minor
          Found in app/assets/javascripts/components/assignments/assignment.jsx - 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 Course has a Cognitive Complexity of 19 (exceeds 5 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: Minor
          Found in app/assets/javascripts/components/course/course.jsx - 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

          Method create_alerts has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
          Open

            def create_alerts
              @courses.each do |course|
                next unless course.type == 'ClassroomProgramCourse'
                next unless course.approved? # No alerts needed for unapproved courses
                next unless course.students.empty?
          Severity: Minor
          Found in lib/alerts/no_students_alert_manager.rb - 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

          Severity
          Category
          Status
          Source
          Language