WikiEducationFoundation/WikiEduDashboard

View on GitHub

Showing 454 of 1,606 total issues

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

    File course_approval.jsx has 333 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

      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

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

          const renderGraph = () => {
            const vegaSpec = {
              width: props.graphWidth,
              height: props.graphHeight,
              padding: 5,
        Severity: Major
        Found in app/assets/javascripts/components/articles/wp10_graph.jsx - About 3 hrs to fix

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

            render() {
              const modifiers = {
                ['outrange']: (day) => {
                  return !this.inrange(day);
                },
          Severity: Major
          Found in app/assets/javascripts/components/common/calendar.jsx - About 3 hrs to fix

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

              render() {
                if (!this.shouldShowDiff(this.props) || !this.props.revision) {
                  return (
                    <div className={`tooltip-trigger ${this.props.showButtonClass}`}>
                      <button onClick={this.showDiff} aria-label="Open Diff Viewer" className="icon icon-diff-viewer"/>
            Severity: Major
            Found in app/assets/javascripts/components/revisions/diff_viewer.jsx - About 3 hrs to fix

              Function render has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
              Open

                render() {
                  if (this.props.loadingUserCourses) {
                    return <div />;
                  }
                  // There are four fundamental states: NewOrClone, CourseForm, wizardForm and CloneChooser
              Severity: Minor
              Found in app/assets/javascripts/components/course_creator/course_creator.jsx - About 3 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 TrainingSlideHandler has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
              Open

              const TrainingSlideHandler = () => {
                const training = useSelector(state => state.training);
                const routeParams = useParams();
                const navigate = useNavigate();
                const dispatch = useDispatch();
              Severity: Minor
              Found in app/assets/javascripts/training/components/training_slide_handler.jsx - About 3 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 93 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                render() {
                  const dateCalc = new DateCalculator(this.props.timeline_start, this.props.timeline_end, this.props.index, { zeroIndexed: false });
                  let weekDatesContent;
                  let meetDates;
                  if (this.props.meetings && this.props.meetings.length > 0) {
              Severity: Major
              Found in app/assets/javascripts/components/timeline/week.jsx - About 3 hrs to fix

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

                  render() {
                    const course = this.props.course;
                    if (!course) { return <div />; }
                    const dateProps = CourseDateUtils.dateProps(course);
                    let courseLinkClass = 'dark button ';
                Severity: Major
                Found in app/assets/javascripts/components/timeline/meetings.jsx - About 3 hrs to fix

                  Function NamespaceSelect has 93 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  const NamespaceSelect = (props) => {
                    const [selectedNamespaces, setSelectedNamespaces] = useState([]);
                    const [options, setOptions] = useState([]);
                  
                    useEffect(() => {
                  Severity: Major
                  Found in app/assets/javascripts/components/common/namespace_select.jsx - About 3 hrs to fix

                    File course_quality_progress_graph.jsx has 321 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    /* global vegaEmbed */
                    import React, { useEffect } from 'react';
                    import PropTypes from 'prop-types';
                    
                    
                    

                      File ArticleViewer.jsx has 321 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      import React, { useEffect, useRef, useState } from 'react';
                      import PropTypes from 'prop-types';
                      import { useSelector, useDispatch } from 'react-redux';
                      
                      // Utilities

                        Class WikidataSummaryParser has 30 methods (exceeds 20 allowed). Consider refactoring.
                        Open

                        class WikidataSummaryParser
                          REVISION_CLASSIFICATIONS = {
                            'claims created' => :created_claim?,
                            'claims changed' => :changed_claim?,
                            'claims removed' => :removed_claim?,
                        Severity: Minor
                        Found in lib/wikidata_summary_parser.rb - About 3 hrs to fix

                          Function ImpactStatsForm has 90 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          const ImpactStatsForm = (props) => {
                              const [stats, setStats] = useState({});
                          
                              const handleChange = (key, value) => {
                                  setStats({ ...stats, [key]: value });

                            Class CoursesPresenter has 29 methods (exceeds 20 allowed). Consider refactoring.
                            Open

                            class CoursesPresenter
                              attr_reader :current_user, :campaign_param
                            
                              def initialize(current_user:, campaign_param: nil, courses_list: nil, page: nil, tag: nil)
                                @current_user = current_user
                            Severity: Minor
                            Found in app/presenters/courses_presenter.rb - About 3 hrs to fix

                              Function articles has 86 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              export default function articles(state = initialState, action) {
                                switch (action.type) {
                                  case RECEIVE_ARTICLES: {
                                    const wikis = uniqWith(
                                      map(action.data.course.articles, mapWikis),
                              Severity: Major
                              Found in app/assets/javascripts/reducers/articles.js - About 3 hrs to fix

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

                                const renderGraph = (statsData, graphWidth, graphHeight, courseStringPrefix) => {
                                  const vegaSpec = {
                                    width: graphWidth,
                                    height: graphHeight,
                                    padding: { top: 40, left: 70, right: 20, bottom: 35 },

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

                                    render() {
                                      const {
                                        assignments, course, current_user, editable,
                                        showRecent, student
                                      } = this.props;

                                    Function Block has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
                                    Open

                                    const Block = (props) => {
                                    const updateBlock = (valueKey, value) => {
                                        const toPass = { ...props.block };
                                        toPass[valueKey] = value;
                                        delete toPass.deleteBlock;
                                    Severity: Minor
                                    Found in app/assets/javascripts/components/timeline/block.jsx - About 3 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