core/templates/pages/exploration-player-page/learner-experience/conversation-skin.component.ts

Summary

Maintainability
F
1 wk
Test Coverage

File conversation-skin.component.ts has 1477 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

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

      ngOnInit(): void {
        this._editorPreviewMode = this.contextService.isInExplorationEditorPage();
    
        this.collectionId = this.urlService.getCollectionIdFromExplorationUrl();
        this.pidInUrl = this.urlService.getPidFromUrl();

      ConversationSkinComponent has 53 functions (exceeds 20 allowed). Consider refactoring.
      Open

      @Component({
        selector: 'oppia-conversation-skin',
        templateUrl: './conversation-skin.component.html',
        styleUrls: ['./conversation-skin.component.css'],
      })

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

          submitAnswer(
            answer: string,
            interactionRulesService: InteractionRulesService
          ): void {
            this.displayedCard.updateCurrentAnswer(null);

          Function _addNewCard has 150 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            private _addNewCard(newCard): void {
              this.conversationFlowService.addNewCard(newCard);
          
              let totalNumCards = this.playerTranscriptService.getNumCards();
          
          

            Function submitAnswer has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
            Open

              submitAnswer(
                answer: string,
                interactionRulesService: InteractionRulesService
              ): void {
                this.displayedCard.updateCurrentAnswer(null);

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

                  (
                    nextCard,
                    refreshInteraction,
                    feedbackHtml,
                    feedbackAudioTranslations,

              Function getExplorationLink has 78 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                getExplorationLink(): string {
                  if (
                    this.recommendedExplorationSummaries &&
                    this.recommendedExplorationSummaries[0]
                  ) {

                Function getExplorationLink has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
                Open

                  getExplorationLink(): string {
                    if (
                      this.recommendedExplorationSummaries &&
                      this.recommendedExplorationSummaries[0]
                    ) {

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

                  showUpcomingCard(): void {
                    let currentIndex = this.playerPositionService.getDisplayedCardIndex();
                    let conceptCardIsBeingShown =
                      this.displayedCard.getStateName() === null &&
                      !this.explorationPlayerStateService.isInQuestionMode();

                  Function moveToNewCard has 55 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    private moveToNewCard(
                      feedbackHtml: string | null,
                      isFinalQuestion: boolean,
                      nextCard: StateCard
                    ) {

                    Function giveFeedbackAndStayOnCurrentCard has 53 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      private giveFeedbackAndStayOnCurrentCard(
                        feedbackHtml: string | null,
                        missingPrerequisiteSkillId: string | null,
                        refreshInteraction: boolean,
                        refresherExplorationId: string | null

                      Function _addNewCard has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                      Open

                        private _addNewCard(newCard): void {
                          this.conversationFlowService.addNewCard(newCard);
                      
                          let totalNumCards = this.playerTranscriptService.getNumCards();
                      
                      

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

                        private moveToNewCard(
                          feedbackHtml: string | null,
                          isFinalQuestion: boolean,
                          nextCard: StateCard
                        ) {

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

                        private _navigateToDisplayedCard(): void {
                          let index = this.playerPositionService.getDisplayedCardIndex();
                          this.displayedCard = this.playerTranscriptService.getCard(index);
                      
                          if (

                        Function _navigateToMostRecentlyReachedCheckpoint has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          private _navigateToMostRecentlyReachedCheckpoint() {
                            let states: StateObjectsBackendDict;
                            this.readOnlyExplorationBackendApiService
                              .loadLatestExplorationAsync(this.explorationId, this.pidInUrl)
                              .then(response => {

                          Function _initializeDirectiveComponents has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            private _initializeDirectiveComponents(initialCard, focusLabel): void {
                              this._addNewCard(initialCard);
                              this.nextCard = initialCard;
                              if (!this.explorationPlayerStateService.isInDiagnosticTestPlayerMode()) {
                                this.explorationPlayerStateService.onPlayerStateChange.emit(

                            Function showPendingCard has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              showPendingCard(): void {
                                this.startCardChangeAnimation = true;
                                this.explorationPlayerStateService.recordNewCardAdded();
                            
                                setTimeout(

                              Function showUpcomingCard has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                              Open

                                showUpcomingCard(): void {
                                  let currentIndex = this.playerPositionService.getDisplayedCardIndex();
                                  let conceptCardIsBeingShown =
                                    this.displayedCard.getStateName() === null &&
                                    !this.explorationPlayerStateService.isInQuestionMode();

                              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

                              Avoid too many return statements within this function.
                              Open

                                      return;

                                Function _initializeDirectiveComponents has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                Open

                                  private _initializeDirectiveComponents(initialCard, focusLabel): void {
                                    this._addNewCard(initialCard);
                                    this.nextCard = initialCard;
                                    if (!this.explorationPlayerStateService.isInDiagnosticTestPlayerMode()) {
                                      this.explorationPlayerStateService.onPlayerStateChange.emit(

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

                                  ngAfterViewChecked(): void {
                                    let submitButtonIsDisabled = this.isSubmitButtonDisabled();
                                    if (submitButtonIsDisabled !== this.submitButtonIsDisabled) {
                                      this.submitButtonIsDisabled = submitButtonIsDisabled;
                                      this.changeDetectorRef.detectChanges();
                                core/templates/components/state-editor/state-content-editor/state-content-editor.component.ts on lines 111..117

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

                                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

                                        if (parentExplorationIds) {
                                          for (let i = 0; i < parentExplorationIds.length - 1; i++) {
                                            result = this.urlService.addField(
                                              result,
                                              'parent',
                                core/templates/components/summary-tile/exploration-summary-tile.component.ts on lines 247..255

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

                                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.directiveSubscriptions.add(
                                        this.hintsAndSolutionManagerService.onHintConsumed.subscribe(() => {
                                          this.questionPlayerStateService.hintUsed(
                                            this.questionPlayerEngineService.getCurrentQuestion()
                                          );
                                core/templates/pages/exploration-player-page/learner-experience/conversation-skin.component.ts on lines 283..291

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

                                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.directiveSubscriptions.add(
                                        this.hintsAndSolutionManagerService.onSolutionViewedEventEmitter.subscribe(
                                          () => {
                                            this.questionPlayerStateService.solutionViewed(
                                              this.questionPlayerEngineService.getCurrentQuestion()
                                core/templates/pages/exploration-player-page/learner-experience/conversation-skin.component.ts on lines 275..281

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

                                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.directiveSubscriptions.add(
                                      this.conceptCardManagerService.onLearnerGetsReallyStuck.subscribe(() => {
                                        this.isLearnerReallyStuck = true;
                                        this.triggerIfLearnerStuckActionDirectly();
                                      })
                                extensions/interactions/InteractiveMap/directives/oppia-interactive-interactive-map.component.ts on lines 98..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 57.

                                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

                                          setTimeout(() => {
                                            let alertInfoElement = document.querySelector(
                                              '.oppia-exploration-checkpoints-message'
                                            );
                                
                                
                                core/templates/pages/exploration-player-page/learner-experience/conversation-skin.component.ts on lines 1055..1064

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

                                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

                                        setTimeout(() => {
                                          let alertInfoElement = document.querySelector(
                                            '.oppia-exploration-checkpoints-message'
                                          );
                                
                                
                                core/templates/pages/exploration-player-page/learner-experience/conversation-skin.component.ts on lines 813..822

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

                                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 (!this.displayedCard.isInteractionInline()) {
                                        this.playerPositionService.onHelpCardAvailable.emit({
                                          helpCardHtml: feedbackHtml,
                                          hasContinueButton: true,
                                        });
                                core/templates/pages/exploration-player-page/learner-experience/conversation-skin.component.ts on lines 1473..1478

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

                                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 (!this.displayedCard.isInteractionInline()) {
                                          this.playerPositionService.onHelpCardAvailable.emit({
                                            helpCardHtml: feedbackHtml,
                                            hasContinueButton: true,
                                          });
                                core/templates/pages/exploration-player-page/learner-experience/conversation-skin.component.ts on lines 1504..1509

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

                                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

                                          let loginRedirectUrl = this.urlInterpolationService.interpolateUrl(
                                            StoryViewerDomainConstants.STORY_PROGRESS_URL_TEMPLATE,
                                            {
                                              topic_url_fragment: topicUrlFragment,
                                              classroom_url_fragment: classroomUrlFragment,
                                core/templates/domain/story_viewer/story-viewer-backend-api.service.ts on lines 108..116

                                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