core/templates/pages/contributor-dashboard-page/modal-templates/translation-suggestion-review-modal.component.ts

Summary

Maintainability
F
6 days
Test Coverage

File translation-suggestion-review-modal.component.ts has 667 lines of code (exceeds 250 allowed). Consider refactoring.
Open

// Copyright 2021 The Oppia Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at

    TranslationSuggestionReviewModalComponent has 34 functions (exceeds 20 allowed). Consider refactoring.
    Open

    @Component({
      selector: 'oppia-translation-suggestion-review-modal',
      templateUrl: './translation-suggestion-review-modal.component.html',
    })
    export class TranslationSuggestionReviewModalComponent implements OnInit {

      Function refreshActiveContributionState has 77 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        refreshActiveContributionState(): void {
          this.activeContribution = this.allContributions[this.activeSuggestionId];
      
          // Close modal instance if the suggestion's corresponding opportunity
          // is deleted. See issue #14234.

        Function acceptAndReviewNext has 52 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          acceptAndReviewNext(): void {
            if (this.isUndoFeatureEnabled) {
              this.finalCommitMessage = this.generateCommitMessage();
              const reviewMessageForSubmitter =
                this.reviewMessage +

          Function rejectAndReviewNext has 51 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            rejectAndReviewNext(reviewMessage: string): void {
              if (this.isUndoFeatureEnabled) {
                if (
                  this.validatorsService.isValidReviewMessage(
                    reviewMessage,

            Function ngOnInit has 39 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              ngOnInit(): void {
                this.isUndoFeatureEnabled =
                  this.platformFeatureService.status.CdAllowUndoingTranslationReview.isEnabled;
                this.activeSuggestionId = this.initialSuggestionId;
                this.activeContribution =

              Function acceptAndReviewNext has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
              Open

                acceptAndReviewNext(): void {
                  if (this.isUndoFeatureEnabled) {
                    this.finalCommitMessage = this.generateCommitMessage();
                    const reviewMessageForSubmitter =
                      this.reviewMessage +

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

                commitQueuedSuggestion(): void {
                  if (!this.queuedSuggestion) {
                    return;
                  }
                  this.contributionAndReviewService.reviewExplorationSuggestion(

                Function resolveSuggestionAndUpdateModal has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                Open

                  resolveSuggestionAndUpdateModal(): void {
                    if (this.isUndoFeatureEnabled) {
                      if (this.queuedSuggestion) {
                        this.resolvedSuggestionIds.push(this.queuedSuggestion.suggestion_id);
                
                

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

                  undoReviewAction(): void {
                    clearTimeout(this.commitTimeout); // Clear the commit timeout.
                    if (this.queuedSuggestion) {
                      const indexToRemove = this.resolvedSuggestionIds.indexOf(
                        this.queuedSuggestion.suggestion_id

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

                  rejectAndReviewNext(reviewMessage: string): void {
                    if (this.isUndoFeatureEnabled) {
                      if (
                        this.validatorsService.isValidReviewMessage(
                          reviewMessage,

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

                  constructor(
                    private readonly changeDetectorRef: ChangeDetectorRef,
                    public activeModal: NgbActiveModal,
                    private alertsService: AlertsService,
                    private contextService: ContextService,
                core/templates/components/question-directives/question-player/question-player.component.ts on lines 115..129
                core/templates/components/state-editor/state-editor.component.ts on lines 98..112
                core/templates/pages/blog-dashboard-page/blog-post-editor/blog-post-editor.component.ts on lines 96..110
                core/templates/pages/classroom-page/classroom-page.component.ts on lines 59..73
                core/templates/pages/exploration-editor-page/translation-tab/translation-tab.component.ts on lines 67..81
                core/templates/pages/exploration-player-page/learner-experience/ratings-and-recommendations.component.ts on lines 93..107
                core/templates/pages/feedback-updates-page/feedback-updates-page.component.ts on lines 167..181
                core/templates/pages/library-page/library-page.component.ts on lines 95..109

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

                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

                  goToNextItem(): void {
                    const lastContributionId = this.remainingContributionIds.pop();
                    // If the current item is the last item, do not navigate.
                    if (lastContributionId === undefined) {
                      return;
                core/templates/pages/contributor-dashboard-page/modal-templates/translation-suggestion-review-modal.component.ts on lines 435..450

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

                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

                  goToPreviousItem(): void {
                    const lastContributionId = this.skippedContributionIds.pop();
                    // If the current item is the first item, do not navigate.
                    if (lastContributionId === undefined) {
                      return;
                core/templates/pages/contributor-dashboard-page/modal-templates/translation-suggestion-review-modal.component.ts on lines 418..433

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

                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

                  toggleExpansionState(tab: ExpansionTabType): void {
                    if (tab === ExpansionTabType.CONTENT) {
                      this.isContentExpanded = !this.isContentExpanded;
                    } else if (tab === ExpansionTabType.TRANSLATION) {
                      this.isTranslationExpanded = !this.isTranslationExpanded;
                core/templates/pages/contributor-dashboard-page/modal-templates/translation-modal.component.ts on lines 320..326

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

                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

                interface ActiveSuggestionDict {
                  author_name: string;
                  change_cmd: SuggestionChangeDict;
                  exploration_content_html: string | string[] | null;
                  language_code: string;
                core/templates/pages/contributor-dashboard-page/modal-templates/question-suggestion-review-modal.component.ts on lines 83..94

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

                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

                  updateHtml(value: string): void {
                    if (value !== this.editedContent.html) {
                      this.editedContent.html = value;
                      this.changeDetectorRef.detectChanges();
                    }
                core/templates/pages/topics-and-skills-dashboard-page/modals/create-new-skill-modal.component.ts on lines 72..77

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

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

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

                      const reviewMessageForSubmitter =
                        this.reviewMessage +
                        (this.translationUpdated
                          ? (this.reviewMessage.length > 0 ? ': ' : '') +
                            '(Note: This suggestion was submitted with reviewer edits.)'
                core/templates/pages/contributor-dashboard-page/modal-templates/translation-suggestion-review-modal.component.ts on lines 511..516

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

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

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

                      const reviewMessageForSubmitter =
                        this.reviewMessage +
                        (this.translationUpdated
                          ? (this.reviewMessage.length > 0 ? ': ' : '') +
                            '(Note: This suggestion was submitted with reviewer edits.)'
                core/templates/pages/contributor-dashboard-page/modal-templates/translation-suggestion-review-modal.component.ts on lines 488..493

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

                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

                        errorMessage => {
                          this.alertsService.clearWarnings();
                          this.alertsService.addWarning(`Invalid Suggestion: ${errorMessage}`);
                        }
                core/templates/pages/contributor-dashboard-page/modal-templates/translation-suggestion-review-modal.component.ts on lines 589..594

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

                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

                          errorMessage => {
                            this.alertsService.clearWarnings();
                            this.alertsService.addWarning(
                              `Invalid Suggestion: ${errorMessage}`
                            );
                core/templates/pages/contributor-dashboard-page/modal-templates/translation-suggestion-review-modal.component.ts on lines 533..536

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

                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

                          () => {
                            this.alertsService.clearMessages();
                            this.alertsService.addSuccessMessage('Suggestion rejected.');
                            this.resolveSuggestionAndUpdateModal();
                          },
                core/templates/pages/contributor-dashboard-page/modal-templates/translation-suggestion-review-modal.component.ts on lines 528..532

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

                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

                        () => {
                          this.alertsService.clearMessages();
                          this.alertsService.addSuccessMessage('Suggestion accepted.');
                          this.resolveSuggestionAndUpdateModal();
                        },
                core/templates/pages/contributor-dashboard-page/modal-templates/translation-suggestion-review-modal.component.ts on lines 584..588

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

                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