ElectronicBabylonianLiterature/ebl-frontend

View on GitHub
src/fragmentarium/application/FragmentService.ts

Summary

Maintainability
C
1 day
Test Coverage
A
90%

FragmentService has 41 functions (exceeds 20 allowed). Consider refactoring.
Open

export class FragmentService {
  private readonly referenceInjector: ReferenceInjector

  constructor(
    private readonly fragmentRepository: FragmentRepository &
Severity: Minor
Found in src/fragmentarium/application/FragmentService.ts - About 5 hrs to fix

    File FragmentService.ts has 362 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import Reference from 'bibliography/domain/Reference'
    import Bluebird from 'bluebird'
    import DictionaryWord from 'dictionary/domain/Word'
    import Annotation from 'fragmentarium/domain/annotation'
    import Folio from 'fragmentarium/domain/Folio'
    Severity: Minor
    Found in src/fragmentarium/application/FragmentService.ts - About 4 hrs to fix

      Similar blocks of code found in 6 locations. Consider refactoring.
      Wontfix

        updateGenres(number: string, genres: Genres): Bluebird<Fragment> {
          return this.fragmentRepository
            .updateGenres(number, genres)
            .then((fragment: Fragment) => this.injectReferences(fragment))
        }
      Severity: Major
      Found in src/fragmentarium/application/FragmentService.ts and 5 other locations - About 1 hr to fix
      src/fragmentarium/application/FragmentService.ts on lines 166..170
      src/fragmentarium/application/FragmentService.ts on lines 172..176
      src/fragmentarium/application/FragmentService.ts on lines 246..253
      src/fragmentarium/application/FragmentService.ts on lines 264..271
      src/fragmentarium/application/FragmentService.ts on lines 273..277

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

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

        updateDate(number: string, date: MesopotamianDate): Bluebird<Fragment> {
          return this.fragmentRepository
            .updateDate(number, date)
            .then((fragment: Fragment) => this.injectReferences(fragment))
        }
      Severity: Major
      Found in src/fragmentarium/application/FragmentService.ts and 5 other locations - About 1 hr to fix
      src/fragmentarium/application/FragmentService.ts on lines 160..164
      src/fragmentarium/application/FragmentService.ts on lines 166..170
      src/fragmentarium/application/FragmentService.ts on lines 246..253
      src/fragmentarium/application/FragmentService.ts on lines 264..271
      src/fragmentarium/application/FragmentService.ts on lines 273..277

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

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

        updateLemmatization(
          number: string,
          lemmatization: LemmatizationDto
        ): Bluebird<Fragment> {
          return this.fragmentRepository
      Severity: Major
      Found in src/fragmentarium/application/FragmentService.ts and 5 other locations - About 1 hr to fix
      src/fragmentarium/application/FragmentService.ts on lines 160..164
      src/fragmentarium/application/FragmentService.ts on lines 166..170
      src/fragmentarium/application/FragmentService.ts on lines 172..176
      src/fragmentarium/application/FragmentService.ts on lines 264..271
      src/fragmentarium/application/FragmentService.ts on lines 273..277

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

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

        updateColophon(number: string, colophon: Colophon): Bluebird<Fragment> {
          return this.fragmentRepository
            .updateColophon(number, colophon)
            .then((fragment: Fragment) => this.injectReferences(fragment))
        }
      Severity: Major
      Found in src/fragmentarium/application/FragmentService.ts and 5 other locations - About 1 hr to fix
      src/fragmentarium/application/FragmentService.ts on lines 160..164
      src/fragmentarium/application/FragmentService.ts on lines 166..170
      src/fragmentarium/application/FragmentService.ts on lines 172..176
      src/fragmentarium/application/FragmentService.ts on lines 246..253
      src/fragmentarium/application/FragmentService.ts on lines 264..271

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

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

        updateScript(number: string, script: Script): Bluebird<Fragment> {
          return this.fragmentRepository
            .updateScript(number, script)
            .then((fragment: Fragment) => this.injectReferences(fragment))
        }
      Severity: Major
      Found in src/fragmentarium/application/FragmentService.ts and 5 other locations - About 1 hr to fix
      src/fragmentarium/application/FragmentService.ts on lines 160..164
      src/fragmentarium/application/FragmentService.ts on lines 172..176
      src/fragmentarium/application/FragmentService.ts on lines 246..253
      src/fragmentarium/application/FragmentService.ts on lines 264..271
      src/fragmentarium/application/FragmentService.ts on lines 273..277

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

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

        updateArchaeology(
          number: string,
          archaeology: ArchaeologyDto
        ): Bluebird<Fragment> {
          return this.fragmentRepository
      Severity: Major
      Found in src/fragmentarium/application/FragmentService.ts and 5 other locations - About 1 hr to fix
      src/fragmentarium/application/FragmentService.ts on lines 160..164
      src/fragmentarium/application/FragmentService.ts on lines 166..170
      src/fragmentarium/application/FragmentService.ts on lines 172..176
      src/fragmentarium/application/FragmentService.ts on lines 246..253
      src/fragmentarium/application/FragmentService.ts on lines 273..277

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

      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 3 locations. Consider refactoring.
      Invalid

        updateIntroduction(number: string, introduction: string): Bluebird<Fragment> {
          return this.fragmentRepository
            .updateIntroduction(number, introduction)
            .then((fragment: Fragment) => this.injectReferences(fragment))
        }
      Severity: Major
      Found in src/fragmentarium/application/FragmentService.ts and 2 other locations - About 1 hr to fix
      src/fragmentarium/application/FragmentService.ts on lines 207..214
      src/fragmentarium/application/FragmentService.ts on lines 222..226

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

      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 3 locations. Consider refactoring.
      Invalid

        updateTransliteration(
          number: string,
          transliteration: string
        ): Bluebird<Fragment> {
          return this.fragmentRepository
      Severity: Major
      Found in src/fragmentarium/application/FragmentService.ts and 2 other locations - About 1 hr to fix
      src/fragmentarium/application/FragmentService.ts on lines 216..220
      src/fragmentarium/application/FragmentService.ts on lines 222..226

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

      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 3 locations. Consider refactoring.
      Invalid

        updateNotes(number: string, notes: string): Bluebird<Fragment> {
          return this.fragmentRepository
            .updateNotes(number, notes)
            .then((fragment: Fragment) => this.injectReferences(fragment))
        }
      Severity: Major
      Found in src/fragmentarium/application/FragmentService.ts and 2 other locations - About 1 hr to fix
      src/fragmentarium/application/FragmentService.ts on lines 207..214
      src/fragmentarium/application/FragmentService.ts on lines 216..220

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

      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

        searchLemma(lemma: string): Bluebird<readonly Word[]> {
          return _.isEmpty(lemma)
            ? Bluebird.resolve([])
            : this.wordRepository.searchLemma(lemma)
        }
      Severity: Major
      Found in src/fragmentarium/application/FragmentService.ts and 1 other location - About 1 hr to fix
      src/dictionary/application/WordService.ts on lines 35..39

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

      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
            .injectReferencesToText(fragment.text)
            .then((text) =>
              produce(fragment, (draft) => {
                draft.text = castDraft(text)
      Severity: Major
      Found in src/fragmentarium/application/FragmentService.ts and 1 other location - About 1 hr to fix
      src/corpus/application/TextService.ts on lines 291..297

      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

        findAnnotations(number: string): Bluebird<readonly Annotation[]> {
          return this.fragmentRepository.findAnnotations(number, false)
        }
      Severity: Minor
      Found in src/fragmentarium/application/FragmentService.ts and 1 other location - About 30 mins to fix
      src/fragmentarium/application/FragmentService.ts on lines 339..341

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

        generateAnnotations(number: string): Bluebird<readonly Annotation[]> {
          return this.fragmentRepository.findAnnotations(number, true)
        }
      Severity: Minor
      Found in src/fragmentarium/application/FragmentService.ts and 1 other location - About 30 mins to fix
      src/fragmentarium/application/FragmentService.ts on lines 336..338

      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