WikiEducationFoundation/WikiEduDashboard

View on GitHub

Showing 462 of 1,666 total issues

Function Course has 102 lines of code (exceeds 25 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: Major
Found in app/assets/javascripts/components/course/course.jsx - About 4 hrs to fix

    Function Panel has 101 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    const Panel = (props) => {
      const persistState = () => {
          const step = props.step.toLowerCase().split(' ').slice(0, 2);
          step[1] = +step[1] + 1; // Keeping the step in line with the UI
          window.history.pushState(
    Severity: Major
    Found in app/assets/javascripts/components/wizard/panel.jsx - About 4 hrs to fix

      Function OnboardingSupplementary has 101 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export const OnboardingSupplementary = (props) => {
        const formRef = useRef(null);
        const navigate = useNavigate();
        const [state, setState] = useState({
          heardFrom: '',
      Severity: Major
      Found in app/assets/javascripts/components/onboarding/supplementary.jsx - About 4 hrs to fix

        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

          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 });

                                Function TimelineHandler has 89 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                const TimelineHandler = (props) => {
                                  const [reorderable, setReorderable] = useState(false);
                                  const [editableTitles, setEditableTitles] = useState(false);
                                
                                // Replace componentDidMount with useEffect hook
                                Severity: Major
                                Found in app/assets/javascripts/components/timeline/timeline_handler.jsx - About 3 hrs to fix

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