WikiEducationFoundation/WikiEduDashboard

View on GitHub

Showing 1,672 of 1,672 total issues

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

  test('handles url-encoded characters in Wikipedia redlinks -- #2', () => {
    const input = 'https://en.wikipedia.org/w/index.php?title=Mesut%20%C3%96zil:REDLINK&redirect=no';
    const output = courseUtils.articleFromTitleInput(input);
    expect(output.title).toBe('Mesut Özil');
    expect(output.project).toBe('wikipedia');
Severity: Major
Found in test/utils/course_utils.spec.js and 13 other locations - About 3 hrs to fix
test/utils/course_utils.spec.js on lines 100..107
test/utils/course_utils.spec.js on lines 109..116
test/utils/course_utils.spec.js on lines 118..125
test/utils/course_utils.spec.js on lines 127..134
test/utils/course_utils.spec.js on lines 136..143
test/utils/course_utils.spec.js on lines 145..152
test/utils/course_utils.spec.js on lines 154..161
test/utils/course_utils.spec.js on lines 163..170
test/utils/course_utils.spec.js on lines 172..179
test/utils/course_utils.spec.js on lines 181..188
test/utils/course_utils.spec.js on lines 190..197
test/utils/course_utils.spec.js on lines 199..206
test/utils/course_utils.spec.js on lines 208..215

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

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

  test('converts Wikipedia urls into titles', () => {
    const input = 'https://en.wikipedia.org/wiki/Robot_selfie';
    const output = courseUtils.articleFromTitleInput(input);
    expect(output.title).toBe('Robot selfie');
    expect(output.project).toBe('wikipedia');
Severity: Major
Found in test/utils/course_utils.spec.js and 13 other locations - About 3 hrs to fix
test/utils/course_utils.spec.js on lines 109..116
test/utils/course_utils.spec.js on lines 118..125
test/utils/course_utils.spec.js on lines 127..134
test/utils/course_utils.spec.js on lines 136..143
test/utils/course_utils.spec.js on lines 145..152
test/utils/course_utils.spec.js on lines 154..161
test/utils/course_utils.spec.js on lines 163..170
test/utils/course_utils.spec.js on lines 172..179
test/utils/course_utils.spec.js on lines 181..188
test/utils/course_utils.spec.js on lines 190..197
test/utils/course_utils.spec.js on lines 199..206
test/utils/course_utils.spec.js on lines 208..215
test/utils/course_utils.spec.js on lines 217..224

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

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

  test('handles mobile urls correctly', () => {
    const input = 'https://en.m.wikipedia.org/wiki/Robot_selfie';
    const output = courseUtils.articleFromTitleInput(input);
    expect(output.title).toBe('Robot selfie');
    expect(output.project).toBe('wikipedia');
Severity: Major
Found in test/utils/course_utils.spec.js and 13 other locations - About 3 hrs to fix
test/utils/course_utils.spec.js on lines 100..107
test/utils/course_utils.spec.js on lines 118..125
test/utils/course_utils.spec.js on lines 127..134
test/utils/course_utils.spec.js on lines 136..143
test/utils/course_utils.spec.js on lines 145..152
test/utils/course_utils.spec.js on lines 154..161
test/utils/course_utils.spec.js on lines 163..170
test/utils/course_utils.spec.js on lines 172..179
test/utils/course_utils.spec.js on lines 181..188
test/utils/course_utils.spec.js on lines 190..197
test/utils/course_utils.spec.js on lines 199..206
test/utils/course_utils.spec.js on lines 208..215
test/utils/course_utils.spec.js on lines 217..224

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

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 getCampaignPromise = (slug) => {
  return request(`/campaigns/${slug}.json`)
    .then((res) => {
      if (res.ok && res.status === 200) {
        return res.json();
Severity: Major
Found in app/assets/javascripts/actions/campaign_view_actions.js and 1 other location - About 3 hrs to fix
app/assets/javascripts/actions/assignment_actions.js on lines 11..23

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

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 fetchAssignmentsPromise = (courseSlug) => {
  return request(`/courses/${courseSlug}/assignments.json`)
    .then((res) => {
      if (res.ok && res.status === 200) {
        return res.json();
Severity: Major
Found in app/assets/javascripts/actions/assignment_actions.js and 1 other location - About 3 hrs to fix
app/assets/javascripts/actions/campaign_view_actions.js on lines 8..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 111.

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

  render() {
    if (!this.shouldShowDiff(this.props) || !this.props.revision) {
      return (
        <div className={`tooltip-trigger ${this.props.showButtonClass}`}>
          <button onClick={this.showDiff} aria-label="Open Diff Viewer" className="icon icon-diff-viewer"/>
Severity: Major
Found in app/assets/javascripts/components/revisions/diff_viewer.jsx - About 3 hrs to fix

    Function render has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
    Open

      render() {
        if (this.props.loadingUserCourses) {
          return <div />;
        }
        // There are four fundamental states: NewOrClone, CourseForm, wizardForm and CloneChooser
    Severity: Minor
    Found in app/assets/javascripts/components/course_creator/course_creator.jsx - About 3 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 TrainingSlideHandler has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
    Open

    const TrainingSlideHandler = () => {
      const training = useSelector(state => state.training);
      const routeParams = useParams();
      const navigate = useNavigate();
      const dispatch = useDispatch();
    Severity: Minor
    Found in app/assets/javascripts/training/components/training_slide_handler.jsx - About 3 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

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

    export const updateDefaultCampaign = campaignSlug => (dispatch) => {
      return updateDefaultCampaignPromise(campaignSlug)
        .then((data) => {
          dispatch({ type: ADD_NOTIFICATION, notification: { ...data, type: 'success', closable: true } });
          fetchDefaultCampaign()(dispatch);
    Severity: Major
    Found in app/assets/javascripts/actions/settings_actions.js and 1 other location - About 3 hrs to fix
    app/assets/javascripts/actions/settings_actions.js on lines 375..382

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

    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 updateCourseCreationSettings = settings => (dispatch) => {
      return updateCourseCreationSettingsPromise(settings)
        .then((data) => {
          dispatch({ type: ADD_NOTIFICATION, notification: { ...data, type: 'success', closable: true } });
          fetchCourseCreationSettings()(dispatch);
    Severity: Major
    Found in app/assets/javascripts/actions/settings_actions.js and 1 other location - About 3 hrs to fix
    app/assets/javascripts/actions/settings_actions.js on lines 427..434

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

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

      render() {
        const course = this.props.course;
        if (!course) { return <div />; }
        const dateProps = CourseDateUtils.dateProps(course);
        let courseLinkClass = 'dark button ';
    Severity: Major
    Found in app/assets/javascripts/components/timeline/meetings.jsx - About 3 hrs to fix

      Function NamespaceSelect has 93 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      const NamespaceSelect = (props) => {
        const [selectedNamespaces, setSelectedNamespaces] = useState([]);
        const [options, setOptions] = useState([]);
      
        useEffect(() => {
      Severity: Major
      Found in app/assets/javascripts/components/common/namespace_select.jsx - About 3 hrs to fix

        Function render has 93 lines of code (exceeds 25 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: Major
        Found in app/assets/javascripts/components/timeline/week.jsx - About 3 hrs to fix

          File course_quality_progress_graph.jsx has 321 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          /* global vegaEmbed */
          import React, { useEffect } from 'react';
          import PropTypes from 'prop-types';
          
          
          

            File ArticleViewer.jsx has 321 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            import React, { useEffect, useRef, useState } from 'react';
            import PropTypes from 'prop-types';
            import { useSelector, useDispatch } from 'react-redux';
            
            // Utilities

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

                async createRandomPeerAssignments(opts) {
                  const queryString = stringify(opts);
                  const response = await request(`/assignments/assign_reviewers_randomly?${queryString}`, {
                    method: 'POST'
                  });
              Severity: Major
              Found in app/assets/javascripts/utils/api.js and 1 other location - About 3 hrs to fix
              app/assets/javascripts/utils/api.js on lines 188..201

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

              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

                async createAssignment(opts) {
                  const queryString = stringify(opts);
                  const response = await request(`/assignments.json?${queryString}`, {
                    method: 'POST'
                  });
              Severity: Major
              Found in app/assets/javascripts/utils/api.js and 1 other location - About 3 hrs to fix
              app/assets/javascripts/utils/api.js on lines 203..216

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

              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

              Class WikidataSummaryParser has 30 methods (exceeds 20 allowed). Consider refactoring.
              Open

              class WikidataSummaryParser
                REVISION_CLASSIFICATIONS = {
                  'claims created' => :created_claim?,
                  'claims changed' => :changed_claim?,
                  'claims removed' => :removed_claim?,
              Severity: Minor
              Found in lib/wikidata_summary_parser.rb - About 3 hrs to fix

                Function ImpactStatsForm has 90 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                const ImpactStatsForm = (props) => {
                    const [stats, setStats] = useState({});
                
                    const handleChange = (key, value) => {
                        setStats({ ...stats, [key]: value });

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

                        <td className="table-link-cell word-count">
                          <a href={`/courses/${course.slug}/`}>
                            <div>
                              {course.human_word_count}
                            </div>
                  app/assets/javascripts/components/course/active_course_row.jsx on lines 28..37
                  app/assets/javascripts/components/course/course_row.jsx on lines 22..31
                  app/assets/javascripts/components/course/course_row.jsx on lines 38..47

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

                  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