ElectronicBabylonianLiterature/ebl-frontend

View on GitHub
src/corpus/application/TextService.ts

Summary

Maintainability
D
2 days
Test Coverage
B
89%

File TextService.ts has 418 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import Bluebird from 'bluebird'
import produce, { castDraft } from 'immer'
import _ from 'lodash'
import { stringify } from 'query-string'

Severity: Minor
Found in src/corpus/application/TextService.ts - About 6 hrs to fix

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

      findChapterDisplay(
        id: ChapterId,
        lines: readonly number[] = [],
        variants: readonly number[] = []
      ): Bluebird<ChapterDisplay> {
    Severity: Major
    Found in src/corpus/application/TextService.ts - About 2 hrs to fix

      TextService has 21 functions (exceeds 20 allowed). Consider refactoring.
      Wontfix

      export default class TextService {
        private readonly referenceInjector: ReferenceInjector
      
        constructor(
          private readonly apiClient: ApiClient,
      Severity: Minor
      Found in src/corpus/application/TextService.ts - About 2 hrs to fix

        Function findChapterLine has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          findChapterLine(
            id: ChapterId,
            number: number,
            variantNumber: number
          ): Bluebird<LineDetails> {
        Severity: Minor
        Found in src/corpus/application/TextService.ts - About 1 hr to fix

          Function findLineVariant has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            findLineVariant(
              variant: LineVariantDisplayDto,
              isPrimaryVariant: boolean
            ): Bluebird<LineVariantDisplay> {
              return Bluebird.all([
          Severity: Minor
          Found in src/corpus/application/TextService.ts - About 1 hr to fix

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

              findColophons(id: ChapterId): Bluebird<SiglumAndTransliteration[]> {
                return this.apiClient
                  .fetchJson(`${createChapterUrl(id)}/colophons`, false)
                  .then(fromSiglumAndTransliterationDto)
                  .then((colophons) =>
            Severity: Major
            Found in src/corpus/application/TextService.ts and 1 other location - About 5 hrs to fix
            src/corpus/application/TextService.ts on lines 332..348

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

            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

              findUnplacedLines(id: ChapterId): Bluebird<SiglumAndTransliteration[]> {
                return this.apiClient
                  .fetchJson(`${createChapterUrl(id)}/unplaced_lines`, false)
                  .then(fromSiglumAndTransliterationDto)
                  .then((unplacedLines) =>
            Severity: Major
            Found in src/corpus/application/TextService.ts and 1 other location - About 5 hrs to fix
            src/corpus/application/TextService.ts on lines 314..330

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

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

              updateAlignment(
                id: ChapterId,
                alignment: ChapterAlignment
              ): Bluebird<Chapter> {
                return this.apiClient
            Severity: Major
            Found in src/corpus/application/TextService.ts and 1 other location - About 2 hrs to fix
            src/corpus/application/TextService.ts on lines 397..407

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

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

              updateLemmatization(
                id: ChapterId,
                lemmatization: ChapterLemmatization
              ): Bluebird<Chapter> {
                return this.apiClient
            Severity: Major
            Found in src/corpus/application/TextService.ts and 1 other location - About 2 hrs to fix
            src/corpus/application/TextService.ts on lines 388..395

            Duplicated Code

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

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

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

            Tuning

            This issue has a mass of 75.

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

              list(): Bluebird<Text[]> {
                return this.apiClient
                  .fetchJson('/texts', false)
                  .then((dtos) => dtos.map(fromDto))
              }
            Severity: Major
            Found in src/corpus/application/TextService.ts and 1 other location - About 1 hr to fix
            src/fragmentarium/infrastructure/FindspotRepository.ts on lines 13..17

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

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

              query(query: CorpusQuery): Bluebird<CorpusQueryResult> {
                return this.apiClient.fetchJson(`/corpus/query?${stringify(query)}`, false)
              }
            Severity: Major
            Found in src/corpus/application/TextService.ts and 1 other location - About 1 hr to fix
            src/corpus/application/TextService.ts on lines 350..355

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

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

              findExtantLines(id: ChapterId): Bluebird<ExtantLines> {
                return this.apiClient.fetchJson(
                  `${createChapterUrl(id)}/extant_lines`,
                  false
                )
            Severity: Major
            Found in src/corpus/application/TextService.ts and 1 other location - About 1 hr to fix
            src/corpus/application/TextService.ts on lines 384..386

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

            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

                                  return this.referenceInjector
                                    .injectReferencesToMarkup(line.parts)
                                    .then((parts) =>
                                      produce(line, (draft) => {
                                        draft.parts = castDraft(parts)
            Severity: Major
            Found in src/corpus/application/TextService.ts and 1 other location - About 1 hr to fix
            src/fragmentarium/application/FragmentService.ts on lines 387..393

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

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

              findManuscripts(id: ChapterId): Bluebird<Manuscript[]> {
                return this.apiClient
                  .fetchJson(`${createChapterUrl(id)}/manuscripts`, false)
                  .then((manuscripts) => manuscripts.map(fromManuscriptDto))
              }
            Severity: Minor
            Found in src/corpus/application/TextService.ts and 1 other location - About 55 mins to fix
            src/bibliography/infrastructure/BibliographyRepository.ts on lines 32..36

            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

            There are no issues that match your filters.

            Category
            Status