WikiEducationFoundation/WikiEduDashboard

View on GitHub

Showing 1,672 of 1,672 total issues

File timeline.jsx has 424 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 { HTML5Backend } from 'react-dnd-html5-backend';
import { DndProvider } from 'react-dnd';
Severity: Minor
Found in app/assets/javascripts/components/timeline/timeline.jsx - About 6 hrs to fix

    Function Nav has 153 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    const Nav = () => {
      const {
        rooturl: rootUrl,
        logopath: logoPath,
        fluid: fluidStr,
    Severity: Major
    Found in app/assets/javascripts/components/nav/nav.jsx - About 6 hrs to fix

      Function AvailableActions has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
      Open

      const AvailableActions = ({ course, current_user, updateCourse, courseCreationNotice }) => {
        const dispatch = useDispatch();
      
        const join = (role = null) => {
          const enrollURL = course.enroll_url;
      Severity: Minor
      Found in app/assets/javascripts/components/overview/available_actions.jsx - About 6 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 151 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        render() {
          const keys = articleListKeys(this.props.course);
          const project = this.props.course.home_wiki.project;
          const trackedEditable = this.props.current_user && this.props.current_user.isAdvancedRole;
      
      
      Severity: Major
      Found in app/assets/javascripts/components/articles/article_list.jsx - About 6 hrs to fix

        Function TextResults has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
        Open

        const TextResults = ({ followUpOnly, answers_data, follow_up_answers: followUpAnswers, sentiment, question }) => {
          const [limit, setLimit] = useState();
          const [buttonText, setbuttonText] = useState('More');
        
          const followUpAnswerCount = Object.keys(followUpAnswers).length;
        Severity: Minor
        Found in app/assets/javascripts/surveys/components/TextResults.jsx - About 5 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 AssignButton has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
        Open

        const AssignButton = ({ course, role, course_id, wikidataLabels = {}, hideAssignedArticles,
          assignments, unassigned, student, allowMultipleArticles, current_user, isStudentsPage,
          permitted, tooltip_message }) => {
          const dispatch = useDispatch();
          const [language, setLanguage] = useState('');
        Severity: Minor
        Found in app/assets/javascripts/components/common/AssignCell/AssignButton.jsx - About 5 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 3 locations. Consider refactoring.
        Open

          describe('December to April', () => {
            test('December 2021 - should return Spring 2022', () => {
              start_date = new Date(2021, 11, 1);
              const result = inferDefaultCampaign(campaigns, start_date);
              expect(result).toStrictEqual({ id: 1, title: 'Spring 2022', slug: 'spring_2022' });
        Severity: Major
        Found in test/utils/infer_default_campaign.spec.js and 2 other locations - About 5 hrs to fix
        test/utils/infer_default_campaign.spec.js on lines 34..46
        test/utils/infer_default_campaign.spec.js on lines 48..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 151.

        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

          describe('August to November', () => {
            test('August 2022 - should return Fall 2022', () => {
              start_date = new Date(2022, 7, 1);
              const result = inferDefaultCampaign(campaigns, start_date);
              expect(result).toStrictEqual({ id: 3, title: 'Fall 2022', slug: 'fall_2022' });
        Severity: Major
        Found in test/utils/infer_default_campaign.spec.js and 2 other locations - About 5 hrs to fix
        test/utils/infer_default_campaign.spec.js on lines 20..32
        test/utils/infer_default_campaign.spec.js on lines 34..46

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

        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

          describe('May to July', () => {
            test('May 2022 - should return Summer 2022', () => {
              start_date = new Date(2022, 4, 1);
              const result = inferDefaultCampaign(campaigns, start_date);
              expect(result).toStrictEqual({ id: 2, title: 'Summer 2022', slug: 'summer_2022' });
        Severity: Major
        Found in test/utils/infer_default_campaign.spec.js and 2 other locations - About 5 hrs to fix
        test/utils/infer_default_campaign.spec.js on lines 20..32
        test/utils/infer_default_campaign.spec.js on lines 48..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 151.

        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

          test(
            'returns an article object with the language, project, title, and url, comparing it to the default wiki',
            () => {
              const assignment = {
                article_url: 'https://es.wikipedia.org/wiki/Silvia_Federici',
        Severity: Major
        Found in test/utils/course_utils.spec.js and 1 other location - About 5 hrs to fix
        test/utils/course_utils.spec.js on lines 228..247

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

        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

          test(
            'returns an article object with the language, project, title, and url',
            () => {
              const assignment = {
                article_url: 'https://es.wikipedia.org/wiki/Autofoto',
        Severity: Major
        Found in test/utils/course_utils.spec.js and 1 other location - About 5 hrs to fix
        test/utils/course_utils.spec.js on lines 249..268

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

        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 ArticleFinder has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
        Open

        const ArticleFinder = (props) => {
          const [isSubmitted, setIsSubmitted] = useState(false);
          const [showFilters, setShowFilters] = useState(false);
        
          useEffect(() => {
        Severity: Minor
        Found in app/assets/javascripts/components/article_finder/article_finder.jsx - About 5 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 WeekdayPicker has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
        Open

        const WeekdayPicker = ({
          className: componentClassName,
          style,
          tabIndex,
        
        
        Severity: Minor
        Found in app/assets/javascripts/components/common/weekday_picker.jsx - About 5 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 5 locations. Consider refactoring.
        Open

        const UpdateImpactStats = () => {
          const getKey = () => {
            return 'update_impact_stats';
          };
        
        
        app/assets/javascripts/components/settings/views/add_admin_button.jsx on lines 6..24
        app/assets/javascripts/components/settings/views/add_special_user_button.jsx on lines 6..24
        app/assets/javascripts/components/settings/views/update_default_campaign_setting.jsx on lines 6..24
        app/assets/javascripts/components/settings/views/update_salesforce_credentials.jsx on lines 6..24

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

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

        const AddAdminButton = () => {
          const getKey = () => {
            return 'add_admin_button';
          };
        
        
        app/assets/javascripts/components/settings/views/add_special_user_button.jsx on lines 6..24
        app/assets/javascripts/components/settings/views/update_default_campaign_setting.jsx on lines 6..24
        app/assets/javascripts/components/settings/views/update_impact_stats.jsx on lines 6..24
        app/assets/javascripts/components/settings/views/update_salesforce_credentials.jsx on lines 6..24

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

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

        const UpdateSalesforceCredentials = () => {
          const getKey = () => {
            return 'update_salesforce_credentials_button';
          };
        
        
        app/assets/javascripts/components/settings/views/add_admin_button.jsx on lines 6..24
        app/assets/javascripts/components/settings/views/add_special_user_button.jsx on lines 6..24
        app/assets/javascripts/components/settings/views/update_default_campaign_setting.jsx on lines 6..24
        app/assets/javascripts/components/settings/views/update_impact_stats.jsx on lines 6..24

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

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

        const AddSpecialUserButton = () => {
          const getKey = () => {
            return 'add_special_user_button';
          };
        
        
        app/assets/javascripts/components/settings/views/add_admin_button.jsx on lines 6..24
        app/assets/javascripts/components/settings/views/update_default_campaign_setting.jsx on lines 6..24
        app/assets/javascripts/components/settings/views/update_impact_stats.jsx on lines 6..24
        app/assets/javascripts/components/settings/views/update_salesforce_credentials.jsx on lines 6..24

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

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

        const UpdateDefaultCampaignSetting = () => {
          const getKey = () => {
            return 'update_default_campaign_button';
          };
        
        
        app/assets/javascripts/components/settings/views/add_admin_button.jsx on lines 6..24
        app/assets/javascripts/components/settings/views/add_special_user_button.jsx on lines 6..24
        app/assets/javascripts/components/settings/views/update_impact_stats.jsx on lines 6..24
        app/assets/javascripts/components/settings/views/update_salesforce_credentials.jsx on lines 6..24

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

        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('start', () => {
            describe('loop is zeroIndexed', () => {
              test(
                'returns the formatted start of the nth week (as provided to the constructor)',
                () => {
        Severity: Major
        Found in test/utils/date_calculator.spec.js and 1 other location - About 5 hrs to fix
        test/utils/date_calculator.spec.js on lines 25..41

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

        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('end', () => {
            describe('last day of the week we started on is before course end', () => {
              test(
                'returns the formatted start of the nth week (as provided to the constructor)',
                () => {
        Severity: Major
        Found in test/utils/date_calculator.spec.js and 1 other location - About 5 hrs to fix
        test/utils/date_calculator.spec.js on lines 5..24

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

        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