WikiEducationFoundation/WikiEduDashboard

View on GitHub

Showing 1,605 of 1,605 total issues

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

      <td className="tooltip-trigger desktop-only-tc">
        {isWikipedia && <p className="rating_num hidden">{revision.rating_num}</p>}
        {isWikipedia && <div className={ratingClass}><p>{revision.pretty_rating || '-'}</p></div>}
        {isWikipedia && <div className="tooltip dark">
          <p>{I18n.t(`articles.rating_docs.${revision.rating || '?'}`, { class: revision.rating || '' })}</p>
Severity: Major
Found in app/assets/javascripts/components/revisions/revision.jsx and 1 other location - About 7 hrs to fix
app/assets/javascripts/components/assignments/assignment.jsx 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 179.

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

Survey has 51 functions (exceeds 20 allowed). Consider refactoring.
Open

const Survey = {

  currentBlock: 0,
  submitted: [],
  submittedAll: false,
Severity: Major
Found in app/assets/javascripts/surveys/modules/Survey.js - About 7 hrs to fix

    File course_creator.jsx has 459 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import React from 'react';
    import createReactClass from 'create-react-class';
    import PropTypes from 'prop-types';
    import { connect } from 'react-redux';
    import { Link } from 'react-router-dom';
    Severity: Minor
    Found in app/assets/javascripts/components/course_creator/course_creator.jsx - About 7 hrs to fix

      Function TicketsHandler has 171 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      const TicketsHandler = () => {
        const [page, setPage] = useState(0);
        const [mode, setMode] = useState('filter');
        const [searchQuery, setSearchQuery] = useState({ by_email_or_username: '', in_subject: '', in_content: '', by_course: '', });
      
      
      Severity: Major
      Found in app/assets/javascripts/components/tickets/tickets_handler.jsx - About 6 hrs to fix

        File AssignButton.jsx has 450 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import React, { useEffect, useState } from 'react';
        import PropTypes from 'prop-types';
        import { useDispatch } from 'react-redux';
        import { Link } from 'react-router-dom';
        
        
        Severity: Minor
        Found in app/assets/javascripts/components/common/AssignCell/AssignButton.jsx - About 6 hrs to fix

          Function ArticleViewer has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring.
          Open

          const ArticleViewer = ({ showOnMount, users, showArticleFinder, showButtonLabel,
            fetchArticleDetails, assignedUsers, article, course, current_user = {},
            showButtonClass, showPermalink = true, title }) => {
            const [failureMessage, setFailureMessage] = useState(null);
            const [fetched, setFetched] = useState(false);

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

          export default function revisions(state = initialState, action) {
            switch (action.type) {
              case INCREASE_LIMIT: {
                let revisionsDisplayed = state.revisionsDisplayed.concat(
                  state.revisions.slice(
          Severity: Major
          Found in app/assets/javascripts/reducers/revisions.js - About 6 hrs to fix

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

              const onChangeHandler = (newValue, data) => {
                if (data.action !== 'input-change') return;
                if (!newValue) {
                  setInputValue('');
                  return;
            app/assets/javascripts/components/course_creator/scoping_methods/pagepile_scoping.jsx on lines 49..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 169.

            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 onChangeHandler = (newValue, data) => {
                if (data.action !== 'input-change') return;
                if (!newValue) {
                  setInputValue('');
                  return;
            app/assets/javascripts/components/course_creator/scoping_methods/petscan_scoping.jsx on lines 49..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 169.

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

            const ArticleFinderRow = (props) => {
                const [isLoading, setIsLoading] = useState(false);
                const prevPropsRef = useRef();
            
                // Note: This comment is applicable for the article finder row of a course

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

                        <DatePicker
                          id="timeline_end"
                          onChange={this.updateCourseDates}
                          value={this.state.dateValuesUpdated ? this.state.course.timeline_end : null}
                          value_key="timeline_end"
              app/assets/javascripts/components/overview/course_cloned_modal.jsx on lines 241..254

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

              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

                        <DatePicker
                          id="timeline_start"
                          onChange={this.updateCourseDates}
                          value={this.state.dateValuesUpdated ? this.state.course.timeline_start : null}
                          value_key="timeline_start"
              app/assets/javascripts/components/overview/course_cloned_modal.jsx on lines 255..268

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

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

              const ArticleFinderRow = (props) => {
                  const [isLoading, setIsLoading] = useState(false);
                  const prevPropsRef = useRef();
              
                  // Note: This comment is applicable for the article finder row of a course

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

                render() {
                  if (this.props.loadingUserCourses) {
                    return <div />;
                  }
                  // There are four fundamental states: NewOrClone, CourseForm, wizardForm and CloneChooser
              Severity: Major
              Found in app/assets/javascripts/components/course_creator/course_creator.jsx - About 6 hrs to fix

                File timeline.jsx has 424 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                import React from 'react';
                import createReactClass from 'create-react-class';
                import PropTypes from 'prop-types';
                import { HTML5Backend } from 'react-dnd-html5-backend';
                import { DndProvider } from 'react-dnd';
                Severity: Minor
                Found in app/assets/javascripts/components/timeline/timeline.jsx - About 6 hrs to fix

                  Function AvailableActions has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
                  Open

                  const AvailableActions = ({ course, current_user, updateCourse, courseCreationNotice }) => {
                    const dispatch = useDispatch();
                  
                    const join = (role = null) => {
                      const enrollURL = course.enroll_url;
                  Severity: Minor
                  Found in app/assets/javascripts/components/overview/available_actions.jsx - About 6 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 Nav has 152 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  const Nav = () => {
                    const {
                      rooturl: rootUrl,
                      logopath: logoPath,
                      fluid: fluidStr,
                  Severity: Major
                  Found in app/assets/javascripts/components/nav/nav.jsx - About 6 hrs to fix

                    Function render has 151 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      render() {
                        const keys = articleListKeys(this.props.course);
                        const project = this.props.course.home_wiki.project;
                        const trackedEditable = this.props.current_user && this.props.current_user.isAdvancedRole;
                    
                    
                    Severity: Major
                    Found in app/assets/javascripts/components/articles/article_list.jsx - About 6 hrs to fix

                      Function TextResults has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
                      Open

                      const TextResults = ({ followUpOnly, answers_data, follow_up_answers: followUpAnswers, sentiment, question }) => {
                        const [limit, setLimit] = useState();
                        const [buttonText, setbuttonText] = useState('More');
                      
                        const followUpAnswerCount = Object.keys(followUpAnswers).length;
                      Severity: Minor
                      Found in app/assets/javascripts/surveys/components/TextResults.jsx - About 5 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 AssignButton has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
                      Open

                      const AssignButton = ({ course, role, course_id, wikidataLabels = {}, hideAssignedArticles,
                        assignments, unassigned, student, allowMultipleArticles, current_user, isStudentsPage,
                        permitted, tooltip_message }) => {
                        const dispatch = useDispatch();
                        const [language, setLanguage] = useState('');
                      Severity: Minor
                      Found in app/assets/javascripts/components/common/AssignCell/AssignButton.jsx - About 5 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