Coursemology/coursemology2

View on GitHub
client/app/bundles/course/assessment/submission/components/FileInput.jsx

Summary

Maintainability
B
6 hrs
Test Coverage

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

  render() {
    const {
      disabled,
      fieldState: { error },
      field: { value },

Function FileInputField has 37 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const FileInputField = (props) => {
  const {
    disabled,
    isMultipleAttachmentsAllowed,
    maxAttachmentsAllowed,

Function displayFileNames has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  displayFileNames(files) {
    const { disabled } = this.props;
    const { dropzoneActive } = this.state;
    if (dropzoneActive) {
      return <FileUpload style={{ width: 60, height: 60 }} />;

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

const translations = defineMessages({
  uploadDisabled: {
    id: 'course.assessment.submission.FileInput.uploadDisabled',
    defaultMessage: 'File upload disabled',
  },
client/app/bundles/course/assessment/submission/components/answers/ForumPostResponse/ForumCard.jsx on lines 24..37
client/app/bundles/course/assessment/submission/components/answers/ForumPostResponse/TopicCard.jsx on lines 24..37
client/app/bundles/course/assessment/submission/components/comment/CommentCard.jsx on lines 15..28
client/app/bundles/course/duplication/pages/Duplication/DuplicateAllButton.jsx on lines 10..26
client/app/bundles/course/duplication/pages/Duplication/DuplicateButton.jsx on lines 10..23
client/app/bundles/course/group/forms/NameDescriptionForm.jsx on lines 14..27
client/app/bundles/course/group/pages/GroupIndex/index.jsx on lines 16..29
client/app/bundles/course/group/pages/GroupShow/index.jsx on lines 19..33
client/app/bundles/course/lesson-plan/containers/LessonPlanLayout/NewEventButton.jsx on lines 11..24
client/app/bundles/course/lesson-plan/containers/LessonPlanLayout/NewMilestoneButton.jsx on lines 11..24
client/app/bundles/course/statistics/pages/StatisticsIndex/course/utils.js on lines 3..16
client/app/bundles/course/survey/pages/SurveyIndex/NewSurveyButton.jsx on lines 12..25
client/app/bundles/course/survey/pages/SurveyShow/NewSectionButton.jsx on lines 12..25
client/app/bundles/course/survey/pages/SurveyShow/Section/DeleteSectionButton.jsx on lines 10..23
client/app/bundles/course/survey/pages/SurveyShow/Section/EditSectionButton.jsx on lines 13..26
client/app/bundles/course/survey/pages/SurveyShow/Section/MoveDownButton.jsx on lines 9..22
client/app/bundles/course/survey/pages/SurveyShow/Section/MoveUpButton.jsx on lines 9..22
client/app/bundles/course/survey/pages/SurveyShow/index.jsx on lines 20..33
client/app/bundles/course/video/submission/containers/DiscussionElements/Editor.jsx on lines 9..22
client/app/bundles/course/video/submission/containers/Statistics.jsx on lines 11..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 60.

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 {
    disabled,
    isMultipleAttachmentsAllowed,
    maxAttachmentsAllowed,
    maxAttachmentSize,
client/app/bundles/course/assessment/submission/components/ReadOnlyEditor/NarrowEditor.jsx on lines 68..77
client/app/bundles/course/assessment/submission/containers/ProgrammingImport/ProgrammingImportEditor.jsx on lines 120..129
client/app/bundles/course/learning-map/components/Gate/index.jsx on lines 55..64
client/app/bundles/course/survey/containers/QuestionFormDialogue/QuestionFormOption.jsx on lines 76..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 48.

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

There are no issues that match your filters.

Category
Status