WikiEducationFoundation/WikiEduDashboard

View on GitHub

Showing 1,672 of 1,672 total issues

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

  } else if (!current_user) {
    link = <ArticleLink content={I18n.t(`users.${ArticleUtils.projectSuffix(course.home_wiki.project, 'no_articles')}`)} />;
  }
app/assets/javascripts/components/overview/my_articles/containers/index.jsx on lines 52..54

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 58.

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

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

            if (this.scrollObject[name].index >= length) {
                this.scrollObject[name].index = length - 1;
                this.nextPosition = paragraphs[this.scrollObject[name].index].coordinates;
                break;
            }
app/assets/javascripts/components/common/ArticleViewer/utils/ArticleScroll.js on lines 123..127

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 58.

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

const EditButton = ({
  allowMultipleArticles, current_user, is_open, setHover, open, role, student,
  tooltip, tooltipIndicator, assignmentLength, project
}) => {
  let assignText;
app/assets/javascripts/components/activity/activity_table_row.jsx on lines 7..64

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 58.

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

    <div
      onMouseEnter={() => setCancelPostIcon(true)} // Show red icon on hover
      onMouseLeave={() => setCancelPostIcon(false)} // Show grey icon when not hovered
      onClick={cancelNewsPost} // Call function to cancel news post confirmation
      className="pop__padded-content news--content edit-news-options-padded-content cancel-post"
app/assets/javascripts/components/nav/news/create_news/options/discard_news_creation.jsx on lines 8..17

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 58.

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

  if ((adminCourseNoteDetails.title.trim().length === 0) || (adminCourseNoteDetails.text.trim().length === 0)) {
    return sendNotification(dispatch, 'Error', 'notes.empty_fields');
  }
Severity: Major
Found in app/assets/javascripts/actions/admin_course_notes_action.js and 1 other location - About 1 hr to fix
app/assets/javascripts/actions/admin_course_notes_action.js on lines 70..72

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 58.

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

const ActivityTableRow = ({ isOpen, diffUrl, revisionDateTime,
  revisionScore, reportUrl, revision, rowId, articleUrl, title, talkPageLink,
  author }) => {
  const dispatch = useDispatch();

app/assets/javascripts/components/common/AssignCell/AssignButton.jsx on lines 163..196

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 58.

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

  useEffect(() => {
    // sets the title of this tab
    const header = I18n.t('users.sub_navigation.student_overview', { prefix });
    document.title = `${course.title} - ${header}`;
  }, []);
app/assets/javascripts/components/students/containers/Articles.jsx on lines 36..40

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 58.

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

  if ((adminCourseNoteDetails.title.trim().length === 0) || (adminCourseNoteDetails.text.trim().length === 0)) {
    return sendNotification(dispatch, 'Error', 'notes.empty_fields');
  }
Severity: Major
Found in app/assets/javascripts/actions/admin_course_notes_action.js and 1 other location - About 1 hr to fix
app/assets/javascripts/actions/admin_course_notes_action.js on lines 40..42

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 58.

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 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 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 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 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 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 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 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 _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

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

                    TrainingProgressDescription.propTypes = {
                      student: PropTypes.shape({
                        course_training_progress_description: PropTypes.string,
                        course_training_progress_assigned_count: PropTypes.number,
                        course_training_progress_completed_count: PropTypes.number
                    app/assets/javascripts/components/common/opt_in_notification.jsx on lines 16..22
                    app/assets/javascripts/components/students/components/Articles/SelectedStudent/ExercisesList/StudentExercise/ExerciseProgressDescription.jsx on lines 19..25

                    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 57.

                    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 7 locations. Consider refactoring.
                    Open

                    NewAccountModal.propTypes = {
                      course: PropTypes.object,
                      passcode: PropTypes.string,
                      newAccount: PropTypes.object,
                      closeModal: PropTypes.func,
                    app/assets/javascripts/components/activity/activity_table.jsx on lines 115..121
                    app/assets/javascripts/components/articles/salesforce_media_buttons.jsx on lines 43..49
                    app/assets/javascripts/components/assignments/assignment.jsx on lines 79..85
                    app/assets/javascripts/components/assignments/assignment_list.jsx on lines 79..85
                    app/assets/javascripts/components/uploads/upload_list.jsx on lines 91..97
                    app/assets/javascripts/training/components/quiz.jsx on lines 81..87

                    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 57.

                    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 7 locations. Consider refactoring.
                    Open

                    AssignmentList.propTypes = {
                      articles: PropTypes.array,
                      assignments: PropTypes.array,
                      course: PropTypes.object,
                      current_user: PropTypes.object,
                    app/assets/javascripts/components/activity/activity_table.jsx on lines 115..121
                    app/assets/javascripts/components/articles/salesforce_media_buttons.jsx on lines 43..49
                    app/assets/javascripts/components/assignments/assignment.jsx on lines 79..85
                    app/assets/javascripts/components/enroll/new_account_modal.jsx on lines 91..97
                    app/assets/javascripts/components/uploads/upload_list.jsx on lines 91..97
                    app/assets/javascripts/training/components/quiz.jsx on lines 81..87

                    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 57.

                    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