WikiEducationFoundation/WikiEduDashboard

View on GitHub

Showing 462 of 1,666 total issues

Function ArticleFinderSearchBar has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

function ArticleFinderSearchBar({ value, onChange, onSearch, disabled, wiki }) {
  const [suggestions, setSuggestions] = useState([]);
  const [isAutocompleteLoading, setAutocompleteLoading] = useState(false);
  let searchClass = 'article-finder-search-bar';

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

const NewReplyForm = ({ ticket, currentUser }) => {
  const dispatch = useDispatch();
  const [replyDetails, setReplyDetails] = useState({
    cc: '',
    content: '',
Severity: Minor
Found in app/assets/javascripts/components/tickets/new_reply_form.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 CourseTypeSelector has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

const CourseTypeSelector = (props) => {
  const _getFormattedCourseType = (type) => {
    return {
      ClassroomProgramCourse: 'Wikipedia Student Program',
      VisitingScholarship: 'Visiting Scholarship',
Severity: Minor
Found in app/assets/javascripts/components/overview/course_type_selector.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 OverviewStats has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

const OverviewStats = ({ course }) => {
  const isWikidata = course.home_wiki.project === 'wikidata';
  const isWikipedia = course.home_wiki.project === 'wikipedia';

  const valueClass = (stat) => {
Severity: Minor
Found in app/assets/javascripts/components/overview/overview_stats.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 upgradeSpecialUser has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const upgradeSpecialUser = (username, position) => (dispatch) => {
  // grant a user admin status
  // username: user's username
  dispatch({
    type: SUBMITTING_NEW_SPECIAL_USER,
Severity: Minor
Found in app/assets/javascripts/actions/settings_actions.js - About 1 hr to fix

    Function notifications has 39 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

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

      Function studentListKeys has 37 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      const studentListKeys = (course) => {
        const contentAddedKey = course.home_wiki_bytes_per_word ? wordsAddedKey : charactersAddedKey(course.home_wiki.project);
      
        return {
          username: {

        Function scrollTo has 36 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            scrollTo(name, scrollBox) {
                this.bump = false;
                const paragraphs = this.scrollObject[name].filteredParagraphs;
                const length = paragraphs.length;
                this.nextPosition = paragraphs[this.scrollObject[name].index].coordinates;

          Function fetchPageRevisionScore has 36 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          const fetchPageRevisionScore = async (revids, wiki, dispatch) => {
              const query = pageRevisionScoreQueryGenerator(map(revids, (revid) => {
                return revid.revisions[0].revid;
              }), wiki.project);
          
          
          Severity: Minor
          Found in app/assets/javascripts/actions/article_finder_action.js - About 1 hr to fix

            Function SearchableCourseList has 36 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            const SearchableCourseList = () => {
              const [searchParams, setSearchParams] = useSearchParams();
              const { results, loaded, sort } = useSelector(state => state.course_search_results);
              const dispatch = useDispatch();
              const searchRef = useRef();
            Severity: Minor
            Found in app/assets/javascripts/components/course/searchable_course_list.jsx - About 1 hr to fix

              Function PopoverExpandable has 36 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

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

                Function popover has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  popover() {
                    const PopoverExample = createReactClass({
                      getInitialState() {
                        return {
                          open: false
                Severity: Minor
                Found in app/assets/javascripts/styleguide/styleguide.jsx - About 1 hr to fix

                  Function InlineUsers has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  const InlineUsers = (props) => {
                    const lastUserIndex = props.users.length - 1;
                    let userList = props.users.map((user, index) => {
                      let extraInfo = '';
                      const link = `/users/${user.username}`; // User profile page
                  Severity: Minor
                  Found in app/assets/javascripts/components/overview/inline_users.jsx - About 1 hr to fix

                    Function fetchAll has a Cognitive Complexity of 12 (exceeds 5 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

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

                        scrollTo(name, scrollBox) {
                            this.bump = false;
                            const paragraphs = this.scrollObject[name].filteredParagraphs;
                            const length = paragraphs.length;
                            this.nextPosition = paragraphs[this.scrollObject[name].index].coordinates;

                    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 sortByKey has a Cognitive Complexity of 12 (exceeds 5 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

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

                    export const fetchRevisionsFromUsers = async (course, users, days, last_date, filter) => {
                      const usernames = users.map(user => user.username);
                    
                      let revisions = [];
                      const wikiPromises = [];
                    Severity: Minor
                    Found in app/assets/javascripts/utils/mediawiki_revisions_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 getFilteredArticleFinder has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                    Open

                      [getArticleFinderState], (articleFinder) => {
                        return pickBy(articleFinder.articles, (article) => {
                          const language = articleFinder.home_wiki.language;
                          const project = articleFinder.home_wiki.project;
                          if (article.grade && !includes(Object.keys(PageAssessmentGrades[project][language]), article.grade)) {
                    Severity: Minor
                    Found in app/assets/javascripts/selectors/index.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 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 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
                      Severity
                      Category
                      Status
                      Source
                      Language