indrasaputra/orvosi-api

View on GitHub

Showing 9 of 9 total issues

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

func MedicalRecordUpdater(h *handler.MedicalRecordUpdater) []*Route {
    var routes []*Route

    r := &Route{
        Method:      http.MethodPut,
Severity: Minor
Found in internal/http/router/medical_record.go and 1 other location - About 50 mins to fix
internal/http/router/medical_record.go on lines 12..24

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

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

func MedicalRecordCreator(h *handler.MedicalRecordCreator) []*Route {
    var routes []*Route

    r := &Route{
        Method:      http.MethodPost,
Severity: Minor
Found in internal/http/router/medical_record.go and 1 other location - About 50 mins to fix
internal/http/router/medical_record.go on lines 47..59

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

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 err := s.signin.SignIn(ctx.Request().Context(), user); err != nil {
        res := response.NewError(err)
        status := http.StatusInternalServerError
        if err.Code == entity.ErrEmptyUser.Code {
            status = http.StatusBadRequest
Severity: Minor
Found in internal/http/handler/sign_in.go and 1 other location - About 40 mins to fix
internal/http/handler/medical_record_creator.go on lines 51..59

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

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 err := mrc.creator.Create(ctx.Request().Context(), record); err != nil {
        res := response.NewError(err)
        status := http.StatusInternalServerError
        if err.Code != entity.ErrInternalServer.Code {
            status = http.StatusBadRequest
Severity: Minor
Found in internal/http/handler/medical_record_creator.go and 1 other location - About 40 mins to fix
internal/http/handler/sign_in.go on lines 34..42

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

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

Method MedicalRecordUpdater.Update has 5 return statements (exceeds 4 allowed).
Open

func (mru *MedicalRecordUpdater) Update(ctx echo.Context) error {
    str := ctx.Param("id")
    id, herr := hashids.DecodeHash([]byte(str))
    if herr != nil {
        res := response.NewError(entity.ErrInvalidID)
Severity: Major
Found in internal/http/handler/medical_record_updater.go - About 35 mins to fix

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

    func BuildSigner(cfg *config.Config, db *sql.DB) []*router.Route {
        ins := repository.NewUserInserter(db)
        uc := usecase.NewSigner(ins)
        hdr := handler.NewSigner(uc)
        return router.Signer(hdr)
    Severity: Major
    Found in internal/builder/sign_in.go and 3 other locations - About 30 mins to fix
    internal/builder/medical_record.go on lines 15..20
    internal/builder/medical_record.go on lines 24..29
    internal/builder/medical_record.go on lines 33..38

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

    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

    func BuildMedicalRecordCreator(cfg *config.Config, db *sql.DB) []*router.Route {
        ins := repository.NewMedicalRecordInserter(db)
        uc := usecase.NewMedicalRecordCreator(ins)
        hdr := handler.NewMedicalRecordCreator(uc)
        return router.MedicalRecordCreator(hdr)
    Severity: Major
    Found in internal/builder/medical_record.go and 3 other locations - About 30 mins to fix
    internal/builder/medical_record.go on lines 24..29
    internal/builder/medical_record.go on lines 33..38
    internal/builder/sign_in.go on lines 15..20

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

    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

    func BuildMedicalRecordUpdater(cfg *config.Config, db *sql.DB) []*router.Route {
        up := repository.NewMedicalRecordUpdater(db)
        uc := usecase.NewMedicalRecordUpdater(up)
        hdr := handler.NewMedicalRecordUpdater(uc)
        return router.MedicalRecordUpdater(hdr)
    Severity: Major
    Found in internal/builder/medical_record.go and 3 other locations - About 30 mins to fix
    internal/builder/medical_record.go on lines 15..20
    internal/builder/medical_record.go on lines 24..29
    internal/builder/sign_in.go on lines 15..20

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

    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

    func BuildMedicalRecordFinder(cfg *config.Config, db *sql.DB) []*router.Route {
        sel := repository.NewMedicalRecordSelector(db)
        uc := usecase.NewMedicalRecordFinder(sel)
        hdr := handler.NewMedicalRecordFinder(uc)
        return router.MedicalRecordFinder(hdr)
    Severity: Major
    Found in internal/builder/medical_record.go and 3 other locations - About 30 mins to fix
    internal/builder/medical_record.go on lines 15..20
    internal/builder/medical_record.go on lines 33..38
    internal/builder/sign_in.go on lines 15..20

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

    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

    Severity
    Category
    Status
    Source
    Language