WikiEducationFoundation/WikiEduDashboard

View on GitHub

Showing 462 of 1,666 total issues

Function alerts has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export default function alerts(state = initialState, action) {
  switch (action.type) {
    case RECEIVE_ALERTS: {
      const newState = { ...state };
      const sortedAlerts = sortByKey(action.data.alerts, 'created_at', null, SORT_DESCENDING.created_at);
Severity: Minor
Found in app/assets/javascripts/reducers/alerts.js - About 1 hr to fix

    Function renderWeekday has 32 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      const renderWeekday = (weekday) => {
        let dayClassName = 'DayPicker-Weekday';
        let customModifiers = [];
    
        if (modifiers) {
    Severity: Minor
    Found in app/assets/javascripts/components/common/weekday_picker.jsx - About 1 hr to fix

      Function useBlockDrag has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

      export const useBlockDrag = ({ block, isAnimating, canDrag, onBlockDragOver }) => {
        const ref = useRef(null);
      
        // this makes the block draggable
        const [{ isDragging }, drag] = useDrag({
      Severity: Minor
      Found in app/assets/javascripts/hooks/useBlockDrag.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 articles has a Cognitive Complexity of 11 (exceeds 5 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: Minor
      Found in app/assets/javascripts/reducers/articles.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 SpecialUser has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

      const SpecialUser = ({
        downgradeSpecialUser, // Prop for downgrading special user (renamed from action creator)
        position,
        username = 'Not Defined',
        realname = 'Not Defined',
      Severity: Minor
      Found in app/assets/javascripts/components/settings/views/special_user.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

      Function handleCourse has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

        handleCourse(course, isValidProp) {
          if (this.state.shouldRedirect === true) {
            window.location = `/courses/${course.slug}`;
            return this.setState({ shouldRedirect: false });
          }
      Severity: Minor
      Found in app/assets/javascripts/components/course_creator/course_creator.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

      Function CourseWikiList has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

      const CourseWikiList = ({ courses, sort }) => {
        const dispatch = useDispatch();
        if (sort.key) {
          // eslint-disable-next-line no-restricted-syntax
          for (const key of Object.keys(keys)) {

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

        def run_update
          log_start_of_update 'Daily update tasks are beginning.'
          update_users
          update_commons_uploads
          update_article_data
      Severity: Minor
      Found in lib/data_cycle/daily_update.rb - 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

      Method notification has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          def notification(survey_id, curr_user=nil)
            if curr_user.nil?
              # if curr_user is nil, then we haven't preloaded the user's notifications
              notifications = user.survey_notifications.completed.includes(survey_assignment: :survey)
            else
      Severity: Minor
      Found in config/initializers/surveys.rb - 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 editMode has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        const editMode = (e) => {
          e.preventDefault();
          const $parent = $(e.target).parents('.rails_editable');
          $parent.addClass('rails_editable-editing');
          $(e.target).hide();
      Severity: Minor
      Found in app/assets/javascripts/utils/editable.js - About 1 hr to fix

        Function wizard has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export default function wizard(state = initialState, action) {
          switch (action.type) {
            case RECEIVE_WIZARD_ASSIGNMENT_OPTIONS: {
              const assignmentOptions = action.assignmentOptions;
              return { ...state, assignmentOptions, panels: panels(assignmentOptions) };
        Severity: Minor
        Found in app/assets/javascripts/reducers/wizard.js - About 1 hr to fix

          Function assignments has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export default function assignments(state = initialState, action) {
            switch (action.type) {
              case RECEIVE_ASSIGNMENTS: {
                const dataAssignments = action.data.course.assignments;
                // Initial sorting by article title
          Severity: Minor
          Found in app/assets/javascripts/reducers/assignments.js - About 1 hr to fix

            Function UserProfile has 31 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            const UserProfile = () => {
              const dispatch = useDispatch();
              const stats = useSelector(state => state.userProfile.stats);
              const isLoading = useSelector(state => state.userProfile.isLoading);
              const userTrainingStatus = useSelector(state => state.userTrainingStatus);
            Severity: Minor
            Found in app/assets/javascripts/components/user_profiles/user_profile.jsx - About 1 hr to fix

              Function TicketShowHandler has 31 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              const TicketShowHandler = (props) => {
                const { id } = useParams();
              
                const dispatch = useDispatch();
              
              
              Severity: Minor
              Found in app/assets/javascripts/components/tickets/ticket_show_handler.jsx - About 1 hr to fix

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

                const fetchAllRevisions = async (API_URL, days, usernames, wiki, course_start, last_date) => {
                  let ucend;
                  let exitNext = false;
                  if (isBefore(subDays(toDate(last_date), days), toDate(course_start))) {
                    ucend = formatISO(toDate(course_start));
                Severity: Minor
                Found in app/assets/javascripts/utils/mediawiki_revisions_utils.js - About 1 hr to fix

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

                  const updateBlockPosition = (movingBlock, newWeekId, targetIndex, blocks) => {
                    const oldWeekId = movingBlock.id;
                    const movedBlock = { ...movingBlock };
                    movedBlock.week_id = newWeekId;
                    const weekChanged = newWeekId !== oldWeekId;
                  Severity: Minor
                  Found in app/assets/javascripts/reducers/timeline.js - About 1 hr to fix

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

                    export default function training(state = initialState, action) {
                      const data = action.data;
                      switch (action.type) {
                        case RECEIVE_TRAINING_MODULE: {
                          const newState = {
                    Severity: Minor
                    Found in app/assets/javascripts/reducers/training.js - About 1 hr to fix

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

                      const AcademicSystem = (props) => {
                        const [selectedOption, setSelectedOption] = useState(props.value || 'semester');
                      
                        useEffect(() => {
                          props.updateCourseProps({ academic_system: selectedOption });
                      Severity: Minor
                      Found in app/assets/javascripts/components/common/academic_system.jsx - About 1 hr to fix

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

                            const weekNav = weekNavInfo.map((weekInfo, navIndex) => {
                              let navClassName = 'week-nav__item';
                              if (navIndex === 0) {
                                navClassName += ' is-current';
                              }
                        Severity: Minor
                        Found in app/assets/javascripts/components/timeline/timeline.jsx - About 1 hr to fix

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

                          const DidYouKnowHandler = () => {
                            const myCoursesRef = useRef(null);
                          
                            const dispatch = useDispatch();
                            const articles = useSelector(state => state.didYouKnow.articles);
                          Severity: Minor
                          Found in app/assets/javascripts/components/activity/did_you_know_handler.jsx - About 1 hr to fix
                            Severity
                            Category
                            Status
                            Source
                            Language