ElectronicBabylonianLiterature/ebl-frontend

View on GitHub
src/fragmentarium/infrastructure/FragmentRepository.ts

Summary

Maintainability
D
1 day
Test Coverage
A
90%

File FragmentRepository.ts has 392 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import Promise from 'bluebird'
import _ from 'lodash'
import { stringify } from 'query-string'
import produce from 'immer'
import {
Severity: Minor
Found in src/fragmentarium/infrastructure/FragmentRepository.ts - About 5 hrs to fix

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

    class ApiFragmentRepository
      implements FragmentInfoRepository, FragmentRepository, AnnotationRepository {
      constructor(private readonly apiClient: JsonApiClient) {}
    
      statistics(): Promise<{ transliteratedFragments: number; lines: number }> {
    Severity: Minor
    Found in src/fragmentarium/infrastructure/FragmentRepository.ts - About 4 hrs to fix

      Function createFragment has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Wontfix

      function createFragment(dto: FragmentDto): Fragment {
        const museumKey: MuseumKey = dto.museum
        return Fragment.create({
          ...dto,
          number: museumNumberToString(dto.museumNumber),
      Severity: Minor
      Found in src/fragmentarium/infrastructure/FragmentRepository.ts - About 1 hr to fix

        Function createFragment has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Wontfix

        function createFragment(dto: FragmentDto): Fragment {
          const museumKey: MuseumKey = dto.museum
          return Fragment.create({
            ...dto,
            number: museumNumberToString(dto.museumNumber),
        Severity: Minor
        Found in src/fragmentarium/infrastructure/FragmentRepository.ts - About 35 mins to fix

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

          updateColophon(number: string, colophon: Colophon): Promise<Fragment> {
            const path = createFragmentPath(number, 'colophon')
            return this.apiClient
              .postJson(path, { colophon: colophon })
              .then(createFragment)
        Severity: Major
        Found in src/fragmentarium/infrastructure/FragmentRepository.ts and 3 other locations - About 1 hr to fix
        src/fragmentarium/infrastructure/FragmentRepository.ts on lines 240..243
        src/fragmentarium/infrastructure/FragmentRepository.ts on lines 283..291
        src/fragmentarium/infrastructure/FragmentRepository.ts on lines 300..308

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

          updateDate(number: string, date: MesopotamianDate): Promise<Fragment> {
            const path = createFragmentPath(number, 'date')
            return this.apiClient.postJson(path, { date }).then(createFragment)
          }
        Severity: Major
        Found in src/fragmentarium/infrastructure/FragmentRepository.ts and 3 other locations - About 1 hr to fix
        src/fragmentarium/infrastructure/FragmentRepository.ts on lines 283..291
        src/fragmentarium/infrastructure/FragmentRepository.ts on lines 300..308
        src/fragmentarium/infrastructure/FragmentRepository.ts on lines 310..315

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

          updateArchaeology(
            number: string,
            archaeology: ArchaeologyDto
          ): Promise<Fragment> {
            const path = createFragmentPath(number, 'archaeology')
        Severity: Major
        Found in src/fragmentarium/infrastructure/FragmentRepository.ts and 3 other locations - About 1 hr to fix
        src/fragmentarium/infrastructure/FragmentRepository.ts on lines 240..243
        src/fragmentarium/infrastructure/FragmentRepository.ts on lines 283..291
        src/fragmentarium/infrastructure/FragmentRepository.ts on lines 310..315

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

          updateLemmatization(
            number: string,
            lemmatization: LemmatizationDto
          ): Promise<Fragment> {
            const path = createFragmentPath(number, 'lemmatization')
        Severity: Major
        Found in src/fragmentarium/infrastructure/FragmentRepository.ts and 3 other locations - About 1 hr to fix
        src/fragmentarium/infrastructure/FragmentRepository.ts on lines 240..243
        src/fragmentarium/infrastructure/FragmentRepository.ts on lines 300..308
        src/fragmentarium/infrastructure/FragmentRepository.ts on lines 310..315

        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

          updateTransliteration(
            number: string,
            transliteration: string
          ): Promise<Fragment> {
            const path = createFragmentPath(number, 'transliteration')
        Severity: Major
        Found in src/fragmentarium/infrastructure/FragmentRepository.ts and 2 other locations - About 1 hr to fix
        src/fragmentarium/infrastructure/FragmentRepository.ts on lines 265..272
        src/fragmentarium/infrastructure/FragmentRepository.ts on lines 274..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 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): Promise<Fragment> {
            const path = createFragmentPath(number, 'notes')
            return this.apiClient
              .postJson(path, {
                notes: notes,
        Severity: Major
        Found in src/fragmentarium/infrastructure/FragmentRepository.ts and 2 other locations - About 1 hr to fix
        src/fragmentarium/infrastructure/FragmentRepository.ts on lines 253..263
        src/fragmentarium/infrastructure/FragmentRepository.ts on lines 265..272

        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

          updateIntroduction(number: string, introduction: string): Promise<Fragment> {
            const path = createFragmentPath(number, 'introduction')
            return this.apiClient
              .postJson(path, {
                introduction: introduction,
        Severity: Major
        Found in src/fragmentarium/infrastructure/FragmentRepository.ts and 2 other locations - About 1 hr to fix
        src/fragmentarium/infrastructure/FragmentRepository.ts on lines 253..263
        src/fragmentarium/infrastructure/FragmentRepository.ts on lines 274..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 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 4 locations. Consider refactoring.
        Open

          fragmentPager(fragmentNumber: string): Promise<FragmentPagerData> {
            return this.apiClient.fetchJson(
              `/fragments/${encodeURIComponent(fragmentNumber)}/pager`,
              false
            )
        Severity: Major
        Found in src/fragmentarium/infrastructure/FragmentRepository.ts and 3 other locations - About 55 mins to fix
        src/dictionary/infrastructure/WordRepository.ts on lines 12..14
        src/fragmentarium/infrastructure/ImageRepository.ts on lines 18..23
        src/fragmentarium/infrastructure/ImageRepository.ts on lines 31..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 54.

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

          fetchNeedsRevision(): FragmentInfosPromise {
            return this._fetch({ needsRevision: true }).then((fragmentInfos) =>
              fragmentInfos.map(createFragmentInfo)
            )
          }
        Severity: Major
        Found in src/fragmentarium/infrastructure/FragmentRepository.ts and 2 other locations - About 50 mins to fix
        src/fragmentarium/infrastructure/FragmentRepository.ts on lines 177..181
        src/fragmentarium/infrastructure/FragmentRepository.ts on lines 183..187

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

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

          random(): FragmentInfosPromise {
            return this._fetch({ random: true }).then((fragmentInfos) =>
              fragmentInfos.map(createFragmentInfo)
            )
          }
        Severity: Major
        Found in src/fragmentarium/infrastructure/FragmentRepository.ts and 2 other locations - About 50 mins to fix
        src/fragmentarium/infrastructure/FragmentRepository.ts on lines 183..187
        src/fragmentarium/infrastructure/FragmentRepository.ts on lines 189..193

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

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

          interesting(): FragmentInfosPromise {
            return this._fetch({ interesting: true }).then((fragmentInfos) =>
              fragmentInfos.map(createFragmentInfo)
            )
          }
        Severity: Major
        Found in src/fragmentarium/infrastructure/FragmentRepository.ts and 2 other locations - About 50 mins to fix
        src/fragmentarium/infrastructure/FragmentRepository.ts on lines 177..181
        src/fragmentarium/infrastructure/FragmentRepository.ts on lines 189..193

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

        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