WikiEducationFoundation/WikiEduDashboard

View on GitHub

Showing 1,672 of 1,672 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

      <td>
        {isWikipedia && <div className={ratingMobileClass}><p>{article.pretty_rating}</p></div>}
        <p className="title">
          {articleLink}
        </p>
app/assets/javascripts/components/assignments/assignment.jsx on lines 66..71

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 77.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

        <td>
          {isWikipedia && <div className={ratingMobileClass}><p>{article.pretty_rating}</p></div>}
          <p className="title">
            {articleLink}
          </p>
Severity: Major
Found in app/assets/javascripts/components/assignments/assignment.jsx and 1 other location - About 2 hrs to fix
app/assets/javascripts/components/articles/available_article.jsx on lines 99..104

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 77.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  it('should handle RECEIVE_NEWS_CONTENT_LIST', () => {
    const initialState = {};
    const newsContentList = { id: 1, title: 'News Title' };

    const action = {
Severity: Major
Found in test/reducers/persisted_news.spec.js and 1 other location - About 2 hrs to fix
test/reducers/persisted_news.spec.js on lines 22..32

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 77.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  it('should handle PERSIST_NEWS_CONTENT', () => {
    const initialState = {};
    const newsContentList = { id: 1, title: 'News Title' };

    const action = {
Severity: Major
Found in test/reducers/persisted_news.spec.js and 1 other location - About 2 hrs to fix
test/reducers/persisted_news.spec.js on lines 10..20

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 77.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Function SearchableCourseList has a Cognitive Complexity of 16 (exceeds 5 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 2 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 EnrollCard has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

const EnrollCard = ({
  user, userRoles, course, courseLink, passcode, enrolledParam, enrollFailureReason
}) => {
  const [modalShown, setModalShown] = useState(false);
  const [isHovered, setIsHovered] = useState(false);
Severity: Minor
Found in app/assets/javascripts/components/enroll/enroll_card.jsx - About 2 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 16 (exceeds 5 allowed). Consider refactoring.
Open

  render() {
    const dateCalc = new DateCalculator(this.props.timeline_start, this.props.timeline_end, this.props.index, { zeroIndexed: false });
    let weekDatesContent;
    let meetDates;
    if (this.props.meetings && this.props.meetings.length > 0) {
Severity: Minor
Found in app/assets/javascripts/components/timeline/week.jsx - About 2 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 16 (exceeds 5 allowed). Consider refactoring.
Open

  render() {
    const keys = articleListKeys(this.props.course);
    const project = this.props.course.home_wiki.project;
    const trackedEditable = this.props.current_user && this.props.current_user.isAdvancedRole;

Severity: Minor
Found in app/assets/javascripts/components/articles/article_list.jsx - About 2 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 EditableRedux has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

const EditableRedux = (Component, Label) => {
  const editableComponent = createReactClass({
    displayName: 'EditableRedux',
    propTypes: {
      course_id: PropTypes.any,
Severity: Minor
Found in app/assets/javascripts/components/high_order/editable_redux.jsx - About 2 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 UploadList has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

const UploadList = ({ uploads, view, sortBy, loadingUploads, totalUploadsCount }) => {
  let elements;
  let noUploadsMessage;
  if (uploads.length > 0) {
    elements = uploads.map(upload => (
Severity: Minor
Found in app/assets/javascripts/components/uploads/upload_list.jsx - About 2 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 AssignmentLinks has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

const AssignmentLinks = ({ assignment, courseType, user, course, project, editMode }) => {
  const { article_url, id, role, editors } = assignment;
  const actions = [];

  if ((editors && editors.length) || assignment.role === ASSIGNED_ROLE) {

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 CategoriesScoping has 52 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const CategoriesScoping = () => {
  const depth = useSelector(state => state.scopingMethods.categories.depth);
  const categories = useSelector(state => state.scopingMethods.categories.tracked);
  const home_wiki = useSelector(state => state.course.home_wiki);
  const dispatch = useDispatch();

    File training_slide_handler.jsx has 253 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import React, { useEffect, useState } from 'react';
    import { useNavigate, useParams } from 'react-router';
    import { extend } from 'lodash-es';
    import { useDispatch, useSelector } from 'react-redux';
    import { fetchTrainingModule, setSlideCompleted, setCurrentSlide, toggleMenuOpen } from '../../actions/training_actions.js';
    Severity: Minor
    Found in app/assets/javascripts/training/components/training_slide_handler.jsx - About 2 hrs to fix

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

            assignButton = (
              <AssignCell
                assignments={assigned}
                assignmentsLength={assigned.length}
                course={course}
      app/assets/javascripts/components/students/shared/StudentList/Student/Student.jsx on lines 95..107

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 76.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

            reviewButton = (
              <AssignCell
                assignments={reviewing}
                assignmentsLength={reviewing.length}
                course={course}
      app/assets/javascripts/components/students/shared/StudentList/Student/Student.jsx on lines 81..93

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 76.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Function articleFromTitleInput has 51 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        static articleFromTitleInput(articleTitleInput) {
          const articleTitle = articleTitleInput;
          if (!/http/.test(articleTitle)) {
            const title = articleTitle.replace(/_/g, ' ');
            return {
      Severity: Major
      Found in app/assets/javascripts/utils/course_utils.js - About 2 hrs to fix

        Function SettingsHandler has 51 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        const SettingsHandler = () => {
          const dispatch = useDispatch();
        
          const adminUsers = useSelector(state => state.settings.adminUsers);
          const specialUsers = useSelector(state => state.settings.specialUsers);
        Severity: Major
        Found in app/assets/javascripts/components/settings/settings_handler.jsx - About 2 hrs to fix

          Function newsContent has 51 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            const newsContent = newsContentList.map((news, index) => {
              const isCurrentlyEditedNews = editNewsId === news.id;
              const isHovered = newsHoverId === news.id;
              const confirmDelete = confirmDeleteNewsId === news.id;
              // Opaque text area input when admin selects delete news

            Function downgradeSpecialUser has 50 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export const downgradeSpecialUser = (username, position) => (dispatch) => {
              // remove a user's admin status
              // username: user's username
              dispatch({
                type: REVOKING_SPECIAL_USER,
            Severity: Minor
            Found in app/assets/javascripts/actions/settings_actions.js - About 2 hrs to fix

              Similar blocks of code found in 4 locations. Consider refactoring.
              Open

              StudentDrawer.propTypes = {
                course: PropTypes.object,
                exerciseView: PropTypes.bool,
                student: PropTypes.object,
                isOpen: PropTypes.bool,
              app/assets/javascripts/components/enroll/enroll_card.jsx on lines 97..105
              app/assets/javascripts/components/revisions/revision.jsx on lines 46..54
              app/assets/javascripts/components/user_profiles/instructor_stats.jsx on lines 108..116

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 75.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Severity
              Category
              Status
              Source
              Language