WikiEducationFoundation/WikiEduDashboard

View on GitHub

Showing 464 of 1,680 total issues

Function ActiveCourseList has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

const ActiveCourseList = ({ defaultCampaignOnly = true }) => {
  const { isLoaded, courses, sort } = useSelector(state => state.active_courses);
  const dispatch = useDispatch();

  useEffect(() => {
Severity: Minor
Found in app/assets/javascripts/components/course/active_course_list.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 fetchReferencesAddedFromWiki has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const fetchReferencesAddedFromWiki = async (wiki_url, revisions) => {
  const wiki = getWikiObjectFromURL(wiki_url);
  if (!isSupportedORESWiki(wiki)) {
    // wiki is not supported
    return;
Severity: Minor
Found in app/assets/javascripts/utils/media_wiki_references_utils.js - About 1 hr to fix

    Function validateCurrentQuestion has 35 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      validateCurrentQuestion(e) {
        e.preventDefault();
        const $target = $(e.target);
        const $block = $target.parents('.block');
        this.$currentBlock = $block;
    Severity: Minor
    Found in app/assets/javascripts/surveys/modules/Survey.js - About 1 hr to fix

      Function fetchRevisions has 35 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export const fetchRevisions = course => async (dispatch, getState) => {
        dispatch({ type: REVISIONS_LOADING });
        const state = getState();
        const users = state.users.users.filter(user => user.role === STUDENT_ROLE);
        if (users.length === 0) {
      Severity: Minor
      Found in app/assets/javascripts/actions/revisions_actions.js - About 1 hr to fix

        Function users has 35 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export default function users(state = initialState, action) {
          switch (action.type) {
            case RECEIVE_USERS: {
              // Transform the 'real_name' for users in 'action' into separate 'first_name'
              // and 'last_name' properties if 'real_name' is available by using transformUsers.
        Severity: Minor
        Found in app/assets/javascripts/reducers/users.js - About 1 hr to fix

          Function userRoles has 35 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            userRoles(currentUser, users) {
              // Role values correspond to the CoursesUsers roles defined
              const roles = {};
              if (!currentUser) { return roles; }
              if (getFiltered(users, { id: currentUser.id, role: STUDENT_ROLE })[0]) {
          Severity: Minor
          Found in app/assets/javascripts/utils/user_utils.js - About 1 hr to fix

            Function Campaign has 35 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export const Campaign = () => {
              const dispatch = useDispatch();
              const campaign = useSelector(state => state.campaign);
            
              const { campaign_slug } = useParams();
            Severity: Minor
            Found in app/assets/javascripts/components/campaign/campaign.jsx - About 1 hr to fix

              Function handleParentConditionalChange has 34 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                handleParentConditionalChange(value, conditionalGroup, $parent) {
                  let { currentAnswers } = conditionalGroup;
                  let conditional;
                  // let resetQuestions = false;
              
              
              Severity: Minor
              Found in app/assets/javascripts/surveys/modules/Survey.js - About 1 hr to fix

                Function searchForPages has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  async searchForPages(wiki, search_term, namespace, map=(el)=>el, depth, limit=10){
                    let search_query;
                    if(search_term.split(' ').length > 1){
                      // if we have multiple words, search for the exact words
                      search_query = `intitle:${search_term}`;
                Severity: Minor
                Found in app/assets/javascripts/utils/api.js - About 1 hr to fix

                  Function Controls has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  export const Controls = (props) => {
                    const {
                      course, current_user, students, notify, showOverviewFilters, sortSelect
                    } = props;
                  
                  

                    Function search_results has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

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

                      Function LanguagePicker has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      const LanguagePicker = () => {
                        const enN = getNativeName('en');
                        const esN = getNativeName('es');
                        const frN = getNativeName('fr');
                      
                      
                      Severity: Minor
                      Found in app/assets/javascripts/components/nav/language_picker.jsx - About 1 hr to fix

                        Function processQuestionGroupData has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          processQuestionGroupData(data) {
                            const _postData = {};
                            const answerGroup = {};
                            data.forEach((field) => {
                              const { name } = field;
                        Severity: Minor
                        Found in app/assets/javascripts/surveys/modules/Survey.js - About 1 hr to fix

                          Function validations has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          export default function validations(state = initialState, action) {
                            switch (action.type) {
                              // This adds a validation, but without marking it 'changed'.
                              // This means no error message gets added to the queue.
                              case ADD_VALIDATION: {
                          Severity: Minor
                          Found in app/assets/javascripts/reducers/validations.js - About 1 hr to fix

                            Function TemplatesScoping has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            const TemplatesScoping = () => {
                              const templates = useSelector(state => state.scopingMethods.templates.include);
                              const home_wiki = useSelector(state => state.course.home_wiki);
                              const [currentWiki, setCurrentWiki] = useState(home_wiki);
                              return (

                              Function news has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

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

                                Function ConfigureSiteNotice has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                const ConfigureSiteNotice = (props) => {
                                  const [isSiteNotice, setIsSiteNotice] = useState();
                                  const dispatch = useDispatch();
                                
                                  const getKey = () => {

                                  Function Expandable has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                  const Expandable = function (Component) {
                                    const wrappedComponent = createReactClass({
                                      displayName: 'Expandable',
                                  
                                      statics: {
                                  Severity: Minor
                                  Found in app/assets/javascripts/components/high_order/expandable.jsx - About 1 hr to fix

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

                                      render() {
                                        const currentWeek = CourseDateUtils.currentWeekOrder(this.props.timelineStart);
                                        const weekNumberOffset = CourseDateUtils.weeksBeforeTimeline(this.props.course);
                                        const blocks = [];
                                    
                                    
                                    Severity: Minor
                                    Found in app/assets/javascripts/components/overview/milestones.jsx - About 1 hr to fix

                                      Function NotificationsBell has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                                      Open

                                      const NotificationsBell = () => {
                                        const [hasOpenTickets, setHasOpenTickets] = useState(false);
                                        const [hasRequestedAccounts, setHasRequestedAccounts] = useState(false);
                                      
                                        useEffect(() => {
                                      Severity: Minor
                                      Found in app/assets/javascripts/components/nav/notifications_bell.jsx - About 1 hr to fix
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language