WikiEducationFoundation/WikiEduDashboard

View on GitHub

Showing 1,672 of 1,672 total issues

Function CourseForm has 255 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const CourseForm = (props) => {
  const handleWikiChange = (wiki) => {
    const home_wiki = wiki.value;
    const prev_wiki = { ...props.course.home_wiki };
    const wikis = CourseUtils.normalizeWikis(
Severity: Major
Found in app/assets/javascripts/components/course_creator/course_form.jsx - About 1 day to fix

    File details.jsx has 583 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import React from 'react';
    import createReactClass from 'create-react-class';
    import PropTypes from 'prop-types';
    
    import Instructors from './instructors';
    Severity: Major
    Found in app/assets/javascripts/components/overview/details.jsx - About 1 day to fix

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

        render() {
          const i18nPrefix = this.props.course.string_prefix;
          let buttonClass = 'button dark';
          buttonClass += this.state.isPersisting ? ' working' : '';
      
      
      Severity: Major
      Found in app/assets/javascripts/components/overview/course_cloned_modal.jsx - About 1 day to fix

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

          describe('#wikiwhoColorURL', () => {
            it('should create a wikiwhoColorURL when given a valid article', () => {
              const helper = new URLBuilder({ article: defaults.article });
              const expected = 'https://wikiwho-api.wmcloud.org/en/whocolor/v1.0.0-beta/Brown%20Bear%2C%20Brown%20Bear%2C%20What%20Do%20You%20See%3F/0/';
              expect(helper.wikiwhoColorURL()).toEqual(expected);
        app/assets/javascripts/components/common/ArticleViewer/utils/URLBuilder.spec.js on lines 72..88

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

        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

          describe('#wikiwhoColorRevisionURL', () => {
            it('should create a wikiwhoColorRevisionURL when given a valid article', () => {
              const helper = new URLBuilder({ article: defaults.article });
              const expected = 'https://wikiwho-api.wmcloud.org/en/api/v1.0.0-beta/rev_content/Brown%20Bear%2C%20Brown%20Bear%2C%20What%20Do%20You%20See%3F/?o_rev_id=true&editor=true&token_id=true&out=true&in=true';
              expect(helper.wikiwhoColorRevisionURL()).toEqual(expected);
        app/assets/javascripts/components/common/ArticleViewer/utils/URLBuilder.spec.js on lines 54..70

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

        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

            case INCREASE_LIMIT_COURSE_SPECIFIC: {
              let revisionsDisplayedCourseSpecific = state.revisionsDisplayedCourseSpecific.concat(
                state.courseScopedRevisions.slice(
                    state.revisionsDisplayedCourseSpecific.length, state.revisionsDisplayedCourseSpecific.length + REVISIONS_INCREMENT
                  )
        Severity: Major
        Found in app/assets/javascripts/reducers/revisions.js and 1 other location - About 1 day to fix
        app/assets/javascripts/reducers/revisions.js on lines 50..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 219.

        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

            case RECEIVE_ASSESSMENTS: {
              const newState = { ...state, assessmentsLoaded: true };
              const revisionsArray = newState.revisions;
              const pageAssessments = action.data.assessments;
              newState.revisions = revisionsArray.map((revision) => {
        Severity: Major
        Found in app/assets/javascripts/reducers/revisions.js and 1 other location - About 1 day to fix
        app/assets/javascripts/reducers/revisions.js on lines 140..161

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

        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

            case INCREASE_LIMIT: {
              let revisionsDisplayed = state.revisionsDisplayed.concat(
                state.revisions.slice(
                    state.revisionsDisplayed.length, state.revisionsDisplayed.length + REVISIONS_INCREMENT
                  )
        Severity: Major
        Found in app/assets/javascripts/reducers/revisions.js and 1 other location - About 1 day to fix
        app/assets/javascripts/reducers/revisions.js on lines 72..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 219.

        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

            case 'RECEIVE_ASSESSMENTS_COURSE_SPECIFIC': {
              const newState = { ...state, courseSpecificAssessmentsLoaded: true };
              const revisionsArray = newState.courseScopedRevisions;
              const pageAssessments = action.data.assessments;
              newState.courseScopedRevisions = revisionsArray.map((revision) => {
        Severity: Major
        Found in app/assets/javascripts/reducers/revisions.js and 1 other location - About 1 day to fix
        app/assets/javascripts/reducers/revisions.js on lines 118..139

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

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

                <div className="stat-display__row">
                  <h5 className="stats-label">{I18n.t('metrics.claims')}</h5>
                  <div className="stat-display__value-group">
                    <OverviewStat
                      id="claims-created"
        app/assets/javascripts/components/common/wikidata_overview_stats.jsx on lines 16..41
        app/assets/javascripts/components/common/wikidata_overview_stats.jsx on lines 87..112

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

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

                <div className="stat-display__row">
                  <h5 className="stats-label">{I18n.t('metrics.labels')}</h5>
                  <div className="stat-display__value-group">
                    <OverviewStat
                      id="labels-added"
        app/assets/javascripts/components/common/wikidata_overview_stats.jsx on lines 16..41
        app/assets/javascripts/components/common/wikidata_overview_stats.jsx on lines 61..86

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

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

                <div className="stat-display__row">
                  <h5 className="stats-label">{I18n.t('metrics.general')}</h5>
                  <div className="stat-display__value-group">
                    <OverviewStat
                      id="total-revisions"
        app/assets/javascripts/components/common/wikidata_overview_stats.jsx on lines 61..86
        app/assets/javascripts/components/common/wikidata_overview_stats.jsx on lines 87..112

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

        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 statistic_update_info_utils.spec.js has 523 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import '../testHelper';
        import { getLastUpdateMessage, getFirstUpdateMessage, firstUpdateTime, lastSuccessfulUpdateMoment, nextUpdateExpected, getLastUpdateSummary, getTotaUpdatesMessage, getUpdateLogs } from '../../app/assets/javascripts/utils/statistic_update_info_utils';
        
        describe('firstUpdateTime', () => {
          test(
        Severity: Major
        Found in test/utils/statistic_update_info_utils.spec.js - About 1 day to fix

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

                  <div className="stat-display__row">
                    <h5 className="stats-label">Descriptions</h5>
                    <div className="stat-display__value-group">
                      <OverviewStat
                        id="descriptions-added"
          app/assets/javascripts/components/common/wikidata_overview_stats.jsx on lines 139..164

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

          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 className="stat-display__row">
                    <h5 className="stats-label">Aliases</h5>
                    <div className="stat-display__value-group">
                      <OverviewStat
                        id="aliases-added"
          app/assets/javascripts/components/common/wikidata_overview_stats.jsx on lines 113..138

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

          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 settings_actions.js has 512 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          
          import {
            SET_ADMIN_USERS, SET_SPECIAL_USERS,
            SUBMITTING_NEW_SPECIAL_USER, REVOKING_SPECIAL_USER,
            SUBMITTING_NEW_ADMIN, REVOKING_ADMIN, SET_COURSE_CREATION_SETTINGS,
          Severity: Major
          Found in app/assets/javascripts/actions/settings_actions.js - About 1 day to fix

            Function Block has 206 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            const Block = (props) => {
            const updateBlock = (valueKey, value) => {
                const toPass = { ...props.block };
                toPass[valueKey] = value;
                delete toPass.deleteBlock;
            Severity: Major
            Found in app/assets/javascripts/components/timeline/block.jsx - About 1 day to fix

              Function TrainingSlideHandler has 199 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              const TrainingSlideHandler = () => {
                const training = useSelector(state => state.training);
                const routeParams = useParams();
                const navigate = useNavigate();
                const dispatch = useDispatch();
              Severity: Major
              Found in app/assets/javascripts/training/components/training_slide_handler.jsx - About 7 hrs to fix

                Function List has a Cognitive Complexity of 50 (exceeds 5 allowed). Consider refactoring.
                Open

                const List = ({
                  keys,
                  sortable,
                  table_key,
                  className,
                Severity: Minor
                Found in app/assets/javascripts/components/common/list.jsx - About 7 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 48 (exceeds 5 allowed). Consider refactoring.
                Open

                  render() {
                    const canRename = this.canRename();
                    const isClassroomProgramType = this.props.course.type === 'ClassroomProgramCourse';
                    const timelineDatesDiffer = this.props.course.start !== this.props.course.timeline_start || this.props.course.end !== this.props.course.timeline_end;
                    const eventSync = this.props.course.flags.event_sync;
                Severity: Minor
                Found in app/assets/javascripts/components/overview/details.jsx - About 7 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

                Severity
                Category
                Status
                Source
                Language