WikiEducationFoundation/WikiEduDashboard

View on GitHub

Showing 457 of 1,626 total issues

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

Function timeline has 85 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export default function timeline(state = initialState, action) {
  switch (action.type) {
    case SAVED_TIMELINE:
    case RECEIVE_TIMELINE: {
      return {
Severity: Major
Found in app/assets/javascripts/reducers/timeline.js - About 3 hrs to fix

    Function renderGraph has 84 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 },

      CourseCreator has 28 functions (exceeds 20 allowed). Consider refactoring.
      Open

      const CourseCreator = createReactClass({
        displayName: 'CourseCreator',
      
        propTypes: {
          course: PropTypes.object.isRequired,
      Severity: Minor
      Found in app/assets/javascripts/components/course_creator/course_creator.jsx - About 3 hrs to fix

        Function uploads has 82 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export default function uploads(state = initialState, action) {
          switch (action.type) {
            case RECEIVE_UPLOADS: {
              const dataUploads = action.data.course.uploads;
              // Intial sorting by upload date
        Severity: Major
        Found in app/assets/javascripts/reducers/uploads.js - About 3 hrs to fix

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

            render() {
              if (this.props.readOnly) {
                const lastIndex = this.props.wikis.length - 1;
          
                const wikiList = map(this.props.wikis, (wiki, index) => {
          Severity: Major
          Found in app/assets/javascripts/components/common/wiki_select.jsx - About 3 hrs to fix

            File index.js has 303 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            import { createSelector } from 'reselect';
            import { sortBy, difference, uniq, filter, includes, pickBy, find } from 'lodash-es';
            import { getFiltered } from '../utils/model_utils';
            import { STUDENT_ROLE, INSTRUCTOR_ROLE, ONLINE_VOLUNTEER_ROLE, CAMPUS_VOLUNTEER_ROLE, STAFF_ROLE, fetchStates, ARTICLES_PER_PAGE, REVIEWING_ROLE } from '../constants';
            import UserUtils from '../utils/user_utils.js';
            Severity: Minor
            Found in app/assets/javascripts/selectors/index.js - About 3 hrs to fix

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

                render() {
                  const modifiers = {
                    ['outrange']: (day) => {
                      return !this.inrange(day);
                    },
              Severity: Minor
              Found in app/assets/javascripts/components/common/calendar.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 AvailableArticles has 81 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              const AvailableArticles = (props) => {
                useEffect(() => {
                  const project = props.course.home_wiki.project;
                  document.title = `${props.course.title} - ${ArticleUtils.I18n('available', project)}`;
                }, []);
              Severity: Major
              Found in app/assets/javascripts/components/articles/available_articles.jsx - About 3 hrs to fix

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

                  render() {
                    const dateProps = CourseDateUtils.dateProps(this.props.course);
                
                    const step1 = this.props.shouldShowSteps
                      ? <h2><span>1.</span><small> Confirm the course’s start and end dates.</small></h2>
                Severity: Major
                Found in app/assets/javascripts/components/wizard/form_panel.jsx - About 3 hrs to fix

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

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

                    Function Article has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
                    Open

                    const Article = ({ article, index, course, fetchArticleDetails, updateArticleTrackedStatus, articleDetails, wikidataLabel,
                      showOnMount, setSelectedIndex, lastIndex, selectedIndex, pageLogsMessage, deletedMessage, current_user }) => {
                      const [tracked, setTracked] = useState(article.tracked);
                    
                      const fetchMissingArticleDetails = () => {
                    Severity: Minor
                    Found in app/assets/javascripts/components/articles/article.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 EnrollButton has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
                    Open

                    const EnrollButton = ({ users, role, course, current_user, allowed, inline }) => {
                      const usernameRef = useRef(null);
                      const realNameRef = useRef(null);
                      const roleDescriptionRef = useRef(null);
                    
                    
                    Severity: Minor
                    Found in app/assets/javascripts/components/common/enroll_button.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 InputHOC has 77 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    const InputHOC = (Component) => {
                      const validatingComponent = createReactClass({
                        displayName: `Input${Component.displayName}`,
                    
                        // value passed is HOC's state value
                    Severity: Major
                    Found in app/assets/javascripts/components/high_order/input_hoc.jsx - About 3 hrs to fix

                      Function onload has 75 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      window.onload = () => {
                        const createCampaignButton = document.querySelector('.create-campaign-button');
                        const createModalWrapper = document.querySelector('.create-modal-wrapper');
                        const wizardPanel = document.querySelector('.wizard__panel');
                      
                      
                      Severity: Major
                      Found in app/assets/javascripts/campaigns.js - About 3 hrs to fix

                        File article_finder_language_mappings.js has 289 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

                        export const PageAssessmentGrades = {
                          wikipedia: {
                            en: {
                              FA: {
                                class: 'fa',
                        Severity: Minor
                        Found in app/assets/javascripts/utils/article_finder_language_mappings.js - About 2 hrs to fix

                          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

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

                              render() {
                                if (this.props.readOnly) {
                                  const lastIndex = this.props.wikis.length - 1;
                            
                                  const wikiList = map(this.props.wikis, (wiki, index) => {
                            Severity: Minor
                            Found in app/assets/javascripts/components/common/wiki_select.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

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