WikiEducationFoundation/WikiEduDashboard

View on GitHub

Showing 1,672 of 1,672 total issues

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

                <TextInput
                  id="course_title"
                  onChange={this.updateCourse}
                  value={this.state.course.title}
                  value_key="title"
app/assets/javascripts/components/overview/course_cloned_modal.jsx on lines 337..347
app/assets/javascripts/components/overview/course_cloned_modal.jsx on lines 382..392

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

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

        <TextInput
          id="course_term"
          onChange={this.updateCourse}
          value={this.state.course.term}
          value_key="term"
app/assets/javascripts/components/overview/course_cloned_modal.jsx on lines 371..381
app/assets/javascripts/components/overview/course_cloned_modal.jsx on lines 382..392

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

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

                <TextInput
                  id="course_school"
                  onChange={this.updateCourse}
                  value={this.state.course.school}
                  value_key="school"
app/assets/javascripts/components/overview/course_cloned_modal.jsx on lines 337..347
app/assets/javascripts/components/overview/course_cloned_modal.jsx on lines 371..381

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

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

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

      <td className="table-link-cell user-count">
        <a href={`/courses/${course.slug}/`}>
          <div>
            {course.user_count}
          </div>
Severity: Major
Found in app/assets/javascripts/components/course/course_row.jsx and 3 other locations - About 3 hrs to fix
app/assets/javascripts/components/course/active_course_row.jsx on lines 12..21
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

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

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

      <td className="table-link-cell user-count">
        <a href={`/courses/${course.slug}/`}>
          <div>
            {course.user_count}
          </div>
app/assets/javascripts/components/course/active_course_row.jsx on lines 12..21
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

Function TimelineHandler has 89 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const TimelineHandler = (props) => {
  const [reorderable, setReorderable] = useState(false);
  const [editableTitles, setEditableTitles] = useState(false);

// Replace componentDidMount with useEffect hook
Severity: Major
Found in app/assets/javascripts/components/timeline/timeline_handler.jsx - About 3 hrs to fix

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

    const updateCourseCreationSettingsPromise = async (settings) => {
      const response = await request('/settings/update_course_creation', {
        method: 'POST',
        body: JSON.stringify(settings)
      });
    Severity: Major
    Found in app/assets/javascripts/actions/settings_actions.js and 1 other location - About 3 hrs to fix
    app/assets/javascripts/actions/category_actions.js on lines 29..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 106.

    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 addCategoryPromise = async (payload) => {
      const response = await request('/categories.json', {
        method: 'POST',
        body: JSON.stringify(payload)
      });
    Severity: Major
    Found in app/assets/javascripts/actions/category_actions.js and 1 other location - About 3 hrs to fix
    app/assets/javascripts/actions/settings_actions.js on lines 360..373

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

    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 CoursesPresenter has 29 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class CoursesPresenter
      attr_reader :current_user, :campaign_param
    
      def initialize(current_user:, campaign_param: nil, courses_list: nil, page: nil, tag: nil)
        @current_user = current_user
    Severity: Minor
    Found in app/presenters/courses_presenter.rb - About 3 hrs to fix

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

        async fetchRecentUploads(opts = {}) {
          const response = await request(`/revision_analytics/recent_uploads.json?scoped=${opts.scoped || false}`);
      
          if (!response.ok) {
            logErrorMessage(response);
      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 121..131

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

      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

            <button onClick={onMoveUp} onMouseEnter={() => setIsHoverArrowUp(true)} onMouseLeave={() => setIsHoverArrowUp(false)} className="button border" aria-label={I18n.t('timeline.move_block_up')} disabled={disableUp}>
              <i className={`icon ${isHoverArrowUp ? 'icon-arrow-up_white' : 'icon-arrow-up'}`} />
            </button>
      app/assets/javascripts/components/timeline/orderable_block.jsx on lines 30..32

      Duplicated Code

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

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

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

      Tuning

      This issue has a mass of 104.

      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

            <button onClick={onMoveDown} onMouseEnter={() => setIsHoverArrowDown(true)} onMouseLeave={() => setIsHoverArrowDown(false)} className="button border" aria-label={I18n.t('timeline.move_block_down')} disabled={disableDown}>
              <i className={`icon ${isHoverArrowDown ? 'icon-arrow-down_white' : 'icon-arrow-down'}`} />
            </button>
      app/assets/javascripts/components/timeline/orderable_block.jsx on lines 33..35

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

      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 fetchDykArticles(opts = {}) {
          const response = await request(`/revision_analytics/dyk_eligible.json?scoped=${opts.scoped || false}`);
      
          if (!response.ok) {
            logErrorMessage(response);
      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 133..143

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

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

      export default function articles(state = initialState, action) {
        switch (action.type) {
          case RECEIVE_ARTICLES: {
            const wikis = uniqWith(
              map(action.data.course.articles, mapWikis),
      Severity: Major
      Found in app/assets/javascripts/reducers/articles.js - About 3 hrs to fix

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

          render() {
            const {
              assignments, course, current_user, editable,
              showRecent, student
            } = this.props;

          Function renderGraph has 86 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          const renderGraph = (statsData, graphWidth, graphHeight, courseStringPrefix) => {
            const vegaSpec = {
              width: graphWidth,
              height: graphHeight,
              padding: { top: 40, left: 70, right: 20, bottom: 35 },

            Function CourseApproval has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
            Open

            const CourseApproval = (props) => {
              const [selectedWikiExpert, setSelectedWikiExpert] = useState({});
              const [selectedCampaigns, setSelectedCampaigns] = useState([]);
              const [selectedTags, setSelectedTags] = useState([]);
              const [createdTagOption, setCreatedTagOption] = useState([]);
            Severity: Minor
            Found in app/assets/javascripts/components/course/course_approval.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 Block has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
            Open

            const Block = (props) => {
            const updateBlock = (valueKey, value) => {
                const toPass = { ...props.block };
                toPass[valueKey] = value;
                delete toPass.deleteBlock;
            Severity: Minor
            Found in app/assets/javascripts/components/timeline/block.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 timeline has 85 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export default function timeline(state = initialState, action) {
              switch (action.type) {
                case SAVED_TIMELINE:
                case RECEIVE_TIMELINE: {
                  return {
            Severity: Major
            Found in app/assets/javascripts/reducers/timeline.js - About 3 hrs to fix
              Severity
              Category
              Status
              Source
              Language