rl404/go-malscraper

View on GitHub
internal/cacher/character.go

Summary

Maintainability
C
1 day
Test Coverage

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

func (c *Cacher) GetCharacterOgraphy(t string, id int) (data []model.Role, code int, err error) {
    // Get from cache.
    key := internal.GetKey(internal.KeyCharacterOgraphy, t, id)
    if c.cacher.Get(key, &data) == nil {
        return data, http.StatusOK, nil
Severity: Major
Found in internal/cacher/character.go and 21 other locations - About 1 hr to fix
internal/cacher/anime.go on lines 87..103
internal/cacher/anime.go on lines 125..141
internal/cacher/article.go on lines 30..46
internal/cacher/club.go on lines 49..65
internal/cacher/genre.go on lines 30..46
internal/cacher/genre.go on lines 49..65
internal/cacher/manga.go on lines 30..46
internal/cacher/news.go on lines 30..46
internal/cacher/producer_magazine.go on lines 30..46
internal/cacher/producer_magazine.go on lines 68..84
internal/cacher/recommendation.go on lines 30..46
internal/cacher/review.go on lines 30..46
internal/cacher/search.go on lines 21..37
internal/cacher/search.go on lines 40..56
internal/cacher/season.go on lines 11..27
internal/cacher/top.go on lines 11..27
internal/cacher/top.go on lines 30..46
internal/cacher/user.go on lines 68..84
internal/cacher/user.go on lines 87..103
internal/cacher/user.go on lines 106..122
internal/cacher/user.go on lines 125..141

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

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

func (c *Cacher) GetCharacter(id int) (data *model.Character, code int, err error) {
    // Get from cache.
    key := internal.GetKey(internal.KeyCharacter, id)
    if c.cacher.Get(key, &data) == nil {
        return data, http.StatusOK, nil
Severity: Major
Found in internal/cacher/character.go and 13 other locations - About 1 hr to fix
internal/cacher/anime.go on lines 11..27
internal/cacher/anime.go on lines 106..122
internal/cacher/article.go on lines 11..27
internal/cacher/club.go on lines 30..46
internal/cacher/club.go on lines 87..103
internal/cacher/manga.go on lines 11..27
internal/cacher/manga.go on lines 68..84
internal/cacher/news.go on lines 11..27
internal/cacher/people.go on lines 11..27
internal/cacher/review.go on lines 11..27
internal/cacher/user.go on lines 11..27
internal/cacher/user.go on lines 30..46
internal/cacher/user.go on lines 49..65

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

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

func (c *Cacher) GetCharacterClub(id int) (data []model.ClubItem, code int, err error) {
    // Get from cache.
    key := internal.GetKey(internal.KeyCharacterClub, id)
    if c.cacher.Get(key, &data) == nil {
        return data, http.StatusOK, nil
Severity: Major
Found in internal/cacher/character.go and 23 other locations - About 1 hr to fix
internal/cacher/anime.go on lines 30..46
internal/cacher/anime.go on lines 49..65
internal/cacher/anime.go on lines 144..160
internal/cacher/anime.go on lines 163..179
internal/cacher/anime.go on lines 182..198
internal/cacher/anime.go on lines 201..217
internal/cacher/character.go on lines 30..46
internal/cacher/character.go on lines 106..122
internal/cacher/club.go on lines 11..27
internal/cacher/genre.go on lines 11..27
internal/cacher/manga.go on lines 49..65
internal/cacher/manga.go on lines 87..103
internal/cacher/manga.go on lines 106..122
internal/cacher/manga.go on lines 125..141
internal/cacher/manga.go on lines 144..160
internal/cacher/people.go on lines 30..46
internal/cacher/people.go on lines 49..65
internal/cacher/people.go on lines 68..84
internal/cacher/people.go on lines 87..103
internal/cacher/people.go on lines 106..122
internal/cacher/top.go on lines 49..65
internal/cacher/top.go on lines 68..84
internal/cacher/user.go on lines 144..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 167.

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

func (c *Cacher) GetCharacterArticle(id int) (data []model.ArticleItem, code int, err error) {
    // Get from cache.
    key := internal.GetKey(internal.KeyCharacterArticle, id)
    if c.cacher.Get(key, &data) == nil {
        return data, http.StatusOK, nil
Severity: Major
Found in internal/cacher/character.go and 23 other locations - About 1 hr to fix
internal/cacher/anime.go on lines 30..46
internal/cacher/anime.go on lines 49..65
internal/cacher/anime.go on lines 144..160
internal/cacher/anime.go on lines 163..179
internal/cacher/anime.go on lines 182..198
internal/cacher/anime.go on lines 201..217
internal/cacher/character.go on lines 87..103
internal/cacher/character.go on lines 106..122
internal/cacher/club.go on lines 11..27
internal/cacher/genre.go on lines 11..27
internal/cacher/manga.go on lines 49..65
internal/cacher/manga.go on lines 87..103
internal/cacher/manga.go on lines 106..122
internal/cacher/manga.go on lines 125..141
internal/cacher/manga.go on lines 144..160
internal/cacher/people.go on lines 30..46
internal/cacher/people.go on lines 49..65
internal/cacher/people.go on lines 68..84
internal/cacher/people.go on lines 87..103
internal/cacher/people.go on lines 106..122
internal/cacher/top.go on lines 49..65
internal/cacher/top.go on lines 68..84
internal/cacher/user.go on lines 144..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 167.

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

func (c *Cacher) GetCharacterVA(id int) (data []model.Role, code int, err error) {
    // Get from cache.
    key := internal.GetKey(internal.KeyCharacterVA, id)
    if c.cacher.Get(key, &data) == nil {
        return data, http.StatusOK, nil
Severity: Major
Found in internal/cacher/character.go and 23 other locations - About 1 hr to fix
internal/cacher/anime.go on lines 30..46
internal/cacher/anime.go on lines 49..65
internal/cacher/anime.go on lines 144..160
internal/cacher/anime.go on lines 163..179
internal/cacher/anime.go on lines 182..198
internal/cacher/anime.go on lines 201..217
internal/cacher/character.go on lines 30..46
internal/cacher/character.go on lines 87..103
internal/cacher/club.go on lines 11..27
internal/cacher/genre.go on lines 11..27
internal/cacher/manga.go on lines 49..65
internal/cacher/manga.go on lines 87..103
internal/cacher/manga.go on lines 106..122
internal/cacher/manga.go on lines 125..141
internal/cacher/manga.go on lines 144..160
internal/cacher/people.go on lines 30..46
internal/cacher/people.go on lines 49..65
internal/cacher/people.go on lines 68..84
internal/cacher/people.go on lines 87..103
internal/cacher/people.go on lines 106..122
internal/cacher/top.go on lines 49..65
internal/cacher/top.go on lines 68..84
internal/cacher/user.go on lines 144..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 167.

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

func (c *Cacher) GetCharacterPicture(id int) (data []string, code int, err error) {
    // Get from cache.
    key := internal.GetKey(internal.KeyCharacterPicture, id)
    if c.cacher.Get(key, &data) == nil {
        return data, http.StatusOK, nil
Severity: Major
Found in internal/cacher/character.go and 4 other locations - About 1 hr to fix
internal/cacher/anime.go on lines 220..236
internal/cacher/club.go on lines 68..84
internal/cacher/manga.go on lines 163..179
internal/cacher/people.go on lines 125..141

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

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