WikiEducationFoundation/WikiEduDashboard

View on GitHub

Showing 462 of 1,667 total issues

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 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 CourseApproval has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
      Open

      const CourseApproval = (props) => {
        const [selectedWikiExpert, setSelectedWikiExpert] = useState({});
        const [selectedCampaigns, setSelectedCampaigns] = useState([]);
        const [selectedTags, setSelectedTags] = useState([]);
        const [createdTagOption, setCreatedTagOption] = useState([]);
      Severity: Minor
      Found in app/assets/javascripts/components/course/course_approval.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 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

              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 render has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
                      Open

                        render() {
                          const i18nPrefix = this.props.course.string_prefix;
                          let buttonClass = 'button dark';
                          buttonClass += this.state.isPersisting ? ' working' : '';
                      
                      
                      Severity: Minor
                      Found in app/assets/javascripts/components/overview/course_cloned_modal.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 WikiSelect has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
                      Open

                      const WikiSelect = ({ multi, onChange, styles, wikis, homeWiki, readOnly, label, id, options }) => {
                        // Function to generate URL for a wiki
                        const url = useCallback((wiki) => {
                          const subdomain = wiki.language || 'www';
                          return `${subdomain}.${wiki.project}.org`;
                      Severity: Minor
                      Found in app/assets/javascripts/components/common/wiki_select.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
                            Severity
                            Category
                            Status
                            Source
                            Language