WikiEducationFoundation/WikiEduDashboard

View on GitHub

Showing 1,672 of 1,672 total issues

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

  const renderGraph = () => {
    const vegaSpec = {
      width: props.graphWidth,
      height: props.graphHeight,
      padding: 5,
Severity: Major
Found in app/assets/javascripts/components/articles/edit_size_graph.jsx - About 5 hrs to fix

    Function CourseDates has 126 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    const CourseDates = (props) => {
      const updateCourseDates = (key, value) => {
        const updatedCourse = CourseDateUtils.updateCourseDates(props.course, key, value);
        props.updateCourseProps(updatedCourse);
      };
    Severity: Major
    Found in app/assets/javascripts/components/course_creator/course_dates.jsx - About 5 hrs to fix

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

      export default function didYouKnow(state = initialState, action) {
        switch (action.type) {
          case RECEIVE_DYK: {
            return {
              articles: action.payload.data.articles,
      Severity: Major
      Found in app/assets/javascripts/reducers/did_you_know.js and 1 other location - About 4 hrs to fix
      app/assets/javascripts/reducers/recent_edits.js on lines 11..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 134.

      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 default function recentEdits(state = initialState, action) {
        switch (action.type) {
          case RECEIVE_RECENT_EDITS: {
            return {
              revisions: action.payload.data.revisions,
      Severity: Major
      Found in app/assets/javascripts/reducers/recent_edits.js and 1 other location - About 4 hrs to fix
      app/assets/javascripts/reducers/did_you_know.js on lines 10..30

      Duplicated Code

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

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

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

      Tuning

      This issue has a mass of 134.

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

      const RevisionHandler = ({ course, courseScopedLimit }) => {
        const [isCourseScoped, setIsCourseScoped] = useState(false);
      
        const dispatch = useDispatch();
      
      
      Severity: Minor
      Found in app/assets/javascripts/components/revisions/revisions_handler.jsx - About 4 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 33 (exceeds 5 allowed). Consider refactoring.
      Open

        render() {
          if (this.props.loading) {
            return <Loading />;
          }
      
      
      Severity: Minor
      Found in app/assets/javascripts/components/timeline/timeline.jsx - About 4 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

      File routes.rb has 371 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      Rails.application.routes.draw do
        get 'errors/file_not_found'
        get 'errors/unprocessable'
        get 'errors/login_error'
        get 'errors/internal_server_error'
      Severity: Minor
      Found in config/routes.rb - About 4 hrs to fix

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

          beforeEach(() => {
            cannedResponse = { spam: 'eggs' };
            sinon.stub(requestModule, 'default')
              .onCall(0).resolves(
                { status: 200, ok: true, json: sinon.fake.returns({}) }
        Severity: Major
        Found in test/actions/settings_actions.spec.js and 1 other location - About 4 hrs to fix
        test/actions/settings_actions.spec.js on lines 94..103

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

        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

              if ((state.sort.key !== 'date' && state.sort.key !== null) || (state.sort.key === 'date' && state.sort.sortKey !== null)) {
                const desc = state.sort.sortKey === null;
                const absolute = state.sort.key === 'characters';
                revisionsDisplayed = sortByKey(revisionsDisplayed, state.sort.key, null, desc, absolute).newModels;
              }
        Severity: Major
        Found in app/assets/javascripts/reducers/revisions.js and 1 other location - About 4 hrs to fix
        app/assets/javascripts/reducers/revisions.js on lines 187..191

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

        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

              if ((state.sort.key !== 'date' && state.sort.key !== null) || (state.sort.key === 'date' && state.sort.sortKey !== null)) {
                const desc = state.sort.sortKey === null;
                const absolute = state.sort.key === 'characters';
                revisionsDisplayedCourseSpecific = sortByKey(revisionsDisplayedCourseSpecific, state.sort.key, null, desc, absolute).newModels;
              }
        Severity: Major
        Found in app/assets/javascripts/reducers/revisions.js and 1 other location - About 4 hrs to fix
        app/assets/javascripts/reducers/revisions.js on lines 166..170

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

        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

            tr: {
              SM: {
                class: 'fa',
                pretty: 'SM',
                score: 100
        app/assets/javascripts/utils/article_finder_language_mappings.js on lines 82..113

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

        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

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

          beforeEach(() => {
            cannedResponse = { spam: 'eggs' };
            sinon.stub(requestModule, 'default')
            .onCall(0).resolves(
              { status: 200, ok: true, json: sinon.fake.returns({}) }
        Severity: Major
        Found in test/actions/settings_actions.spec.js and 1 other location - About 4 hrs to fix
        test/actions/settings_actions.spec.js on lines 42..51

        Duplicated Code

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

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

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

        Tuning

        This issue has a mass of 132.

        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

            fr: {
              AdQ: {
                class: 'fa',
                pretty: 'AdQ',
                score: 100,
        app/assets/javascripts/utils/article_finder_language_mappings.js on lines 114..145

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

        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

          return (
            <tr>
              <td>
                <form onSubmit={handleSubmit}>
                  <TextInput
        app/assets/javascripts/components/settings/views/update_featured_campaign_form.jsx on lines 16..33

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

        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

            return (
              <tr>
                <td>
                  <form onSubmit={handleSubmit}>
                    <TextInput
        app/assets/javascripts/components/settings/views/default_campaign_form.jsx on lines 17..34

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

        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

        HamburgerMenu.propTypes = {
          rootUrl: PropTypes.string,
          logoPath: PropTypes.string,
          exploreUrl: PropTypes.string,
          exploreName: PropTypes.string,
        Severity: Major
        Found in app/assets/javascripts/components/nav/hamburger_menu.jsx and 1 other location - About 4 hrs to fix
        app/assets/javascripts/components/course/course_approval.jsx on lines 362..376

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

        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

        CourseApproval.propTypes = {
          course: PropTypes.object,
          fetchSpecialUsers: PropTypes.func,
          fetchAllCampaigns: PropTypes.func,
          addUser: PropTypes.func,
        Severity: Major
        Found in app/assets/javascripts/components/course/course_approval.jsx and 1 other location - About 4 hrs to fix
        app/assets/javascripts/components/nav/hamburger_menu.jsx on lines 109..123

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

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

        const NotesPanel = () => {
          // State variables for managing the modal and note creation
          const [isModalOpen, setIsModalOpen] = useState(null);
          const [isNoteCreationActive, setIsNoteCreationActive] = useState(false);
        
        
        Severity: Major
        Found in app/assets/javascripts/components/admin_notes/notes_panel.jsx - About 4 hrs to fix

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

          const addCampaignsPromise = async (courseId, campaignId) => {
            const response = await request(`/courses/${courseId}/campaign.json`, {
              method: 'POST',
              body: JSON.stringify({ campaign: { title: campaignId } })
            });
          Severity: Major
          Found in app/assets/javascripts/actions/campaign_actions.js and 3 other locations - About 4 hrs to fix
          app/assets/javascripts/actions/campaign_actions.js on lines 32..44
          app/assets/javascripts/actions/tag_actions.js on lines 46..58
          app/assets/javascripts/actions/tag_actions.js on lines 73..85

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

          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

          const removeTagPromise = async (courseId, tag) => {
            const response = await request(`/courses/${courseId}/tag.json`, {
              method: 'DELETE',
              body: JSON.stringify({ tag: { tag } })
            });
          Severity: Major
          Found in app/assets/javascripts/actions/tag_actions.js and 3 other locations - About 4 hrs to fix
          app/assets/javascripts/actions/campaign_actions.js on lines 32..44
          app/assets/javascripts/actions/campaign_actions.js on lines 59..71
          app/assets/javascripts/actions/tag_actions.js on lines 46..58

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

          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