WikiEducationFoundation/WikiEduDashboard

View on GitHub

Showing 462 of 1,666 total issues

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

  render() {
    const canRename = this.canRename();
    const isClassroomProgramType = this.props.course.type === 'ClassroomProgramCourse';
    const timelineDatesDiffer = this.props.course.start !== this.props.course.timeline_start || this.props.course.end !== this.props.course.timeline_end;
    const eventSync = this.props.course.flags.event_sync;
Severity: Major
Found in app/assets/javascripts/components/overview/details.jsx - About 2 days to fix

    File language_names.js has 923 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    // adapted from https://github.com/meikidd/iso-639-1/blob/master/src/data.js
    
    const LanguageNames = {
        aa: {
          name: 'Afar',
    Severity: Major
    Found in app/assets/javascripts/utils/language_names.js - About 2 days to fix

      Function ArticleFinder has 334 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      const ArticleFinder = (props) => {
        const [isSubmitted, setIsSubmitted] = useState(false);
        const [showFilters, setShowFilters] = useState(false);
      
        useEffect(() => {
      Severity: Major
      Found in app/assets/javascripts/components/article_finder/article_finder.jsx - About 1 day to fix

        Function renderGraph has 300 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          const renderGraph = () => {
            if (articleData.length === 0) {
              return;
            }
        
        

          Function CourseApproval has 287 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          const CourseApproval = (props) => {
            const [selectedWikiExpert, setSelectedWikiExpert] = useState({});
            const [selectedCampaigns, setSelectedCampaigns] = useState([]);
            const [selectedTags, setSelectedTags] = useState([]);
            const [createdTagOption, setCreatedTagOption] = useState([]);
          Severity: Major
          Found in app/assets/javascripts/components/course/course_approval.jsx - About 1 day to fix

            File Survey.js has 636 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            //--------------------------------------------------------
            // Vendor Requirements [imports]
            //--------------------------------------------------------
            import { assign, throttle } from 'lodash-es';
            import Rails from '@rails/ujs';
            Severity: Major
            Found in app/assets/javascripts/surveys/modules/Survey.js - About 1 day to fix

              File api.js has 607 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              import { capitalize } from './strings';
              import logErrorMessage from './log_error_message';
              import request from './request';
              import { stringify } from 'query-string';
              import Rails from '@rails/ujs';
              Severity: Major
              Found in app/assets/javascripts/utils/api.js - About 1 day to fix

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

                  render() {
                    if (this.props.loading) {
                      return <Loading />;
                    }
                
                
                Severity: Major
                Found in app/assets/javascripts/components/timeline/timeline.jsx - About 1 day to fix

                  Function CourseForm has 255 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  const CourseForm = (props) => {
                    const handleWikiChange = (wiki) => {
                      const home_wiki = wiki.value;
                      const prev_wiki = { ...props.course.home_wiki };
                      const wikis = CourseUtils.normalizeWikis(
                  Severity: Major
                  Found in app/assets/javascripts/components/course_creator/course_form.jsx - About 1 day to fix

                    File details.jsx has 583 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 Instructors from './instructors';
                    Severity: Major
                    Found in app/assets/javascripts/components/overview/details.jsx - About 1 day to fix

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

                        render() {
                          const i18nPrefix = this.props.course.string_prefix;
                          let buttonClass = 'button dark';
                          buttonClass += this.state.isPersisting ? ' working' : '';
                      
                      
                      Severity: Major
                      Found in app/assets/javascripts/components/overview/course_cloned_modal.jsx - About 1 day to fix

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

                        import '../testHelper';
                        import { getLastUpdateMessage, getFirstUpdateMessage, firstUpdateTime, lastSuccessfulUpdateMoment, nextUpdateExpected, getLastUpdateSummary, getTotaUpdatesMessage, getUpdateLogs } from '../../app/assets/javascripts/utils/statistic_update_info_utils';
                        
                        describe('firstUpdateTime', () => {
                          test(
                        Severity: Major
                        Found in test/utils/statistic_update_info_utils.spec.js - About 1 day to fix

                          File settings_actions.js has 512 lines of code (exceeds 250 allowed). Consider refactoring.
                          Open

                          
                          import {
                            SET_ADMIN_USERS, SET_SPECIAL_USERS,
                            SUBMITTING_NEW_SPECIAL_USER, REVOKING_SPECIAL_USER,
                            SUBMITTING_NEW_ADMIN, REVOKING_ADMIN, SET_COURSE_CREATION_SETTINGS,
                          Severity: Major
                          Found in app/assets/javascripts/actions/settings_actions.js - About 1 day to fix

                            Function Block has 206 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            const Block = (props) => {
                            const updateBlock = (valueKey, value) => {
                                const toPass = { ...props.block };
                                toPass[valueKey] = value;
                                delete toPass.deleteBlock;
                            Severity: Major
                            Found in app/assets/javascripts/components/timeline/block.jsx - About 1 day to fix

                              Function TrainingSlideHandler has 199 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              const TrainingSlideHandler = () => {
                                const training = useSelector(state => state.training);
                                const routeParams = useParams();
                                const navigate = useNavigate();
                                const dispatch = useDispatch();
                              Severity: Major
                              Found in app/assets/javascripts/training/components/training_slide_handler.jsx - About 7 hrs to fix

                                Function List has a Cognitive Complexity of 50 (exceeds 5 allowed). Consider refactoring.
                                Open

                                const List = ({
                                  keys,
                                  sortable,
                                  table_key,
                                  className,
                                Severity: Minor
                                Found in app/assets/javascripts/components/common/list.jsx - About 7 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 render has a Cognitive Complexity of 48 (exceeds 5 allowed). Consider refactoring.
                                Open

                                  render() {
                                    const canRename = this.canRename();
                                    const isClassroomProgramType = this.props.course.type === 'ClassroomProgramCourse';
                                    const timelineDatesDiffer = this.props.course.start !== this.props.course.timeline_start || this.props.course.end !== this.props.course.timeline_end;
                                    const eventSync = this.props.course.flags.event_sync;
                                Severity: Minor
                                Found in app/assets/javascripts/components/overview/details.jsx - About 7 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 183 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                export default function articleFinder(state = initialState, action) {
                                  switch (action.type) {
                                    case UPDATE_FINDER_FIELD: {
                                      const newState = { ...state };
                                      newState[action.data.key] = action.data.value;
                                Severity: Major
                                Found in app/assets/javascripts/reducers/article_finder.js - About 7 hrs to fix

                                  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
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language