WikiEducationFoundation/WikiEduDashboard

View on GitHub

Showing 462 of 1,667 total issues

Function default has 73 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export default function (state = initialState, action) {
  switch (action.type) {
    case DELETE_TICKET: {
      const all = removeTicket(state.all, action.id);
      return {
Severity: Major
Found in app/assets/javascripts/reducers/tickets.js - About 2 hrs to fix

    File diff_viewer.jsx has 287 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 SalesforceMediaButtons from '../articles/salesforce_media_buttons.jsx';
    import Loading from '../common/loading.jsx';
    Severity: Minor
    Found in app/assets/javascripts/components/revisions/diff_viewer.jsx - About 2 hrs to fix

      File date_picker.jsx has 286 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 DayPicker from 'react-day-picker';
      import OnClickOutside from 'react-onclickoutside';
      Severity: Minor
      Found in app/assets/javascripts/components/common/date_picker.jsx - About 2 hrs to fix

        Function CourseTypeSelector has 69 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        const CourseTypeSelector = (props) => {
          const _getFormattedCourseType = (type) => {
            return {
              ClassroomProgramCourse: 'Wikipedia Student Program',
              VisitingScholarship: 'Visiting Scholarship',
        Severity: Major
        Found in app/assets/javascripts/components/overview/course_type_selector.jsx - About 2 hrs to fix

          Function revisions has a Cognitive Complexity of 20 (exceeds 5 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: Minor
          Found in app/assets/javascripts/reducers/revisions.js - About 2 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 NewsPopoverContent has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
          Open

          const NewsPopoverContent = ({ createNews }) => {
            // Retrieve the news content list from the Redux store
            const newsContentList = useSelector(state => state.news.news_content_list);
            const dispatch = useDispatch();
          
          

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

          const FinalArticleChecklist = () => {
            const checklistItems = [
              { key: '1', label: "The title is short and simple. It doesn't look like an essay, or ask a question." },
              { key: '2', label: 'The first sentence is direct and useful; it clearly defines the subject, with the topic of the article in bold.' },
              { key: '3', label: 'The lead section is a clear summary, not an introduction or argument. A reader could stop at the end of the lead and have a good overview of the most important aspects of the topic.' },
          Severity: Major
          Found in app/assets/javascripts/components/common/final_article_checklist.jsx - About 2 hrs to fix

            DiffViewer has 24 functions (exceeds 20 allowed). Consider refactoring.
            Open

            const DiffViewer = createReactClass({
              displayName: 'DiffViewer',
            
              // Diff viewer takes a main (final) revision, and optionally a first revision.
              // If a first revision is supplied, it fetches a diff from the parent of the
            Severity: Minor
            Found in app/assets/javascripts/components/revisions/diff_viewer.jsx - About 2 hrs to fix

              Class DashboardPresenter has 24 methods (exceeds 20 allowed). Consider refactoring.
              Open

              class DashboardPresenter
                include Rails.application.routes.url_helpers
              
                attr_reader :courses, :current, :past, :submitted, :strictly_current, :current_user
              
              
              Severity: Minor
              Found in app/presenters/dashboard_presenter.rb - About 2 hrs to fix

                Function panels has 65 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    const panels = this.props.panels.map((panel, i) => {
                      const active = this.props.activePanelIndex === i;
                      const stepNumber = i + 1;
                      let outOf;
                      if (i > 1) {
                Severity: Major
                Found in app/assets/javascripts/components/wizard/wizard.jsx - About 2 hrs to fix

                  Function Course has a Cognitive Complexity of 19 (exceeds 5 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: Minor
                  Found in app/assets/javascripts/components/course/course.jsx - About 2 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 Assignment has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                  Open

                  const Assignment = (props) => {
                      if (!props.course.home_wiki) { return <div />; }
                      const article = props.article || CourseUtils.articleFromAssignment(props.assignmentGroup[0], props.course.home_wiki);
                      if (!article.formatted_title) {
                        article.formatted_title = CourseUtils.formattedArticleTitle(article, props.course.home_wiki, props.wikidataLabel);
                  Severity: Minor
                  Found in app/assets/javascripts/components/assignments/assignment.jsx - About 2 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

                  Method create_alerts has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def create_alerts
                      @courses.each do |course|
                        next unless course.type == 'ClassroomProgramCourse'
                        next unless course.approved? # No alerts needed for unapproved courses
                        next unless course.students.empty?
                  Severity: Minor
                  Found in lib/alerts/no_students_alert_manager.rb - About 2 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 course has 64 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  export default function course(state = initialState, action) {
                    switch (action.type) {
                      case TOGGLE_SCOPING_METHOD: {
                        if (state.selected.includes(action.method)) {
                          return {
                  Severity: Major
                  Found in app/assets/javascripts/reducers/scoping_methods.js - About 2 hrs to fix

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

                      render() {
                        let description;
                          if (this.props.source === 'pileid') {
                            description = (
                              <p>
                    Severity: Major
                    Found in app/assets/javascripts/components/categories/add_category_button.jsx - About 2 hrs to fix

                      Function YesNoSelector has 64 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      const YesNoSelector = (props) => {
                          const initialState = props.course[props.courseProperty] ? I18n.t('application.opt_yes') : I18n.t('application.opt_no');
                          const [selectedOption, setSelectedOption] = useState({ value: initialState, label: initialState });
                      
                        const _handleChange = (e) => {
                      Severity: Major
                      Found in app/assets/javascripts/components/overview/yes_no_selector.jsx - About 2 hrs to fix

                        Function ArticlesHandler has 63 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        const ArticlesHandler = (props) => {
                          const [loading, setLoading] = useState(true);
                        
                          useEffect(() => {
                            delayFetchAssignmentsAndArticles(props, () => setLoading(false));
                        Severity: Major
                        Found in app/assets/javascripts/components/articles/articles_handler.jsx - About 2 hrs to fix

                          File course_form.jsx has 271 lines of code (exceeds 250 allowed). Consider refactoring.
                          Open

                          import React from 'react';
                          import TextAreaInput from '../common/text_area_input.jsx';
                          import CreatableInput from '../common/creatable_input.jsx';
                          import TextInput from '../common/text_input.jsx';
                          import CourseLevelSelector from './course_level_selector.jsx';
                          Severity: Minor
                          Found in app/assets/javascripts/components/course_creator/course_form.jsx - About 2 hrs to fix

                            File article_list.jsx has 270 lines of code (exceeds 250 allowed). Consider refactoring.
                            Open

                            import React from 'react';
                            import PropTypes from 'prop-types';
                            import createReactClass from 'create-react-class';
                            import { bindActionCreators } from 'redux';
                            import { connect } from 'react-redux';
                            Severity: Minor
                            Found in app/assets/javascripts/components/articles/article_list.jsx - About 2 hrs to fix

                              Function Quiz has 62 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              const Quiz = (props) => {
                                const [selectedAnswerId, setSelectedAnswerId] = useState(null);
                              
                               const setAnswer = (e) => {
                                  return setSelectedAnswerId(e.currentTarget.getAttribute('data-answer-id'));
                              Severity: Major
                              Found in app/assets/javascripts/training/components/quiz.jsx - About 2 hrs to fix
                                Severity
                                Category
                                Status
                                Source
                                Language