WikiEducationFoundation/WikiEduDashboard

View on GitHub

Showing 462 of 1,666 total issues

Function _renderDrawers has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  const _renderDrawers = () => {
    return activity.map((revision) => {
      const courses = revision.courses.map((course) => {
        return (
          <li key={`${revision.key}-${course.slug}`}>
Severity: Minor
Found in app/assets/javascripts/components/activity/activity_table.jsx - About 1 hr to fix

    Function renderConfirm has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      const renderConfirm = () => {
        let buttonContent;
        if (submittingNewAdmin) {
          buttonContent = (<div className="loading__spinner" />);
        } else {
    Severity: Minor
    Found in app/assets/javascripts/components/settings/views/add_admin_form.jsx - About 1 hr to fix

      Function fetchAll has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      const fetchAll = async (API_URL, params, continue_str) => {
        const allData = [];
        let continueToken;
        let hasMore = true;
        while (hasMore) {
      Severity: Minor
      Found in app/assets/javascripts/utils/mediawiki_revisions_utils.js - About 1 hr to fix

        Function groupByAssignmentType has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export const groupByAssignmentType = (assignments, user_id) => {
          // Unassigned to anyone
          const unassignedOptions = { user_id: null, role: ASSIGNED_ROLE };
          const unassigned = getFiltered(assignments, unassignedOptions);
        
        
        Severity: Minor
        Found in app/assets/javascripts/components/util/helpers.js - About 1 hr to fix

          Function wiki_courses has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export default function wiki_courses(state = initialState, action) {
            switch (action.type) {
              case RECEIVE_WIKI_COURSES: {
                return {
                  ...state,
          Severity: Minor
          Found in app/assets/javascripts/reducers/wiki_courses.js - About 1 hr to fix

            Function SiteNoticeForm has 29 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            const SiteNoticeForm = (props) => {
              const [siteNotice, setSiteNotice] = useState();
              const dispatch = useDispatch();
            
              const handleChange = (key, value) => {

              Function NewsPopoverHandler has 29 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              const NewsPopoverHandler = () => {
                // State to track whether the create news popover should be shown or not
                const [createNews, setCreateNews] = useState(false);
                const dispatch = useDispatch();
              
              
              Severity: Minor
              Found in app/assets/javascripts/components/nav/news/news_popover_handler.jsx - About 1 hr to fix

                Function sortByKey has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                export const sortByKey = (models, sortKey, previousKey = null, desc = false, absolute = false, refresh = false) => {
                  const sameKey = sortKey === previousKey;
                  let newKey;
                  if (sameKey) {
                    newKey = null;
                Severity: Minor
                Found in app/assets/javascripts/utils/model_utils.js - About 1 hr to fix

                  Function articleListKeys has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  const articleListKeys = (course) => {
                    const articlesOrItems = ArticleUtils.articlesOrItems(course.home_wiki.project);
                    return {
                      rating_num: {
                        label: I18n.t('articles.rating'),
                  Severity: Minor
                  Found in app/assets/javascripts/components/articles/article_list_keys.js - About 1 hr to fix

                    Function active_courses has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    export default function active_courses(state = initialState, action) {
                      switch (action.type) {
                        case RECEIVE_ACTIVE_COURSES:
                        case RECEIVE_CAMPAIGN_ACTIVE_COURSES: {
                          return {
                    Severity: Minor
                    Found in app/assets/javascripts/reducers/active_courses.js - About 1 hr to fix

                      Function settings has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      const settings = (state = initialState, action) => {
                        switch (action.type) {
                          case SET_ADMIN_USERS:
                            return Object.assign({}, state, { adminUsers: action.data.admins });
                          case SET_SPECIAL_USERS:
                      Severity: Minor
                      Found in app/assets/javascripts/reducers/settings.js - About 1 hr to fix

                        Function fetchPageViews has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        const fetchPageViews = (articlesList, wiki, dispatch, getState) => {
                          const promises = chunk(articlesList, 5).map((articles) => {
                            const query = pageviewQueryGenerator(map(articles, 'pageid'));
                            return limit(() => queryUrl(mediawikiApiBase(wiki.language, wiki.project), query))
                            .then(data => data.query.pages)
                        Severity: Minor
                        Found in app/assets/javascripts/actions/article_finder_action.js - About 1 hr to fix

                          Function CampaignAlerts has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          const CampaignAlerts = () => {
                            const [defaultFilters] = useState([
                              { value: 'ArticlesForDeletionAlert', label: 'Articles For Deletion' },
                              { value: 'DiscretionarySanctionsEditAlert', label: 'Discretionary Sanctions' }
                            ]);
                          Severity: Minor
                          Found in app/assets/javascripts/components/alerts/campaign_alerts.jsx - About 1 hr to fix

                            Function _renderNotification has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              const _renderNotification = (notification, i) => {
                                let message;
                                let className = 'notice';
                                if (notification.type === 'error') {
                                  message = (

                              Function _renderNotification has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                const _renderNotification = (notification, i) => {
                                  let message;
                                  let className = 'notice';
                                  if (notification.type === 'error') {
                                    message = (
                              Severity: Minor
                              Found in app/assets/javascripts/components/common/notifications.jsx - About 1 hr to fix

                                Function enroll has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                  const enroll = (e) => {
                                    e.preventDefault();
                                    const username = usernameRef.current.value;
                                    if (!username) { return; }
                                    const courseId = course.slug;
                                Severity: Minor
                                Found in app/assets/javascripts/components/common/enroll_button.jsx - About 1 hr to fix

                                  Function weekMeetings has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                    weekMeetings(course, exceptions) {
                                      const weekEnd = endOfWeek(toDate(course.timeline_end));
                                      let weekStart = startOfWeek(toDate(course.timeline_start));
                                      const firstWeekStart = getDay(toDate(course.timeline_start));
                                      const courseWeeks = differenceInWeeks(weekEnd, weekStart, { roundingMethod: 'round' });
                                  Severity: Minor
                                  Found in app/assets/javascripts/utils/course_date_utils.js - About 1 hr 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 saveUpdatedAdminCourseNote has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                  export const saveUpdatedAdminCourseNote = adminCourseNoteDetails => async (dispatch, getState) => {
                                    if ((adminCourseNoteDetails.title.trim().length === 0) || (adminCourseNoteDetails.text.trim().length === 0)) {
                                      return sendNotification(dispatch, 'Error', 'notes.empty_fields');
                                    }
                                  
                                  
                                  Severity: Minor
                                  Found in app/assets/javascripts/actions/admin_course_notes_action.js - About 1 hr 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 TrainingModulesViewMode has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                  const TrainingModulesViewMode = (props) => {
                                      const block = props.block;
                                      const modules = [];
                                      const length = block.training_modules.length;
                                  
                                  

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

                                  const NewAccountButton = ({ course, passcode, currentUser }) => {
                                    const [showModal, setShowModal] = useState(false);
                                    const [disabled, setDisabled] = useState(false);
                                    const [isHovered, setIsHovered] = useState(false);
                                  
                                  
                                  Severity: Minor
                                  Found in app/assets/javascripts/components/enroll/new_account_button.jsx - About 1 hr 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