WikiEducationFoundation/WikiEduDashboard

View on GitHub
app/assets/javascripts/utils/api.js

Summary

Maintainability
F
1 wk
Test Coverage
F
44%

File api.js has 529 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { capitalize } from './strings';
import logErrorMessage from './log_error_message';
import request from './request';
import { stringify } from 'query-string';
import Rails from '@rails/ujs';
Severity: Major
Found in app/assets/javascripts/utils/api.js - About 1 day to fix

    API has 36 functions (exceeds 20 allowed). Consider refactoring.
    Open

    const API = {
      // /////////
      // Getters /
      // /////////
      fetchFeedback(articleTitle, assignmentId) {
    Severity: Minor
    Found in app/assets/javascripts/utils/api.js - About 4 hrs to fix

      Function saveTimeline has 40 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        async saveTimeline(courseId, data) {
          const cleanObject = object => {
            if (object.is_new) {
              delete object.id;
              delete object.is_new;
      Severity: Minor
      Found in app/assets/javascripts/utils/api.js - About 1 hr to fix

        Function searchForPages has 34 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          async searchForPages(wiki, search_term, namespace, map=(el)=>el, depth, limit=10){
            let search_query;
            if(search_term.split(' ').length > 1){
              // if we have multiple words, search for the exact words
              search_query = `intitle:${search_term}`;
        Severity: Minor
        Found in app/assets/javascripts/utils/api.js - About 1 hr to fix

          Function searchForPages has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

            async searchForPages(wiki, search_term, namespace, map=(el)=>el, depth, limit=10){
          Severity: Minor
          Found in app/assets/javascripts/utils/api.js - About 45 mins to fix

            Function requestNewAccount has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

              async requestNewAccount(passcode, courseSlug, username, email, createAccountNow) {
            Severity: Minor
            Found in app/assets/javascripts/utils/api.js - About 35 mins to fix

              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 227..240

              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 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 212..225

              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 3 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 2 other locations - About 3 hrs to fix
              app/assets/javascripts/utils/api.js on lines 133..143
              app/assets/javascripts/utils/api.js on lines 157..167

              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 3 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 2 other locations - About 3 hrs to fix
              app/assets/javascripts/utils/api.js on lines 121..131
              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

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

                async fetchSuspectedPlagiarism(opts = {}) {
                  const response = await request(`/revision_analytics/suspected_plagiarism.json?scoped=${opts.scoped || false}`);
              
                  if (!response.ok) {
                    logErrorMessage(response);
              Severity: Major
              Found in app/assets/javascripts/utils/api.js and 2 other locations - About 3 hrs to fix
              app/assets/javascripts/utils/api.js on lines 121..131
              app/assets/javascripts/utils/api.js on lines 157..167

              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 linkToSalesforce(courseId, salesforceId) {
                  const response = await request(`/salesforce/link/${courseId}.json?salesforce_id=${salesforceId}`, {
                    method: 'PUT'
                  });
                  if (!response.ok) {
              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 66..78

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

              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 destroyCustomFeedback(assignmentId, id) {
                  const response = await request(`/assignments/${assignmentId}/assignment_suggestions/${id}`, {
                    method: 'DELETE',
                  });
              
              
              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 516..527

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

              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 updateSalesforceRecord(courseId) {
                  const response = await request(`/salesforce/update/${courseId}.json`, {
                    method: 'PUT'
                  });
                  if (!response.ok) {
              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 384..395

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

              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 deleteAllWeeks(course_id) {
                  const response = await request(`/courses/${course_id}/delete_all_weeks.json`, {
                    method: 'DELETE'
                  });
                  if (!response.ok) {
              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 529..540

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

              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 deleteWeek(week_id) {
                  const response = await request(`/weeks/${week_id}.json`, {
                    method: 'DELETE'
                  });
                  if (!response.ok) {
              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 358..369

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

              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 deleteBlock(block_id) {
                  const response = await request(`/blocks/${block_id}.json`, {
                    method: 'DELETE'
                  });
                  if (!response.ok) {
              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 371..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 97.

              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

                async enableAccountRequests(courseSlug) {
                  const response = await request(`/requested_accounts/${courseSlug}/enable_account_requests`);
                  if (!response.ok) {
                    logErrorMessage(response);
                    const data = await response.text();
              Severity: Major
              Found in app/assets/javascripts/utils/api.js and 3 other locations - About 2 hrs to fix
              app/assets/javascripts/utils/api.js on lines 80..90
              app/assets/javascripts/utils/api.js on lines 145..155
              app/assets/javascripts/utils/api.js on lines 185..195

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

              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

                async fetchUserCourses(userId) {
                  const response = await request(`/courses_users.json?user_id=${userId}`);
              
                  if (!response.ok) {
                    logErrorMessage(response);
              Severity: Major
              Found in app/assets/javascripts/utils/api.js and 3 other locations - About 2 hrs to fix
              app/assets/javascripts/utils/api.js on lines 80..90
              app/assets/javascripts/utils/api.js on lines 145..155
              app/assets/javascripts/utils/api.js on lines 505..514

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

              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

                async fetchSuspectedCoursePlagiarism(course_id) {
                  const response = await request(`/courses/${course_id}/suspected_plagiarism.json`);
              
                  if (!response.ok) {
                    logErrorMessage(response);
              Severity: Major
              Found in app/assets/javascripts/utils/api.js and 3 other locations - About 2 hrs to fix
              app/assets/javascripts/utils/api.js on lines 80..90
              app/assets/javascripts/utils/api.js on lines 185..195
              app/assets/javascripts/utils/api.js on lines 505..514

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

              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

                async fetchUserProfileStats(username) {
                  const response = await request(`/user_stats.json?username=${username}`);
              
                  if (!response.ok) {
                    logErrorMessage(response);
              Severity: Major
              Found in app/assets/javascripts/utils/api.js and 3 other locations - About 2 hrs to fix
              app/assets/javascripts/utils/api.js on lines 145..155
              app/assets/javascripts/utils/api.js on lines 185..195
              app/assets/javascripts/utils/api.js on lines 505..514

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

              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

                  return request(`/courses/${courseId}/${endpoint}.json`, {
                    credentials: "include"
                  })
                    .then(res => {
                      if (res.ok) {
              Severity: Minor
              Found in app/assets/javascripts/utils/api.js and 1 other location - About 55 mins to fix
              app/assets/javascripts/utils/api.js on lines 17..25

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

              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

                  return request(`/revision_feedback.json?title=${articleTitle}&assignment_id=${assignmentId}`)
                    .then(res => {
                      if (res.ok) {
                        return res.json();
                      }
              Severity: Minor
              Found in app/assets/javascripts/utils/api.js and 1 other location - About 55 mins to fix
              app/assets/javascripts/utils/api.js on lines 243..253

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

              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 (!response.ok) {
                    logErrorMessage(response, 'There was an error with the greetings! ');
                    const data = await response.text();
                    response.responseText = data;
                    throw response;
              Severity: Minor
              Found in app/assets/javascripts/utils/api.js and 1 other location - About 50 mins to fix
              app/assets/javascripts/utils/api.js on lines 399..404

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

              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 (!response.ok) {
                    logErrorMessage(response, 'Couldn\'t notify students! ');
                    const data = await response.text();
                    response.responseText = data;
                    throw response;
              Severity: Minor
              Found in app/assets/javascripts/utils/api.js and 1 other location - About 50 mins to fix
              app/assets/javascripts/utils/api.js on lines 413..418

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

              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

              Parsing error: Cannot find module 'babel-plugin-root-import' Require stack: - /usr/local/node_modules/@babel/core/lib/config/files/plugins.js - /usr/local/node_modules/@babel/core/lib/config/files/index.js - /usr/local/node_modules/@babel/core/lib/index.js - /usr/local/node_modules/@babel/eslint-parser/lib/worker/babel-core.cjs - /usr/local/node_modules/@babel/eslint-parser/lib/worker/handle-message.cjs - /usr/local/node_modules/@babel/eslint-parser/lib/client.cjs - /usr/local/node_modules/@babel/eslint-parser/lib/index.cjs - /usr/local/node_modules/eslint/lib/cli-engine/config-array-factory.js - /usr/src/app/lib/eslint6-patch.js - /usr/src/app/lib/eslint.js - /usr/src/app/bin/eslint.js
              Open

              import { capitalize } from './strings';
              Severity: Minor
              Found in app/assets/javascripts/utils/api.js by eslint

              For more information visit Source: http://eslint.org/docs/rules/

              There are no issues that match your filters.

              Category
              Status