core/templates/pages/exploration-editor-page/modal-templates/state-version-history-modal.component.ts

Summary

Maintainability
D
1 day
Test Coverage

Function fetchPreviousVersionHistory has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  fetchPreviousVersionHistory(): void {
    if (!this.versionHistoryService.shouldFetchNewStateVersionHistory()) {
      this.versionHistoryService.incrementCurrentPositionInStateVersionHistoryList();
      return;
    }

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

      onClickExploreBackwardVersionHistory(): void {
        this.yamlStrs.previousVersionStateYaml = '';
        this.yamlStrs.currentVersionStateYaml = '';
    
        const diffData = this.versionHistoryService.getBackwardStateDiffData();

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

      onClickExploreForwardVersionHistory(): void {
        this.yamlStrs.previousVersionStateYaml = '';
        this.yamlStrs.currentVersionStateYaml = '';
    
        const diffData = this.versionHistoryService.getForwardStateDiffData();

    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

          this.versionHistoryBackendApiService
            .fetchStateVersionHistoryAsync(
              this.contextService.getExplorationId(),
              diffData.oldState.name,
              diffData.oldVersionNumber
    core/templates/pages/exploration-editor-page/modal-templates/metadata-version-history-modal.component.ts on lines 187..204

    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

        if (diffData.oldState) {
          this.oldState = diffData.oldState;
          if (diffData.oldState.name === null) {
            // The state name is null before having a state
            // (please refer to the implementation of State object from
    core/templates/pages/exploration-editor-page/modal-templates/state-version-history-modal.component.ts on lines 149..160

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

    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 (diffData.oldState) {
          this.oldState = diffData.oldState;
          if (diffData.oldState.name === null) {
            // The state name is null before having a state
            // (please refer to the implementation of State object from
    core/templates/pages/exploration-editor-page/modal-templates/state-version-history-modal.component.ts on lines 195..206

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

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

      getLastEditedVersionNumber(): number {
        const lastEditedVersionNumber =
          this.versionHistoryService.getBackwardStateDiffData().oldVersionNumber;
        if (lastEditedVersionNumber === null) {
          // A null value for lastEditedVersionNumber marks the end of the version
    core/templates/pages/exploration-editor-page/editor-tab/state-version-history/state-version-history.component.ts on lines 48..60
    core/templates/pages/exploration-editor-page/modal-templates/metadata-version-history-modal.component.ts on lines 84..96
    core/templates/pages/exploration-editor-page/modal-templates/metadata-version-history-modal.component.ts on lines 109..121
    core/templates/pages/exploration-editor-page/modal-templates/state-version-history-modal.component.ts on lines 111..123
    core/templates/pages/exploration-editor-page/settings-tab/settings-tab.component.ts on lines 295..307

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

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

      getNextEditedVersionNumber(): number {
        const nextEditedVersionNumber =
          this.versionHistoryService.getForwardStateDiffData().oldVersionNumber;
        if (nextEditedVersionNumber === null) {
          // A null value for nextEditedVersionNumber marks the end of the version
    core/templates/pages/exploration-editor-page/editor-tab/state-version-history/state-version-history.component.ts on lines 48..60
    core/templates/pages/exploration-editor-page/modal-templates/metadata-version-history-modal.component.ts on lines 84..96
    core/templates/pages/exploration-editor-page/modal-templates/metadata-version-history-modal.component.ts on lines 109..121
    core/templates/pages/exploration-editor-page/modal-templates/state-version-history-modal.component.ts on lines 86..98
    core/templates/pages/exploration-editor-page/settings-tab/settings-tab.component.ts on lines 295..307

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

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

      constructor(
        private ngbActiveModal: NgbActiveModal,
        private contextService: ContextService,
        private versionHistoryService: VersionHistoryService,
        private versionHistoryBackendApiService: VersionHistoryBackendApiService,
    core/templates/pages/exploration-editor-page/modal-templates/lost-changes-modal.component.ts on lines 44..52
    core/templates/pages/exploration-editor-page/modal-templates/metadata-version-history-modal.component.ts on lines 66..74
    core/templates/pages/exploration-player-page/modals/refresher-exploration-confirmation-modal.component.ts on lines 37..45
    core/templates/pages/topic-editor-page/modal-templates/create-new-story-modal.component.ts on lines 34..42
    core/templates/pages/topic-editor-page/modal-templates/create-new-subtopic-modal.component.ts on lines 61..69
    core/templates/pages/topic-editor-page/modal-templates/rearrange-skills-in-subtopics-modal.component.ts on lines 58..66
    core/templates/pages/topics-and-skills-dashboard-page/modals/create-new-topic-modal.component.ts on lines 50..58

    Duplicated Code

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

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

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

    Tuning

    This issue has a mass of 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 4 locations. Consider refactoring.
    Open

      updateRightPane(): void {
        this.historyTabYamlConversionService
          .getYamlStringFromStateOrMetadata(this.newState)
          .then(result => {
            this.yamlStrs.currentVersionStateYaml = result;
    core/templates/pages/exploration-editor-page/modal-templates/metadata-version-history-modal.component.ts on lines 208..214
    core/templates/pages/exploration-editor-page/modal-templates/metadata-version-history-modal.component.ts on lines 216..222
    core/templates/pages/exploration-editor-page/modal-templates/state-version-history-modal.component.ts on lines 267..273

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

      updateLeftPane(): void {
        this.historyTabYamlConversionService
          .getYamlStringFromStateOrMetadata(this.oldState)
          .then(result => {
            this.yamlStrs.previousVersionStateYaml = result;
    core/templates/pages/exploration-editor-page/modal-templates/metadata-version-history-modal.component.ts on lines 208..214
    core/templates/pages/exploration-editor-page/modal-templates/metadata-version-history-modal.component.ts on lines 216..222
    core/templates/pages/exploration-editor-page/modal-templates/state-version-history-modal.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 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

    There are no issues that match your filters.

    Category
    Status