WikiEducationFoundation/WikiEduDashboard

View on GitHub

Showing 453 of 1,605 total issues

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

      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

        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

                Function ArticleFinder has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
                Open

                const ArticleFinder = (props) => {
                  const [isSubmitted, setIsSubmitted] = useState(false);
                  const [showFilters, setShowFilters] = useState(false);
                
                  useEffect(() => {
                Severity: Minor
                Found in app/assets/javascripts/components/article_finder/article_finder.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

                File course_utils.spec.js has 404 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                import '../testHelper';
                import courseUtils from '../../app/assets/javascripts/utils/course_utils.js';
                
                describe('courseUtils.generateTempId', () => {
                  test('creates a slug from term, title and school', () => {
                Severity: Minor
                Found in test/utils/course_utils.spec.js - About 5 hrs to fix

                  Function Form has 142 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  const Form = (props) => {
                    const [state, setState] = useState({
                      started: false,
                      user: props.currentUser,
                      name: props.currentUser.real_name,
                  Severity: Major
                  Found in app/assets/javascripts/components/onboarding/form.jsx - About 5 hrs to fix

                    File article_finder.jsx has 399 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    import React, { useState, useEffect } from 'react';
                    import { connect } from 'react-redux';
                    import InputRange from 'react-input-range';
                    import { includes, map, find } from 'lodash-es';
                    import qs from 'query-string';
                    Severity: Minor
                    Found in app/assets/javascripts/components/article_finder/article_finder.jsx - About 5 hrs to fix

                      Function EditSizeGraph has 136 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      const EditSizeGraph = (props) => {
                        useEffect(() => {
                          renderGraph();
                        }, []);
                      
                      
                      Severity: Major
                      Found in app/assets/javascripts/components/articles/edit_size_graph.jsx - About 5 hrs to fix

                        Function exports has 133 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        module.exports = (env) => {
                          const mode = env.development ? 'development' : 'production';
                          const isProductionOrCI = env.production || env.coverage;
                          let devtool = 'eval-cheap-source-map';
                          // see https://webpack.js.org/configuration/devtool/ for the detailed descriptions of these
                        Severity: Major
                        Found in webpack.config.js - About 5 hrs to fix

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

                            render() {
                              let content;
                              let faqLink;
                          
                              let wikipediaHelpButton;
                          Severity: Major
                          Found in app/assets/javascripts/components/common/get_help_button.jsx - About 5 hrs to fix

                            Function CourseDates has 126 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            const CourseDates = (props) => {
                              const updateCourseDates = (key, value) => {
                                const updatedCourse = CourseDateUtils.updateCourseDates(props.course, key, value);
                                props.updateCourseProps(updatedCourse);
                              };
                            Severity: Major
                            Found in app/assets/javascripts/components/course_creator/course_dates.jsx - About 5 hrs to fix
                              Severity
                              Category
                              Status
                              Source
                              Language