WikiEducationFoundation/WikiEduDashboard

View on GitHub

Showing 1,672 of 1,672 total issues

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

export const deleteWeek = weekId => (dispatch) => {
  return deleteWeekPromise(weekId)
    .then(data => dispatch({
      type: DELETE_WEEK,
      weekId: data.week_id
Severity: Major
Found in app/assets/javascripts/actions/timeline_actions.js and 1 other location - About 2 hrs to fix
app/assets/javascripts/actions/timeline_actions.js on lines 60..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 85.

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

File article_list.jsx has 270 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import React from 'react';
import PropTypes from 'prop-types';
import createReactClass from 'create-react-class';
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
Severity: Minor
Found in app/assets/javascripts/components/articles/article_list.jsx - About 2 hrs to fix

    Function Quiz has 62 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    const Quiz = (props) => {
      const [selectedAnswerId, setSelectedAnswerId] = useState(null);
    
     const setAnswer = (e) => {
        return setSelectedAnswerId(e.currentTarget.getAttribute('data-answer-id'));
    Severity: Major
    Found in app/assets/javascripts/training/components/quiz.jsx - About 2 hrs to fix

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

                label={
                  <div className="tooltip-trigger">
                    <label htmlFor="templates">Templates To Include</label>
                    <span className="tooltip-indicator"/>
                    <div className="tooltip dark">
      app/assets/javascripts/components/course_creator/scoping_methods/categories_scoping.jsx on lines 23..31

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

      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

      export const fetchAllCampaigns = () => (dispatch) => {
        return (
          fetchAllCampaignsPromise()
            .then((data) => {
              dispatch({
      Severity: Major
      Found in app/assets/javascripts/actions/campaign_actions.js and 1 other location - About 2 hrs to fix
      app/assets/javascripts/actions/wizard_actions.js on lines 32..38

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

      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_NOTES_LIST', () => {
          const notesList = [{ id: 1, title: 'Note 1' }];
          const action = { type: types.RECEIVE_NOTES_LIST, notes_list: notesList };
      
          expect(courseNotesReducer(initialState, action)).toEqual({
      Severity: Major
      Found in test/reducers/admin_course_notes.spec.js and 1 other location - About 2 hrs to fix
      test/reducers/admin_course_notes.spec.js on lines 50..57

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

      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

      export const fetchWizardIndex = () => (dispatch) => {
        return fetchWizardIndexPromise()
          .then((data) => {
            dispatch({ type: RECEIVE_WIZARD_ASSIGNMENT_OPTIONS, assignmentOptions: data });
          })
      Severity: Major
      Found in app/assets/javascripts/actions/wizard_actions.js and 1 other location - About 2 hrs to fix
      app/assets/javascripts/actions/campaign_actions.js on lines 98..109

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

      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

                label={
                  <div className="tooltip-trigger">
                    <label htmlFor="categories">Categories To Include</label>
                    <span className="tooltip-indicator"/>
                    <div className="tooltip dark">
      app/assets/javascripts/components/course_creator/scoping_methods/templates_scoping.jsx on lines 22..30

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

      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 UPDATE_NOTES_LIST', () => {
          const updatedNotesList = [{ id: 1, title: 'Updated Note 1' }];
          const action = { type: types.UPDATE_NOTES_LIST, updatedNotesList };
          expect(courseNotesReducer(initialState, action)).toEqual({
            ...initialState,
      Severity: Major
      Found in test/reducers/admin_course_notes.spec.js and 1 other location - About 2 hrs to fix
      test/reducers/admin_course_notes.spec.js on lines 13..21

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

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

      export const StudentExerciseList = (props) => {
        const {
          assignments, course, current_user, editAssignments, exerciseView, openKey, selected,
          sort, trainingStatus, wikidataLabels, sortUsers, userRevisions = {}
        } = props;

        Function TextInput has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

        const TextInput = ({
          value,
          value_key,
          editable,
          label,
        Severity: Minor
        Found in app/assets/javascripts/components/common/text_input.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 CampaignList has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

        const CampaignList = ({ keys, showSearch, RowElement, headerText, userOnly, showStatistics = false }) => {
          const { all_campaigns, all_campaigns_loaded, sort } = useSelector(state => state.campaigns);
          const [searchParams, setSearchParams] = useSearchParams();
          const search = searchParams.get('search');
          const filteredCampaigns = showSearch && search ? all_campaigns.filter(campaign => campaign.title.toLowerCase().includes(search.toLowerCase())) : all_campaigns;
        Severity: Minor
        Found in app/assets/javascripts/components/campaign/campaign_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 course has 60 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export default function course(state = initialState, action) {
          switch (action.type) {
            case RECEIVE_COURSE:
              return { loading: false, ...action.data.course };
            case RECEIVE_COURSE_UPDATE: {
        Severity: Major
        Found in app/assets/javascripts/reducers/course.js - About 2 hrs to fix

          Function EditableRedux has 60 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          const EditableRedux = (Component, Label) => {
            const editableComponent = createReactClass({
              displayName: 'EditableRedux',
              propTypes: {
                course_id: PropTypes.any,
          Severity: Major
          Found in app/assets/javascripts/components/high_order/editable_redux.jsx - About 2 hrs to fix

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

              const fetchFilePath = () => {
                request(`/courses/${course.slug}/ores_plot.json`)
                  .then(resp => resp.json())
                  .then((data) => {
                    setFilePath(data.ores_plot);
            app/assets/javascripts/components/articles/course_ores_plot.jsx on lines 44..51

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

            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 fetchFile = () => {
                request(`/courses/${course.slug}/refresh_ores_data.json`)
                  .then(resp => resp.json())
                  .then((data) => {
                    setRefreshedData(data.ores_plot);
            app/assets/javascripts/components/articles/course_ores_plot.jsx on lines 53..60

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

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

            const Confirm = () => {
              const dispatch = useDispatch();
            
              const confirmationActive = useSelector(state => state.confirm.confirmationActive);
              const confirmMessage = useSelector(state => state.confirm.confirmMessage);
            Severity: Major
            Found in app/assets/javascripts/components/common/confirm.jsx - About 2 hrs to fix

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

                async deleteAdminCourseNote(adminCourseNoteId) {
                   try {
                       const response = await request(`/admin_course_notes/${adminCourseNoteId}`, {
                           method: 'DELETE',
                       });
              Severity: Major
              Found in app/assets/javascripts/utils/api.js and 1 other location - About 2 hrs to fix
              app/assets/javascripts/utils/api.js on lines 545..556

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

              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

              export const getArticlesByNewness = createSelector(
                [getWikiArticles, getNewnessFilter], (articles, newnessFilter) => {
                  switch (newnessFilter) {
                    case 'new':
                      return articles.filter(a => a.new_article);
              Severity: Major
              Found in app/assets/javascripts/selectors/index.js and 1 other location - About 2 hrs to fix
              app/assets/javascripts/selectors/index.js on lines 176..187

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

              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

              export const getArticlesByTrackedStatus = createSelector(
                [getArticlesByNewness, getTrackedStatusFilter], (articles, trackedStatusFilter) => {
                  switch (trackedStatusFilter) {
                    case 'tracked':
                      return articles.filter(a => a.tracked);
              Severity: Major
              Found in app/assets/javascripts/selectors/index.js and 1 other location - About 2 hrs to fix
              app/assets/javascripts/selectors/index.js on lines 163..174

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

              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